aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Resource.cc
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-06-12 12:18:58 (GMT)
committerPavel Labath <pavelo@centrum.sk>2011-11-01 09:54:48 (GMT)
commit7817fd254e9bd1529fa6e98cdba249b7c0b8a6f8 (patch)
tree5842eefc426161b8b88a817c4a7fe900e116a4a4 /src/FbTk/Resource.cc
parent2a6803c7343bbe7ab1da9219fe56a03172b98bf9 (diff)
downloadfluxbox_pavel-7817fd254e9bd1529fa6e98cdba249b7c0b8a6f8.zip
fluxbox_pavel-7817fd254e9bd1529fa6e98cdba249b7c0b8a6f8.tar.bz2
Move more common stuff of (L)ResourceManagers to their base class
Diffstat (limited to 'src/FbTk/Resource.cc')
-rw-r--r--src/FbTk/Resource.cc56
1 files changed, 29 insertions, 27 deletions
diff --git a/src/FbTk/Resource.cc b/src/FbTk/Resource.cc
index fad4bf3..fb0f595 100644
--- a/src/FbTk/Resource.cc
+++ b/src/FbTk/Resource.cc
@@ -37,7 +37,34 @@ using std::string;
37 37
38namespace FbTk { 38namespace FbTk {
39 39
40ResourceManager_base::~ResourceManager_base() { 40
41void ResourceManager_base::addResource(Resource_base &r) {
42 m_resourcelist.push_back(&r);
43 m_resourcelist.unique();
44}
45
46Resource_base *ResourceManager_base::findResource(const string &resname) {
47 // find resource name
48 ResourceList::iterator i = m_resourcelist.begin();
49 ResourceList::iterator i_end = m_resourcelist.end();
50 for (; i != i_end; ++i) {
51 if ((*i)->name() == resname ||
52 (*i)->altName() == resname)
53 return *i;
54 }
55 return 0;
56}
57
58const Resource_base *ResourceManager_base::findResource(const string &resname) const {
59 // find resource name
60 ResourceList::const_iterator i = m_resourcelist.begin();
61 ResourceList::const_iterator i_end = m_resourcelist.end();
62 for (; i != i_end; ++i) {
63 if ((*i)->name() == resname ||
64 (*i)->altName() == resname)
65 return *i;
66 }
67 return 0;
41} 68}
42 69
43string ResourceManager_base::resourceValue(const string &resname) const { 70string ResourceManager_base::resourceValue(const string &resname) const {
@@ -180,30 +207,6 @@ bool ResourceManager::save(const char *filename, const char *mergefilename) {
180 return true; 207 return true;
181} 208}
182 209
183Resource_base *ResourceManager::findResource(const string &resname) {
184 // find resource name
185 ResourceList::iterator i = m_resourcelist.begin();
186 ResourceList::iterator i_end = m_resourcelist.end();
187 for (; i != i_end; ++i) {
188 if ((*i)->name() == resname ||
189 (*i)->altName() == resname)
190 return *i;
191 }
192 return 0;
193}
194
195const Resource_base *ResourceManager::findResource(const string &resname) const {
196 // find resource name
197 ResourceList::const_iterator i = m_resourcelist.begin();
198 ResourceList::const_iterator i_end = m_resourcelist.end();
199 for (; i != i_end; ++i) {
200 if ((*i)->name() == resname ||
201 (*i)->altName() == resname)
202 return *i;
203 }
204 return 0;
205}
206
207ResourceManager &ResourceManager::lock() { 210ResourceManager &ResourceManager::lock() {
208 ++m_db_lock; 211 ++m_db_lock;
209 // if the lock was zero, then load the database 212 // if the lock was zero, then load the database
@@ -231,8 +234,7 @@ void ResourceManager::unlock() {
231 234
232// add the resource and load its value 235// add the resource and load its value
233void ResourceManager::addResource(Resource_base &r) { 236void ResourceManager::addResource(Resource_base &r) {
234 m_resourcelist.push_back(&r); 237 ResourceManager_base::addResource(r);
235 m_resourcelist.unique();
236 238
237 // lock ensures that the database is loaded. 239 // lock ensures that the database is loaded.
238 lock(); 240 lock();