aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Resource.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/Resource.hh')
-rw-r--r--src/FbTk/Resource.hh32
1 files changed, 10 insertions, 22 deletions
diff --git a/src/FbTk/Resource.hh b/src/FbTk/Resource.hh
index fb05426..33a6bb2 100644
--- a/src/FbTk/Resource.hh
+++ b/src/FbTk/Resource.hh
@@ -87,7 +87,7 @@ class ResourceManager_base
87public: 87public:
88 typedef std::list<Resource_base *> ResourceList; 88 typedef std::list<Resource_base *> ResourceList;
89 89
90 virtual ~ResourceManager_base(); 90 virtual ~ResourceManager_base() {}
91 91
92 /// Save all resouces registered to this class 92 /// Save all resouces registered to this class
93 /// @return true on success 93 /// @return true on success
@@ -96,17 +96,19 @@ public:
96 96
97 97
98 /// Add resource to list, only used in Resource<T> 98 /// Add resource to list, only used in Resource<T>
99 virtual void addResource(Resource_base &r) = 0; 99 virtual void addResource(Resource_base &r);
100 100
101 /// Remove a specific resource, only used in Resource<T> 101 /// Remove a specific resource, only used in Resource<T>
102 virtual void removeResource(Resource_base &r) = 0; 102 virtual void removeResource(Resource_base &r) {
103 m_resourcelist.remove(&r);
104 }
103 105
104 /// searches for the resource with the resourcename 106 /// searches for the resource with the resourcename
105 /// @return pointer to resource base on success, else 0. 107 /// @return pointer to resource base on success, else 0.
106 virtual Resource_base *findResource(const std::string &resourcename) = 0; 108 Resource_base *findResource(const std::string &resourcename);
107 /// searches for the resource with the resourcename 109 /// searches for the resource with the resourcename
108 /// @return pointer to resource base on success, else 0. 110 /// @return pointer to resource base on success, else 0.
109 virtual const Resource_base *findResource(const std::string &resourcename) const = 0; 111 const Resource_base *findResource(const std::string &resourcename) const;
110 112
111 std::string resourceValue(const std::string &resourcename) const; 113 std::string resourceValue(const std::string &resourcename) const;
112 void setResourceValue(const std::string &resourcename, const std::string &value); 114 void setResourceValue(const std::string &resourcename, const std::string &value);
@@ -118,13 +120,14 @@ public:
118 */ 120 */
119 template <typename ResourceType, typename Traits> 121 template <typename ResourceType, typename Traits>
120 Resource<ResourceType, Traits> &getResource(const std::string &resource); 122 Resource<ResourceType, Traits> &getResource(const std::string &resource);
123
124protected:
125 ResourceList m_resourcelist;
121}; 126};
122 127
123class ResourceManager: public ResourceManager_base 128class ResourceManager: public ResourceManager_base
124{ 129{
125public: 130public:
126 typedef std::list<Resource_base *> ResourceList;
127
128 // lock specifies if the database should be opened with one level locked 131 // lock specifies if the database should be opened with one level locked
129 // (useful for constructing inside initial set of constructors) 132 // (useful for constructing inside initial set of constructors)
130 ResourceManager(const char *filename, bool lock_db); 133 ResourceManager(const char *filename, bool lock_db);
@@ -139,22 +142,9 @@ public:
139 virtual bool save(const char *filename, const char *mergefilename=0); 142 virtual bool save(const char *filename, const char *mergefilename=0);
140 143
141 144
142
143 /// Add resource to list, only used in Resource<T> 145 /// Add resource to list, only used in Resource<T>
144 virtual void addResource(Resource_base &r); 146 virtual void addResource(Resource_base &r);
145 147
146 /// Remove a specific resource, only used in Resource<T>
147 virtual void removeResource(Resource_base &r) {
148 m_resourcelist.remove(&r);
149 }
150
151 /// searches for the resource with the resourcename
152 /// @return pointer to resource base on success, else 0.
153 virtual Resource_base *findResource(const std::string &resourcename);
154 /// searches for the resource with the resourcename
155 /// @return pointer to resource base on success, else 0.
156 virtual const Resource_base *findResource(const std::string &resourcename) const;
157
158 // this marks the database as "in use" and will avoid reloading 148 // this marks the database as "in use" and will avoid reloading
159 // resources unless it is zero. 149 // resources unless it is zero.
160 // It returns this resource manager. Useful for passing to 150 // It returns this resource manager. Useful for passing to
@@ -176,8 +166,6 @@ protected:
176 166
177private: 167private:
178 168
179 ResourceList m_resourcelist;
180
181 XrmDatabaseHelper *m_database; 169 XrmDatabaseHelper *m_database;
182 170
183 std::string m_filename; 171 std::string m_filename;