26 #ifndef __TERRALIB_COMMON_INTERNAL_APPLICATIONSETTINGS_H
27 #define __TERRALIB_COMMON_INTERNAL_APPLICATIONSETTINGS_H
37 #include <boost/property_tree/ptree.hpp>
38 #include <boost/property_tree/xml_parser.hpp>
39 #include <boost/filesystem.hpp>
40 #include <boost/noncopyable.hpp>
68 ::boost::recursive_mutex,
69 ::boost::lock_guard< ::boost::recursive_mutex>,
70 ::boost::lock_guard< ::boost::recursive_mutex> >,
71 public ::boost::noncopyable
93 void setValue(
const std::string& key,
const std::string& value);
104 std::string
getValue(
const std::string& key);
119 void load(
const std::string& settingsFile);
211 if(boost::filesystem::is_regular_file(
m_file))
212 boost::property_tree::read_xml(
m_file,
m_settings, boost::property_tree::xml_parser::trim_whitespace);
223 boost::filesystem::remove(
m_file);
226 #if BOOST_VERSION > 105600
227 boost::property_tree::xml_writer_settings<std::string> settings(
'\t', 1);
229 boost::property_tree::xml_writer_settings<char> settings(
'\t', 1);
231 boost::property_tree::write_xml(
m_file,
m_settings, std::locale(), settings);
257 #endif // __TERRALIB_COMMON_INTERNAL_APPLICATIONSETTINGS_H
bool m_dirty
A dirty bit to indicate wheter the clients have made changes in the settings since the last update...
void load(const std::string &settingsFile)
It initializes the application settings.
Configuration flags for the TerraLib Common Runtime module.
void changed()
This method can be used by clients to inform manually that the internal state has changed...
void setValue(const std::string &key, const std::string &value)
It stores the value according to the key.
std::string m_file
The settings file name.
ApplicationSettings()
Constructor.
Threading policies that can be applied to TerraLib classes that need some synchronization schema...
ObjectLevelLockingPolicy< ::boost::lock_guard< ::boost::recursive_mutex > > LockWrite
~ApplicationSettings()
The destructor will automatically save the settings to a file if one is set.
const boost::property_tree::ptree & getAllSettings() const
It return a reading reference to the internal settings.
std::string getValue(const std::string &key)
It returns the value for a given key or empty.
This policy assures an object-level locking scheme for a derived class.
ObjectLevelLockingPolicy< ::boost::lock_guard< ::boost::recursive_mutex > > LockRead
boost::property_tree::ptree m_settings
This will keep our settings in memory.
void update()
It updates the application settings.
A class for managing application settings.