From c613a57c64b43e02fbbfc16a15e7d4604466f1e6 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Fri, 19 Dec 2003 18:25:39 +0000 Subject: resourceValue and findResource --- src/FbTk/Resource.cc | 28 +++++++++++++++++++++------- src/FbTk/Resource.hh | 4 +++- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/FbTk/Resource.cc b/src/FbTk/Resource.cc index ad30b57..4c56dbb 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.3 2003/12/19 17:08:25 fluxgen Exp $ +// $Id: Resource.cc,v 1.4 2003/12/19 18:25:39 fluxgen Exp $ #include "XrmDatabaseHelper.hh" #include "Resource.hh" @@ -143,17 +143,31 @@ 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 +Resource_base *ResourceManager::findResource(const std::string &resname) { + // 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; - } + (*i)->altName() == resname) + return *i; } + return 0; +} + +string ResourceManager::resourceValue(const std::string &resname) { + Resource_base *res = findResource(resname); + if (res != 0) + return res->getString(); + + return ""; +} + +void ResourceManager::setResourceValue(const std::string &resname, const std::string &value) { + Resource_base *res = findResource(resname); + if (res != 0) + res->setFromString(value.c_str()); + } void ResourceManager::ensureXrmIsInitialize() { diff --git a/src/FbTk/Resource.hh b/src/FbTk/Resource.hh index 93cfc9e..6fddbac 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.6 2003/12/19 17:08:25 fluxgen Exp $ +// $Id: Resource.hh,v 1.7 2003/12/19 18:25:39 fluxgen Exp $ #ifndef FBTK_RESOURCE_HH #define FBTK_RESOURCE_HH @@ -97,6 +97,8 @@ public: m_resourcelist.remove(&r); } + Resource_base *findResource(const std::string &resourcename); + std::string resourceValue(const std::string &resourcename); void setResourceValue(const std::string &resourcename, const std::string &value); // this marks the database as "in use" and will avoid reloading -- cgit v0.11.2