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.

50 lines
1.4 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 years ago
​
6 years ago
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. bool m_bStorageInitComplete;
  25. public:
  26. // Method to fetch singleton instance.
  27. static storageProvider* getInstance(CSTR Base = (CSTR)"data/storage");
  28. ~storageProvider();
  29. bool startNewSeries(void);
  30. bool startNewEntry(void);
  31. CSTR getCurrentFilePath(void);
  32. CSTR getNewFileName(CSTR JustFileName = NULL);
  33. CSTR getStorageBase(void) { return m_pBasePath; };
  34. protected:
  35. // Constructor - protected so users cannot call it.
  36. explicit storageProvider(CSTR BasePath);
  37. private:
  38. // private static member referencing the single instance of the object
  39. // TODO: Replace basicEventHeap with the type of object you want to
  40. // return the single instance of
  41. static storageProvider* _instance;
  42. };
  43. #endif