From 38ef6e515589af7841c577188eb23c5dbe5d11f3 Mon Sep 17 00:00:00 2001 From: Mathias Gumz Date: Thu, 1 Oct 2009 07:07:07 +0200 Subject: made code simpler --- src/FbTk/Resource.cc | 14 +++++--------- src/FbTk/Resource.hh | 9 ++------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/FbTk/Resource.cc b/src/FbTk/Resource.cc index 94b31b2..4be85de 100644 --- a/src/FbTk/Resource.cc +++ b/src/FbTk/Resource.cc @@ -42,7 +42,11 @@ ResourceManager::ResourceManager(const char *filename, bool lock_db) : m_database(0), m_filename(filename ? filename : "") { - ensureXrmIsInitialize(); + static bool xrm_initialized = false; + if (!xrm_initialized) { + XrmInitialize(); + xrm_initialized = true; + } if (lock_db) lock(); @@ -53,7 +57,6 @@ ResourceManager::~ResourceManager() { delete m_database; } -bool ResourceManager::m_init = false; /** reloads all resources from resourcefile @@ -198,13 +201,6 @@ void ResourceManager::setResourceValue(const string &resname, const string &valu } -void ResourceManager::ensureXrmIsInitialize() { - if (!m_init) { - XrmInitialize(); - m_init = true; - } -} - ResourceManager &ResourceManager::lock() { ++m_db_lock; // if the lock was zero, then load the database diff --git a/src/FbTk/Resource.hh b/src/FbTk/Resource.hh index bfdcdca..8c9d645 100644 --- a/src/FbTk/Resource.hh +++ b/src/FbTk/Resource.hh @@ -139,12 +139,10 @@ public: } } protected: - static void ensureXrmIsInitialize(); int m_db_lock; private: - static bool m_init; ResourceList m_resourcelist; @@ -168,11 +166,8 @@ template class Resource:public Resource_base, public Accessor { public: typedef T Type; - Resource(ResourceManager &rm, T val, - const std::string &name, const std::string &altname): - Resource_base(name, altname), - m_value(val), m_defaultval(val), - m_rm(rm) { + Resource(ResourceManager &rm, T val, const std::string &name, const std::string &altname): + Resource_base(name, altname), m_value(val), m_defaultval(val), m_rm(rm) { m_rm.addResource(*this); // add this to resource handler } virtual ~Resource() { -- cgit v0.11.2