#include <string>
-class GConfWrapper {
+#include <gconf/gconf-client.h>
+
+class GConfItem {
+public:
+ virtual ~GConfItem() {}
+
+protected:
+ GConfItem(); // I do not want to create instances of this class
+
+ static void allocateClient();
+
+protected:
+ // TODO: should I count the references and unref the client when the last user is gone??
+ static GConfClient *ourClient;
+};
+
+class GConfKey : public GConfItem {
+public:
+ GConfKey(const std::string&);
+ GConfKey(const GConfKey&, const std::string&);
+ ~GConfKey() { }
+
+ const std::string& path() const { return myKeyPath; }
+
+ static std::string mergePath(const std::string&, const std::string);
+
+private:
+ std::string myKeyPath;
+};
+
+class GConfOption : public GConfItem {
+protected:
+ GConfOption(const GConfKey& key, const std::string& path): myIsSynchronized(false), myPath(GConfKey::mergePath(key.path(), path)) { }
+
+ void setGConfValue(const GConfValue *);
+ GConfValue *getGConfValue(GConfValueType) const;
+ void unsetGConfValue();
+
+protected:
+ mutable bool myIsSynchronized;
+ std::string myPath;
+};
+
+class GConfStringValue : public GConfOption {
+public:
+ GConfStringValue(const GConfKey&, const std::string&, const std::string& = "");
+ ~GConfStringValue();
+
+ const std::string& value() const;
+ const std::string& setValue(const std::string& newValue);
+
+private:
+ mutable std::string myValue;
+ std::string myDefaultValue;
+};
+
+class GConfBooleanValue : public GConfOption {
+public:
+ GConfBooleanValue(const GConfKey&, const std::string&, bool = false);
+ ~GConfBooleanValue();
+
+ bool value() const;
+ bool setValue(bool newValue);
+
+private:
+ mutable bool myValue;
+ bool myDefaultValue;
+};
+
+class GConfIntegerValue : public GConfOption {
public:
- GConfWrapper(const std::string&);
- ~GConfWrapper();
+ GConfIntegerValue(const GConfKey&, const std::string&, int = false);
+ ~GConfIntegerValue();
- bool getBool(const std::string& name);
- void setBool(const std::string& name, bool);
+ int value() const;
+ int setValue(int newValue);
- int getInt(const std::string& name);
- void setInt(const std::string& name, int);
+private:
+ mutable int myValue;
+ int myDefaultValue;
};
#endif