You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.3 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __STORAGE_PROVIDER_HEADERS__
  2. #define __STORAGE_PROVIDER_HEADERS__
  3. #include "../../components/base/basicMutex.h"
  4. #include "../../components/base/basicFunctionality.h"
  5. #include "../../components/base/basicLogCollection.h"
  6. #include "../../alg/generic/md5.h"
  7. #ifdef __linux__
  8. #include <sys/stat.h>
  9. #include <sys/types.h>
  10. #define STORAGE_DIR_MODE 0x1FF
  11. #define STORAGE_FILE_MODE 0x1B6
  12. #else
  13. #include <direct.h>
  14. #endif
  15. class storageProvider{
  16. private:
  17. basicLogCollection *m_pLog;
  18. CSTR m_pCWD;
  19. CSTR m_pSeriesBase;
  20. CSTR m_pEntryFolder;
  21. U32 m_nSeriesCounter;
  22. CSTR m_pBasePath;
  23. basicMutex m_mCounterProtectorMutex;
  24. public:
  25. // Method to fetch singleton instance.
  26. static storageProvider* getInstance(CSTR Base = "data/storage");
  27. ~storageProvider();
  28. bool startNewSeries(void);
  29. bool startNewEntry(void);
  30. CSTR getNewFileName(void);
  31. CSTR getStorageBase(void) { return m_pBasePath; };
  32. protected:
  33. // Constructor - protected so users cannot call it.
  34. explicit storageProvider(CSTR BasePath);
  35. private:
  36. // private static member referencing the single instance of the object
  37. // TODO: Replace basicEventHeap with the type of object you want to
  38. // return the single instance of
  39. static storageProvider* _instance;
  40. };
  41. #endif