aboutsummaryrefslogtreecommitdiff
path: root/src/Resource.hh
diff options
context:
space:
mode:
authorrathnor <rathnor>2002-12-01 13:42:15 (GMT)
committerrathnor <rathnor>2002-12-01 13:42:15 (GMT)
commit28b5c604490094e187494dcc566bd3d7a05a2c25 (patch)
tree8f78f5714a5cd055c10b067a2656fe7b2338e71a /src/Resource.hh
parentb9134162f9633784d9097df18769a699a62650fe (diff)
downloadfluxbox_pavel-28b5c604490094e187494dcc566bd3d7a05a2c25.zip
fluxbox_pavel-28b5c604490094e187494dcc566bd3d7a05a2c25.tar.bz2
Indenting from tabs to emacs 4-space
Diffstat (limited to 'src/Resource.hh')
-rw-r--r--src/Resource.hh120
1 files changed, 60 insertions, 60 deletions
diff --git a/src/Resource.hh b/src/Resource.hh
index f030d39..8a147c8 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.8 2002/11/26 16:37:18 fluxgen Exp $ 22// $Id: Resource.hh,v 1.9 2002/12/01 13:41:58 rathnor Exp $
23 23
24#ifndef RESOURCE_HH 24#ifndef RESOURCE_HH
25#define RESOURCE_HH 25#define RESOURCE_HH
@@ -33,27 +33,27 @@
33class Resource_base:private FbTk::NotCopyable 33class Resource_base:private FbTk::NotCopyable
34{ 34{
35public: 35public:
36 virtual ~Resource_base() { }; 36 virtual ~Resource_base() { };
37 37
38 /// set from string value 38 /// set from string value
39 virtual void setFromString(char const *strval) = 0; 39 virtual void setFromString(char const *strval) = 0;
40 /// set default value 40 /// set default value
41 virtual void setDefaultValue() = 0; 41 virtual void setDefaultValue() = 0;
42 /// get string value 42 /// get string value
43 virtual std::string getString() = 0; 43 virtual std::string getString() = 0;
44 /// get alternative name of this resource 44 /// get alternative name of this resource
45 inline const std::string& altName() const { return m_altname; } 45 inline const std::string& altName() const { return m_altname; }
46 /// get name of this resource 46 /// get name of this resource
47 inline const std::string& name() const { return m_name; } 47 inline const std::string& name() const { return m_name; }
48 48
49protected: 49protected:
50 Resource_base(const std::string &name, const std::string &altname): 50 Resource_base(const std::string &name, const std::string &altname):
51 m_name(name), m_altname(altname) 51 m_name(name), m_altname(altname)
52 { } 52 { }
53 53
54private: 54private:
55 std::string m_name; ///< name of this resource 55 std::string m_name; ///< name of this resource
56 std::string m_altname; ///< alternative name 56 std::string m_altname; ///< alternative name
57}; 57};
58 58
59class ResourceManager; 59class ResourceManager;
@@ -65,68 +65,68 @@ template <typename T>
65class Resource:public Resource_base 65class Resource:public Resource_base
66{ 66{
67public: 67public:
68 Resource(ResourceManager &rm, T val, 68 Resource(ResourceManager &rm, T val,
69 const std::string &name, const std::string &altname): 69 const std::string &name, const std::string &altname):
70 Resource_base(name, altname), 70 Resource_base(name, altname),
71 m_value(val), m_defaultval(val), 71 m_value(val), m_defaultval(val),
72 m_rm(rm) 72 m_rm(rm)
73 { 73 {
74 m_rm.addResource(*this); // add this to resource handler 74 m_rm.addResource(*this); // add this to resource handler
75 }
76 virtual ~Resource() {
77 m_rm.removeResource(*this); // remove this from resource handler
78 } 75 }
76 virtual ~Resource() {
77 m_rm.removeResource(*this); // remove this from resource handler
78 }
79 79
80 inline void setDefaultValue() { m_value = m_defaultval; } 80 inline void setDefaultValue() { m_value = m_defaultval; }
81 void setFromString(const char *strval); 81 void setFromString(const char *strval);
82 inline Resource<T>& operator = (const T& newvalue) { m_value = newvalue; return *this;} 82 inline Resource<T>& operator = (const T& newvalue) { m_value = newvalue; return *this;}
83 83
84 std::string getString(); 84 std::string getString();
85 inline T& operator*() { return m_value; } 85 inline T& operator*() { return m_value; }
86 inline const T& operator*() const { return m_value; } 86 inline const T& operator*() const { return m_value; }
87 inline T *operator->() { return &m_value; } 87 inline T *operator->() { return &m_value; }
88 inline const T *operator->() const { return &m_value; } 88 inline const T *operator->() const { return &m_value; }
89private: 89private:
90 T m_value, m_defaultval; 90 T m_value, m_defaultval;
91 ResourceManager &m_rm; 91 ResourceManager &m_rm;
92}; 92};
93 93
94class ResourceManager 94class ResourceManager
95{ 95{
96public: 96public:
97 typedef std::list<Resource_base *> ResourceList; 97 typedef std::list<Resource_base *> ResourceList;
98 98
99 ResourceManager() { } 99 ResourceManager() { }
100 virtual ~ResourceManager() {} 100 virtual ~ResourceManager() {}
101 /** 101 /**
102 load all resouces registered to this class 102 load all resouces registered to this class
103 */ 103 */
104 virtual bool load(const char *filename); 104 virtual bool load(const char *filename);
105 /** 105 /**
106 save all resouces registered to this class 106 save all resouces registered to this class
107 */ 107 */
108 virtual bool save(const char *filename, const char *mergefilename=0); 108 virtual bool save(const char *filename, const char *mergefilename=0);
109 /** 109 /**
110 add resource to list 110 add resource to list
111 */ 111 */
112 template <class T> 112 template <class T>
113 void addResource(Resource<T> &r) { 113 void addResource(Resource<T> &r) {
114 m_resourcelist.push_back(&r); 114 m_resourcelist.push_back(&r);
115 m_resourcelist.unique(); 115 m_resourcelist.unique();
116 } 116 }
117 /** 117 /**
118 Remove a specific resource 118 Remove a specific resource
119 */ 119 */
120 template <class T> 120 template <class T>
121 void removeResource(Resource<T> &r) { 121 void removeResource(Resource<T> &r) {
122 m_resourcelist.remove(&r); 122 m_resourcelist.remove(&r);
123 } 123 }
124protected: 124protected:
125 static inline void ensureXrmIsInitialize(); 125 static inline void ensureXrmIsInitialize();
126private: 126private:
127 127
128 static bool m_init; 128 static bool m_init;
129 ResourceList m_resourcelist; 129 ResourceList m_resourcelist;
130}; 130};
131 131
132#endif //_RESOURCE_HH_ 132#endif //_RESOURCE_HH_