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.

103 lines
2.3 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __BASICSETTINGSPROVIDER_H_INCL__
  2. #define __BASICSETTINGSPROVIDER_H_INCL__
  3. #include "basicLogCollection.h"
  4. #include <libconfig.h>
  5. // #pragma message("Debug: Test point riched 1!")
  6. #include "basicFunctionality.h"
  7. #define DEFAULT_SETTINGS_FILE_NAME "default.conf"
  8. /**
  9. * TODO: Add class description
  10. *
  11. * @author Gagua
  12. */
  13. class basicSettingsProvider
  14. {
  15. public:
  16. // Method to fetch singleton instance.
  17. static basicSettingsProvider * getInstance(CSTR configName = NULL);
  18. // Destructor
  19. virtual ~basicSettingsProvider();
  20. bool reload(void);
  21. bool validate(void);
  22. bool saveTo(CSTR fileName);
  23. bool isCompromised(void)
  24. {
  25. return m_bModified;
  26. }
  27. void compromise(void)
  28. {
  29. m_bModified = true;
  30. }
  31. config_setting_t * getSubNode(config_setting_t * Parent, CSTR NodeName);
  32. protected:
  33. // Constructor - protected so users cannot call it.
  34. explicit basicSettingsProvider(CSTR configName = NULL);
  35. private:
  36. config_t m_sCfg;
  37. config_setting_t * m_pRootNode;
  38. basicLogCollection * m_pLog;
  39. char m_pFileName[MAX_PATH];
  40. bool m_bLoadded;
  41. bool m_bModified;
  42. bool load(void);
  43. bool save(void);
  44. bool clear(void);
  45. config_setting_t * getRoot(void)
  46. {
  47. return (m_bLoadded ? m_pRootNode : NULL);
  48. }
  49. // private static member referencing the single instance of the object
  50. // TODO: Replace basicSettingsProvider with the type of object you want to
  51. // return the single instance of
  52. static basicSettingsProvider * _instance;
  53. // Copy constructor
  54. // Declared but not defined to prevent auto-generated
  55. // copy constructor. Refer to "Effective C++" by Meyers
  56. basicSettingsProvider(const basicSettingsProvider & src);
  57. // Assignment operator
  58. // Declared but not defined to prevent auto-generated
  59. // assignment operator. Refer to "Effective C++" by Meyers
  60. basicSettingsProvider & operator=(const basicSettingsProvider & src);
  61. };
  62. // TODO: Uncomment the copy constructor when you need it.
  63. // inline basicSettingsProvider::basicSettingsProvider(const basicSettingsProvider& src)
  64. //{
  65. // // TODO: copy
  66. //}
  67. // TODO: Uncomment the assignment operator when you need it.
  68. // inline basicSettingsProvider& basicSettingsProvider::operator=(const basicSettingsProvider& rhs)
  69. //{
  70. // if (this == &rhs) {
  71. // return *this;
  72. // }
  73. //
  74. // // TODO: assignment
  75. //
  76. // return *this;
  77. //}
  78. #endif // __BASICSETTINGSPROVIDER_H_INCL__