summaryrefslogtreecommitdiff
path: root/src/configuration.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/configuration.h')
-rw-r--r--src/configuration.h47
1 files changed, 29 insertions, 18 deletions
diff --git a/src/configuration.h b/src/configuration.h
index 908d13a4..a46b0718 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -23,6 +23,7 @@
#define CONFIGURATION_H
#include "utils/stringutils.h"
+#include "defaults.h"
#include <libxml/xmlwriter.h>
@@ -31,7 +32,6 @@
#include <map>
#include <string>
-class ConfigListener;
class ConfigurationObject;
/**
@@ -192,7 +192,7 @@ class ConfigurationObject
class Configuration : public ConfigurationObject
{
public:
- virtual ~Configuration() {}
+ ~Configuration();
/**
* Reads config file and parse all options into memory.
@@ -203,20 +203,16 @@ class Configuration : public ConfigurationObject
void init(const std::string &filename, bool useResManager = false);
/**
- * Writes the current settings back to the config file.
- */
- void write();
-
- /**
- * Adds a listener to the listen list of the specified config option.
+ * Set the default values for each keys.
+ *
+ * @param defaultsData data used as defaults.
*/
- void addListener(const std::string &key, ConfigListener *listener);
+ void setDefaultValues(DefaultsData *defaultsData);
/**
- * Removes a listener from the listen list of the specified config
- * option.
+ * Writes the current settings back to the config file.
*/
- void removeListener(const std::string &key, ConfigListener *listener);
+ void write();
void setValue(const std::string &key, const std::string &value);
@@ -238,14 +234,29 @@ class Configuration : public ConfigurationObject
inline void setValue(const std::string &key, bool value)
{ setValue(key, value ? "1" : "0"); }
+ /**
+ * returns a value corresponding to the given key.
+ * The default value returned in based on fallbacks registry.
+ * @see defaults.h
+ */
+ int getIntValue(const std::string &key) const;
+
+ float getFloatValue(const std::string &key) const;
+
+ std::string getStringValue(const std::string &key) const;
+
+ bool getBoolValue(const std::string &key) const;
+
+ Mana::VariableData* getDefault(const std::string &key,
+ Mana::VariableData::DataType type) const;
private:
- typedef std::list<ConfigListener*> Listeners;
- typedef Listeners::iterator ListenerIterator;
- typedef std::map<std::string, Listeners> ListenerMap;
- typedef ListenerMap::iterator ListenerMapIterator;
- ListenerMap mListenerMap;
+ /**
+ * Clean up the default values member.
+ */
+ void cleanDefaults();
- std::string mConfigPath; /**< Location of config file */
+ std::string mConfigPath; /**< Location of config file */
+ DefaultsData *mDefaultsData; /**< Defaults of value for a given key */
};
extern Configuration branding;