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-06-15 23:07:49 (GMT)
commitde1e05cec6b26f6a7f398a9ea64f38fa0943f9c0 (patch)
tree6c5cb813d5cf4bad3c620fb42a2fb4236b9f9ec1 /src/FbTk/Resource.cc
parentf7981d4a85985b4862af0036b7728f8543706374 (diff)
downloadfluxbox_pavel-de1e05cec6b26f6a7f398a9ea64f38fa0943f9c0.zip
fluxbox_pavel-de1e05cec6b26f6a7f398a9ea64f38fa0943f9c0.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