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.

49 lines
1.4 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 getCurrentFilePath(void);
  31. CSTR getNewFileName(CSTR JustFileName = NULL);
  32. CSTR getStorageBase(void) { return m_pBasePath; };
  33. protected:
  34. // Constructor - protected so users cannot call it.
  35. explicit storageProvider(CSTR BasePath);
  36. private:
  37. // private static member referencing the single instance of the object
  38. // TODO: Replace basicEventHeap with the type of object you want to
  39. // return the single instance of
  40. static storageProvider* _instance;
  41. };
  42. #endif