From ffc8cb9443d4ec44cd05c0cb82a27c597ef53888 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Fri, 19 Dec 2003 17:08:25 +0000 Subject: setResourceValue function and a dump --- src/FbTk/Resource.cc | 15 ++++++++++++++- src/FbTk/Resource.hh | 12 ++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/FbTk/Resource.cc b/src/FbTk/Resource.cc index c21e55d..ad30b57 100644 --- a/src/FbTk/Resource.cc +++ b/src/FbTk/Resource.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Resource.cc,v 1.2 2003/07/18 15:40:55 rathnor Exp $ +// $Id: Resource.cc,v 1.3 2003/12/19 17:08:25 fluxgen Exp $ #include "XrmDatabaseHelper.hh" #include "Resource.hh" @@ -143,6 +143,19 @@ bool ResourceManager::save(const char *filename, const char *mergefilename) { return true; } +void ResourceManager::setResourceValue(const std::string &resname, const std::string &value) { + // find resource name + ResourceList::iterator i = m_resourcelist.begin(); + ResourceList::iterator i_end = m_resourcelist.end(); + for (; i != i_end; ++i) { + if ((*i)->name() == resname || + (*i)->altName() == resname) { + (*i)->setFromString(value.c_str()); + return; + } + } +} + void ResourceManager::ensureXrmIsInitialize() { if (!m_init) { XrmInitialize(); diff --git a/src/FbTk/Resource.hh b/src/FbTk/Resource.hh index 06d4b67..93cfc9e 100644 --- a/src/FbTk/Resource.hh +++ b/src/FbTk/Resource.hh @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Resource.hh,v 1.5 2003/12/16 17:06:52 fluxgen Exp $ +// $Id: Resource.hh,v 1.6 2003/12/19 17:08:25 fluxgen Exp $ #ifndef FBTK_RESOURCE_HH #define FBTK_RESOURCE_HH @@ -97,6 +97,8 @@ public: m_resourcelist.remove(&r); } + void setResourceValue(const std::string &resourcename, const std::string &value); + // this marks the database as "in use" and will avoid reloading // resources unless it is zero. // It returns this resource manager. Useful for passing to @@ -105,7 +107,13 @@ public: void unlock(); // for debugging inline int lockDepth() const { return m_db_lock; } - + void dump() { + ResourceList::iterator it = m_resourcelist.begin(); + ResourceList::iterator it_end = m_resourcelist.end(); + for (; it != it_end; ++it) { + std::cerr<<(*it)->name()<