There is a need to have persistent options somewhere. For this is this object. Because of the plattform independency the options are stored in an INI file. This kind of format is supported by Qts settings object.
This is a functionality of smcore
and located in smcore/options.*
.
- Section names will be always in uppercase letters.
- Key names will be always in lowercase letters.
- For both the class will take care about.
- On creation of the object a load is performed to initialize the member variables.
namespace smos
{
namespace smcore
{
class Options
{
public:
/**
* @brief Default constructor
*
* @param optionsfile Name of options file
*/
Options(smos::smcore::SMSring optionsfile);
/**
* @brief Default destructor
*
*/
~Options(void);
/**
* @brief Get the editor call with filename templated
*
* @return smos::smcore::SMSring
*/
smos::smcore::SMSring codeEditorGet(void);
/**
* @brief Get the editor call with filename templated
*
* @param codeeditor smos::smcore::SMSring
*/
void codeEditorSet(smos::smcore::SMSring codeeditor);
/**
* @brief Get the absolute path to the logfile
*
* @return smos::smcore::SMSring The absolute path to the logfile
*/
smos::smcore::SMSring logfileNameGet(void);
/**
* @brief Set the name (and path) of the logfile
*
* @param logfileName Name (and path) of the logfile to use
*/
void logfileNameSet(smos::smcore::SMSring logfileName);
};
}
}
#include "settings.h"
smos::smcore::SMSettings settings = smos::smcore::SMSettings("smos_core.ini");
smos::smcore::SMSring logfileOld = settings.logfileNameGet();
settings.logfileNameSet("logfilenew.log");
This object could be a singleton. But the intention is to create an instance at the top most level and then inject it into the core.