aboutsummaryrefslogtreecommitdiff
path: root/src/Resource.hh
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-07-20 09:51:26 (GMT)
committerfluxgen <fluxgen>2002-07-20 09:51:26 (GMT)
commita18a6b0994292668db09b4c7af0c4e1199b308f8 (patch)
tree778e993c5d8109fb602b46312ca462ab19623aab /src/Resource.hh
parentcd7b6d1fd5b1ac1614b1431126f266d8651c890c (diff)
downloadfluxbox-a18a6b0994292668db09b4c7af0c4e1199b308f8.zip
fluxbox-a18a6b0994292668db09b4c7af0c4e1199b308f8.tar.bz2
comments and other minor stuff
Diffstat (limited to 'src/Resource.hh')
-rw-r--r--src/Resource.hh49
1 files changed, 31 insertions, 18 deletions
diff --git a/src/Resource.hh b/src/Resource.hh
index 10a77f7..8055701 100644
--- a/src/Resource.hh
+++ b/src/Resource.hh
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22// $Id: Resource.hh,v 1.5 2002/05/17 10:59:58 fluxgen Exp $ 22// $Id: Resource.hh,v 1.6 2002/07/20 09:51:03 fluxgen Exp $
23 23
24#ifndef RESOURCE_HH 24#ifndef RESOURCE_HH
25#define RESOURCE_HH 25#define RESOURCE_HH
@@ -31,23 +31,29 @@
31class Resource_base:private NotCopyable 31class Resource_base:private NotCopyable
32{ 32{
33public: 33public:
34 34 virtual ~Resource_base() { };
35 virtual void setFromString(char const *strval)=0;
36 virtual void setDefaultValue()=0;
37
38 virtual std::string getString()=0;
39 inline const std::string& getAltName() const { return m_altname; }
40 inline const std::string& getName() const { return m_name; }
41 35
36 /// set from string value
37 virtual void setFromString(char const *strval) = 0;
38 /// set default value
39 virtual void setDefaultValue() = 0;
40 /// get string value
41 virtual std::string getString() = 0;
42 /// get alternative name of this resource
43 inline const std::string& altName() const { return m_altname; }
44 /// get name of this resource
45 inline const std::string& name() const { return m_name; }
46
42protected: 47protected:
43 Resource_base(const std::string &name, const std::string &altname): 48 Resource_base(const std::string &name, const std::string &altname):
44 m_name(name), m_altname(altname) 49 m_name(name), m_altname(altname)
45 { 50 {
46 51
47 } 52 }
48 virtual ~Resource_base(){ }; 53
49private: 54private:
50 std::string m_name, m_altname; 55 std::string m_name; // name of this resource
56 std::string m_altname; // alternative name
51}; 57};
52 58
53class ResourceManager; 59class ResourceManager;
@@ -62,10 +68,10 @@ public:
62 m_value(val), m_defaultval(val), 68 m_value(val), m_defaultval(val),
63 m_rm(rm) 69 m_rm(rm)
64 { 70 {
65 m_rm.addResource(*this); 71 m_rm.addResource(*this); // add this to resource handler
66 } 72 }
67 ~Resource() { 73 virtual ~Resource() {
68 m_rm.removeResource(*this); 74 m_rm.removeResource(*this); // remove this from resource handler
69 } 75 }
70 76
71 inline void setDefaultValue() { m_value = m_defaultval; } 77 inline void setDefaultValue() { m_value = m_defaultval; }
@@ -87,10 +93,16 @@ class ResourceManager
87public: 93public:
88 typedef std::list<Resource_base *> ResourceList; 94 typedef std::list<Resource_base *> ResourceList;
89 95
90 ResourceManager(){ } 96 ResourceManager() { }
91 97 virtual ~ResourceManager() {}
92 bool load(const char *filename); 98 /**
93 bool save(const char *filename, const char *mergefilename=0); 99 load all resouces registered to this class
100 */
101 virtual bool load(const char *filename);
102 /**
103 save all resouces registered to this class
104 */
105 virtual bool save(const char *filename, const char *mergefilename=0);
94 template <class T> 106 template <class T>
95 void addResource(Resource<T> &r) { 107 void addResource(Resource<T> &r) {
96 m_resourcelist.push_back(&r); 108 m_resourcelist.push_back(&r);
@@ -100,8 +112,9 @@ public:
100 void removeResource(Resource<T> &r) { 112 void removeResource(Resource<T> &r) {
101 m_resourcelist.remove(&r); 113 m_resourcelist.remove(&r);
102 } 114 }
103private: 115protected:
104 static inline void ensureXrmIsInitialize(); 116 static inline void ensureXrmIsInitialize();
117private:
105 static bool m_init; 118 static bool m_init;
106 ResourceList m_resourcelist; 119 ResourceList m_resourcelist;
107 120