A singleton for managing application settings applied to a single user. More...
#include <UserApplicationSettings.h>
Public Types | |
typedef ObjectLevelLockingPolicy< ::boost::lock_guard< ::boost::recursive_mutex > > | LockRead |
typedef ObjectLevelLockingPolicy< ::boost::lock_guard< ::boost::recursive_mutex > > | LockWrite |
typedef volatile ApplicationSettings | VolatileType |
Public Member Functions | |
void | changed () |
This method can be used by clients to inform manually that the internal state has changed. More... | |
const boost::property_tree::ptree & | getAllSettings () const |
It return a reading reference to the internal settings. More... | |
boost::property_tree::ptree & | getAllSettings () |
It return a reference to the internal settings. More... | |
std::string | getValue (const std::string &key) |
It returns the value for a given key or empty. More... | |
void | load (const std::string &fileName) |
It tries to find a default config file based on system macros and default condigurations. More... | |
void | setValue (const std::string &key, const std::string &value) |
It stores the value according to the key. More... | |
void | update () |
It updates the application settings. More... | |
Static Public Member Functions | |
static UserApplicationSettings & | getInstance () |
It returns a reference to the singleton instance. More... | |
Protected Member Functions | |
UserApplicationSettings () | |
It initializes the singleton. More... | |
~UserApplicationSettings () | |
Destructor. More... | |
Protected Attributes | |
bool | m_dirty |
A dirty bit to indicate wheter the clients have made changes in the settings since the last update. More... | |
std::string | m_file |
The settings file name. More... | |
boost::property_tree::ptree | m_settings |
This will keep our settings in memory. More... | |
Friends | |
class | te::common::Singleton< UserApplicationSettings > |
A singleton for managing application settings applied to a single user.
This singleton can be used to keep user preferences that customize the application's appearance and behavior for a given user.
It will look for an user configuration file as follows:
Definition at line 56 of file UserApplicationSettings.h.
|
inherited |
Definition at line 205 of file ThreadingPolicies.h.
|
inherited |
Definition at line 206 of file ThreadingPolicies.h.
|
inherited |
Definition at line 204 of file ThreadingPolicies.h.
|
protected |
It initializes the singleton.
|
protected |
Destructor.
|
inlineinherited |
This method can be used by clients to inform manually that the internal state has changed.
This method is useful when accessing the internal settings structure.
Definition at line 237 of file ApplicationSettings.h.
References te::common::ApplicationSettings::m_dirty.
|
inlineinherited |
It return a reading reference to the internal settings.
Definition at line 244 of file ApplicationSettings.h.
References te::common::ApplicationSettings::m_settings.
|
inlineinherited |
It return a reference to the internal settings.
Definition at line 249 of file ApplicationSettings.h.
References te::common::ApplicationSettings::m_settings.
|
staticinherited |
It returns a reference to the singleton instance.
|
inlineinherited |
It returns the value for a given key or empty.
key | The key used to identify the searched value. |
Definition at line 189 of file ApplicationSettings.h.
References te::common::ApplicationSettings::m_settings.
void te::common::UserApplicationSettings::load | ( | const std::string & | fileName | ) |
It tries to find a default config file based on system macros and default condigurations.
It loads the setting from the given file.
fileName | It must be the full path to the settings file. |
|
inlineinherited |
It stores the value according to the key.
key | The key used to identify the given value. The key must follow the same rules as XML elements and they can be subclassified using a dot notation: setValue(key.subkey.subsubkey, value). |
value | The value to be stored, any valid string. |
Definition at line 181 of file ApplicationSettings.h.
References te::common::ApplicationSettings::m_dirty, and te::common::ApplicationSettings::m_settings.
|
inlineinherited |
It updates the application settings.
Definition at line 215 of file ApplicationSettings.h.
References te::common::ApplicationSettings::m_dirty, te::common::ApplicationSettings::m_file, and te::common::ApplicationSettings::m_settings.
Referenced by te::common::ApplicationSettings::~ApplicationSettings().
|
friend |
Definition at line 60 of file UserApplicationSettings.h.
|
protectedinherited |
A dirty bit to indicate wheter the clients have made changes in the settings since the last update.
Definition at line 167 of file ApplicationSettings.h.
Referenced by te::common::ApplicationSettings::changed(), te::common::ApplicationSettings::load(), te::common::ApplicationSettings::setValue(), and te::common::ApplicationSettings::update().
|
protectedinherited |
The settings file name.
Definition at line 166 of file ApplicationSettings.h.
Referenced by te::common::ApplicationSettings::load(), and te::common::ApplicationSettings::update().
|
protectedinherited |
This will keep our settings in memory.
Definition at line 165 of file ApplicationSettings.h.
Referenced by te::common::ApplicationSettings::getAllSettings(), te::common::ApplicationSettings::getValue(), te::common::ApplicationSettings::load(), te::common::ApplicationSettings::setValue(), and te::common::ApplicationSettings::update().