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
103 lines
2.3 KiB
#ifndef __BASICSETTINGSPROVIDER_H_INCL__
|
|
#define __BASICSETTINGSPROVIDER_H_INCL__
|
|
|
|
#include "basicLogCollection.h"
|
|
|
|
#include <libconfig.h>
|
|
// #pragma message("Debug: Test point riched 1!")
|
|
#include "basicFunctionality.h"
|
|
|
|
#define DEFAULT_SETTINGS_FILE_NAME "default.conf"
|
|
|
|
/**
|
|
* TODO: Add class description
|
|
*
|
|
* @author Gagua
|
|
*/
|
|
|
|
class basicSettingsProvider
|
|
{
|
|
public:
|
|
|
|
// Method to fetch singleton instance.
|
|
static basicSettingsProvider * getInstance(CSTR configName = NULL);
|
|
|
|
// Destructor
|
|
virtual ~basicSettingsProvider();
|
|
|
|
bool reload(void);
|
|
bool validate(void);
|
|
bool saveTo(CSTR fileName);
|
|
|
|
bool isCompromised(void)
|
|
{
|
|
return m_bModified;
|
|
}
|
|
|
|
void compromise(void)
|
|
{
|
|
m_bModified = true;
|
|
}
|
|
|
|
config_setting_t * getSubNode(config_setting_t * Parent, CSTR NodeName);
|
|
|
|
protected:
|
|
|
|
// Constructor - protected so users cannot call it.
|
|
explicit basicSettingsProvider(CSTR configName = NULL);
|
|
|
|
private:
|
|
|
|
config_t m_sCfg;
|
|
config_setting_t * m_pRootNode;
|
|
basicLogCollection * m_pLog;
|
|
|
|
char m_pFileName[MAX_PATH];
|
|
|
|
bool m_bLoadded;
|
|
bool m_bModified;
|
|
|
|
bool load(void);
|
|
bool save(void);
|
|
bool clear(void);
|
|
|
|
config_setting_t * getRoot(void)
|
|
{
|
|
return (m_bLoadded ? m_pRootNode : NULL);
|
|
}
|
|
|
|
// private static member referencing the single instance of the object
|
|
// TODO: Replace basicSettingsProvider with the type of object you want to
|
|
// return the single instance of
|
|
static basicSettingsProvider * _instance;
|
|
|
|
// Copy constructor
|
|
// Declared but not defined to prevent auto-generated
|
|
// copy constructor. Refer to "Effective C++" by Meyers
|
|
basicSettingsProvider(const basicSettingsProvider & src);
|
|
|
|
// Assignment operator
|
|
// Declared but not defined to prevent auto-generated
|
|
// assignment operator. Refer to "Effective C++" by Meyers
|
|
basicSettingsProvider & operator=(const basicSettingsProvider & src);
|
|
};
|
|
|
|
// TODO: Uncomment the copy constructor when you need it.
|
|
// inline basicSettingsProvider::basicSettingsProvider(const basicSettingsProvider& src)
|
|
//{
|
|
// // TODO: copy
|
|
//}
|
|
|
|
// TODO: Uncomment the assignment operator when you need it.
|
|
// inline basicSettingsProvider& basicSettingsProvider::operator=(const basicSettingsProvider& rhs)
|
|
//{
|
|
// if (this == &rhs) {
|
|
// return *this;
|
|
// }
|
|
//
|
|
// // TODO: assignment
|
|
//
|
|
// return *this;
|
|
//}
|
|
|
|
#endif // __BASICSETTINGSPROVIDER_H_INCL__
|