aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Resource.cc
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-06-05 12:27:13 (GMT)
committerPavel Labath <pavelo@centrum.sk>2011-11-01 09:52:46 (GMT)
commitfc21fd822e527dbd918c6565e0e2cea82b0466f4 (patch)
treeb658bf437fafb80d39986c77caebcaf608761964 /src/FbTk/Resource.cc
parente3fabc4cd47ac5479bca421a4d7b79c0c2d9e120 (diff)
downloadfluxbox_pavel-fc21fd822e527dbd918c6565e0e2cea82b0466f4.zip
fluxbox_pavel-fc21fd822e527dbd918c6565e0e2cea82b0466f4.tar.bz2
A rough version of resource implementation in lua
I added a new class, LResourceManager, which should handle loading and saving of resources like the old ResourceManager, only it does that with the help of lua. I moved the common features of the two managers (interface + a few functions) to a common base class ResourceManager_base. I augmented the Resource_base class with two new functions (setFromLua and pushToLua) which are used by the lua RM instead of getString and setFromString. Parts of the new RM are written in lua. To avoid loading scripts from a file at runtime I decided to link compiled lua code straight into the executable. For this purpose I created a small script which converts a binary file into a declaration of a C array of bytes.
Diffstat (limited to 'src/FbTk/Resource.cc')
-rw-r--r--src/FbTk/Resource.cc33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/FbTk/Resource.cc b/src/FbTk/Resource.cc
index 85e78da..fad4bf3 100644
--- a/src/FbTk/Resource.cc
+++ b/src/FbTk/Resource.cc
@@ -37,6 +37,24 @@ using std::string;
37 37
38namespace FbTk { 38namespace FbTk {
39 39
40ResourceManager_base::~ResourceManager_base() {
41}
42
43string ResourceManager_base::resourceValue(const string &resname) const {
44 const Resource_base *res = findResource(resname);
45 if (res != 0)
46 return res->getString();
47
48 return "";
49}
50
51void ResourceManager_base::setResourceValue(const string &resname, const string &value) {
52 Resource_base *res = findResource(resname);
53 if (res != 0)
54 res->setFromString(value.c_str());
55
56}
57
40ResourceManager::ResourceManager(const char *filename, bool lock_db) : 58ResourceManager::ResourceManager(const char *filename, bool lock_db) :
41 m_db_lock(0), 59 m_db_lock(0),
42 m_database(0), 60 m_database(0),
@@ -186,21 +204,6 @@ const Resource_base *ResourceManager::findResource(const string &resname) const
186 return 0; 204 return 0;
187} 205}
188 206
189string ResourceManager::resourceValue(const string &resname) const {
190 const Resource_base *res = findResource(resname);
191 if (res != 0)
192 return res->getString();
193
194 return "";
195}
196
197void ResourceManager::setResourceValue(const string &resname, const string &value) {
198 Resource_base *res = findResource(resname);
199 if (res != 0)
200 res->setFromString(value.c_str());
201
202}
203
204ResourceManager &ResourceManager::lock() { 207ResourceManager &ResourceManager::lock() {
205 ++m_db_lock; 208 ++m_db_lock;
206 // if the lock was zero, then load the database 209 // if the lock was zero, then load the database