1
0
mirror of https://github.com/anope/anope.git synced 2026-06-26 03:06:38 +02:00

Move serialization from Serializable to a Serialize::Type child.

This commit is contained in:
Sadie Powell
2025-03-12 10:29:11 +00:00
parent 718f2e922a
commit cdcf0e2f9a
40 changed files with 778 additions and 452 deletions
+11 -9
View File
@@ -27,9 +27,14 @@ std::list<Serializable *> *Serializable::SerializableItems;
void Serialize::RegisterTypes()
{
static Type nc("NickCore", NickCore::Unserialize), na("NickAlias", NickAlias::Unserialize), bi("BotInfo", BotInfo::Unserialize),
ci("ChannelInfo", ChannelInfo::Unserialize), access("ChanAccess", ChanAccess::Unserialize),
akick("AutoKick", AutoKick::Unserialize), memo("Memo", Memo::Unserialize), xline("XLine", XLine::Unserialize);
static NickCore::Type nc;
static NickAlias::Type na;
static BotInfo::Type bi;
static ChannelInfo::Type ci;
static ChanAccess::Type access;
static AutoKick::Type akick;
static Memo::Type memo;
static XLine::Type xline;
}
void Serialize::CheckTypes()
@@ -124,7 +129,9 @@ void Serialize::Data::SetType(const Anope::string &key, Serialize::DataType dt)
this->types[key] = dt;
}
Type::Type(const Anope::string &n, unserialize_func f, Module *o) : name(n), unserialize(f), owner(o)
Type::Type(const Anope::string &n, Module *o)
: name(n)
, owner(o)
{
TypeOrder.push_back(this->name);
Types[this->name] = this;
@@ -150,11 +157,6 @@ Type::~Type()
Types.erase(this->name);
}
Serializable *Type::Unserialize(Serializable *obj, Serialize::Data &data)
{
return this->unserialize(obj, data);
}
void Type::Check()
{
FOREACH_MOD(OnSerializeCheck, (this));