made code simpler
This commit is contained in:
parent
69de5b5a00
commit
38ef6e5155
2 changed files with 7 additions and 16 deletions
|
@ -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
|
||||
|
|
|
@ -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 <typename T>
|
|||
class Resource:public Resource_base, public Accessor<T> {
|
||||
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() {
|
||||
|
|
Loading…
Reference in a new issue