aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-06-03 11:40:56 (GMT)
committerPaul Tagliamonte <paultag@fluxbox.org>2012-04-07 02:10:14 (GMT)
commit1cec88dfbb12f7a8702c5bb98ac3b0b2b383d58a (patch)
treeb1e4d38238ae9de7ed7db090fa42c5bacbd3c94a /src
parentcb84aa19c45aac2d527404dc4a0a683f6102ab9f (diff)
downloadfluxbox_paul-1cec88dfbb12f7a8702c5bb98ac3b0b2b383d58a.zip
fluxbox_paul-1cec88dfbb12f7a8702c5bb98ac3b0b2b383d58a.tar.bz2
convert ResourceManager::{add,remove}Resource from template to a regular function
Diffstat (limited to 'src')
-rw-r--r--src/FbTk/Resource.cc29
-rw-r--r--src/FbTk/Resource.hh36
2 files changed, 31 insertions, 34 deletions
diff --git a/src/FbTk/Resource.cc b/src/FbTk/Resource.cc
index 4be85de..85e78da 100644
--- a/src/FbTk/Resource.cc
+++ b/src/FbTk/Resource.cc
@@ -226,4 +226,33 @@ void ResourceManager::unlock() {
226 } 226 }
227} 227}
228 228
229// add the resource and load its value
230void ResourceManager::addResource(Resource_base &r) {
231 m_resourcelist.push_back(&r);
232 m_resourcelist.unique();
233
234 // lock ensures that the database is loaded.
235 lock();
236
237 if (m_database == 0) {
238 unlock();
239 return;
240 }
241
242 XrmValue value;
243 char *value_type;
244
245 // now, load the value for this resource
246 if (XrmGetResource(**m_database, r.name().c_str(),
247 r.altName().c_str(), &value_type, &value)) {
248 r.setFromString(value.addr);
249 } else {
250 std::cerr<<"Failed to read: "<<r.name()<<std::endl;
251 std::cerr<<"Setting default value"<<std::endl;
252 r.setDefaultValue();
253 }
254
255 unlock();
256}
257
229} // end namespace FbTk 258} // end namespace FbTk
diff --git a/src/FbTk/Resource.hh b/src/FbTk/Resource.hh
index 8c9d645..55afe60 100644
--- a/src/FbTk/Resource.hh
+++ b/src/FbTk/Resource.hh
@@ -96,12 +96,10 @@ 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 template <class T> 99 void addResource(Resource_base &r);
100 void addResource(Resource<T> &r);
101 100
102 /// Remove a specific resource, only used in Resource<T> 101 /// Remove a specific resource, only used in Resource<T>
103 template <class T> 102 void removeResource(Resource_base &r) {
104 void removeResource(Resource<T> &r) {
105 m_resourcelist.remove(&r); 103 m_resourcelist.remove(&r);
106 } 104 }
107 105
@@ -194,36 +192,6 @@ private:
194}; 192};
195 193
196 194
197// add the resource and load its value
198template <class T>
199void ResourceManager::addResource(Resource<T> &r) {
200 m_resourcelist.push_back(&r);
201 m_resourcelist.unique();
202
203 // lock ensures that the database is loaded.
204 lock();
205
206 if (m_database == 0) {
207 unlock();
208 return;
209 }
210
211 XrmValue value;
212 char *value_type;
213
214 // now, load the value for this resource
215 if (XrmGetResource(**m_database, r.name().c_str(),
216 r.altName().c_str(), &value_type, &value)) {
217 r.setFromString(value.addr);
218 } else {
219 std::cerr<<"Failed to read: "<<r.name()<<std::endl;
220 std::cerr<<"Setting default value"<<std::endl;
221 r.setDefaultValue();
222 }
223
224 unlock();
225}
226
227 195
228template <typename ResourceType> 196template <typename ResourceType>
229Resource<ResourceType> &ResourceManager::getResource(const std::string &resname) { 197Resource<ResourceType> &ResourceManager::getResource(const std::string &resname) {