made code simpler

This commit is contained in:
Mathias Gumz 2009-10-01 07:07:07 +02:00
parent 69de5b5a00
commit 38ef6e5155
2 changed files with 7 additions and 16 deletions

View file

@ -42,7 +42,11 @@ ResourceManager::ResourceManager(const char *filename, bool lock_db) :
m_database(0), m_database(0),
m_filename(filename ? filename : "") m_filename(filename ? filename : "")
{ {
ensureXrmIsInitialize(); static bool xrm_initialized = false;
if (!xrm_initialized) {
XrmInitialize();
xrm_initialized = true;
}
if (lock_db) if (lock_db)
lock(); lock();
@ -53,7 +57,6 @@ ResourceManager::~ResourceManager() {
delete m_database; delete m_database;
} }
bool ResourceManager::m_init = false;
/** /**
reloads all resources from resourcefile 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() { ResourceManager &ResourceManager::lock() {
++m_db_lock; ++m_db_lock;
// if the lock was zero, then load the database // if the lock was zero, then load the database

View file

@ -139,12 +139,10 @@ public:
} }
} }
protected: protected:
static void ensureXrmIsInitialize();
int m_db_lock; int m_db_lock;
private: private:
static bool m_init;
ResourceList m_resourcelist; ResourceList m_resourcelist;
@ -168,11 +166,8 @@ template <typename T>
class Resource:public Resource_base, public Accessor<T> { class Resource:public Resource_base, public Accessor<T> {
public: public:
typedef T Type; typedef T Type;
Resource(ResourceManager &rm, T val, Resource(ResourceManager &rm, T val, const std::string &name, const std::string &altname):
const std::string &name, const std::string &altname): Resource_base(name, altname), m_value(val), m_defaultval(val), m_rm(rm) {
Resource_base(name, altname),
m_value(val), m_defaultval(val),
m_rm(rm) {
m_rm.addResource(*this); // add this to resource handler m_rm.addResource(*this); // add this to resource handler
} }
virtual ~Resource() { virtual ~Resource() {