diff options
author | Adam <Adam@anope.org> | 2012-12-25 15:52:58 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2012-12-25 15:52:58 -0500 |
commit | 392b591d09509ae788f59b1b63a947ed7d8ad562 (patch) | |
tree | fb34d59492895d676e07c47b364829ec9eeb1a14 /include/serialize.h | |
parent | 556a4375e226760169150179b5bcaa659aaf055e (diff) |
Allow modules loaded after startup to magically reobtain their database objects. Fix os_dns for sql(live)
Diffstat (limited to 'include/serialize.h')
-rw-r--r-- | include/serialize.h | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/include/serialize.h b/include/serialize.h index 1a16e5b35..edbf1facf 100644 --- a/include/serialize.h +++ b/include/serialize.h @@ -188,52 +188,49 @@ class Serialize::Checker { Anope::string name; T obj; + mutable Serialize::Type *type; + + inline void Check() const + { + if (!type) + type = Serialize::Type::Find(this->name); + if (type) + type->Check(); + } public: - Checker(const Anope::string &n) : name(n) { } + Checker(const Anope::string &n) : name(n), type(NULL) { } inline const T* operator->() const { - static Serialize::Type *type = Serialize::Type::Find(this->name); - if (type) - type->Check(); + this->Check(); return &this->obj; } inline T* operator->() { - static Serialize::Type *type = Serialize::Type::Find(this->name); - if (type) - type->Check(); + this->Check(); return &this->obj; } inline const T& operator*() const { - static Serialize::Type *type = Serialize::Type::Find(this->name); - if (type) - type->Check(); + this->Check(); return this->obj; } inline T& operator*() { - static Serialize::Type *type = Serialize::Type::Find(this->name); - if (type) - type->Check(); + this->Check(); return this->obj; } inline operator const T&() const { - static Serialize::Type *type = Serialize::Type::Find(this->name); - if (type) - type->Check(); + this->Check(); return this->obj; } inline operator T&() { - static Serialize::Type *type = Serialize::Type::Find(this->name); - if (type) - type->Check(); + this->Check(); return this->obj; } }; |