summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2012-12-25 15:52:58 -0500
committerAdam <Adam@anope.org>2012-12-25 15:52:58 -0500
commit392b591d09509ae788f59b1b63a947ed7d8ad562 (patch)
treefb34d59492895d676e07c47b364829ec9eeb1a14 /include
parent556a4375e226760169150179b5bcaa659aaf055e (diff)
Allow modules loaded after startup to magically reobtain their database objects. Fix os_dns for sql(live)
Diffstat (limited to 'include')
-rw-r--r--include/modules.h3
-rw-r--r--include/serialize.h35
2 files changed, 18 insertions, 20 deletions
diff --git a/include/modules.h b/include/modules.h
index 09df6617e..eba0138b8 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -935,6 +935,7 @@ class CoreExport Module : public Extensible
virtual void OnSerializableConstruct(Serializable *) { }
virtual void OnSerializableDestruct(Serializable *) { }
virtual void OnSerializableUpdate(Serializable *) { }
+ virtual void OnSerializeTypeCreate(Serialize::Type *) { }
/** Called when a chanserv/set command is used
* @param source The source of the command
@@ -1013,7 +1014,7 @@ enum Implementation
I_OnMLock, I_OnUnMLock, I_OnServerSync, I_OnUplinkSync, I_OnBotPrivmsg, I_OnPrivmsg, I_OnLog, I_OnDnsRequest,
I_OnMessage,
- I_OnSerializeCheck, I_OnSerializableConstruct, I_OnSerializableDestruct, I_OnSerializableUpdate,
+ I_OnSerializeCheck, I_OnSerializableConstruct, I_OnSerializableDestruct, I_OnSerializableUpdate, I_OnSerializeTypeCreate,
I_END
};
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;
}
};