mirror of
https://github.com/anope/anope.git
synced 2026-07-09 01:03:14 +02:00
Allow modules to store data in their own databases.
This commit is contained in:
+1
-6
@@ -90,7 +90,7 @@ const std::list<AccessProvider *>& AccessProvider::GetProviders()
|
||||
return providers;
|
||||
}
|
||||
|
||||
ChanAccess::ChanAccess(AccessProvider *p) : provider(p)
|
||||
ChanAccess::ChanAccess(AccessProvider *p) : Serializable("ChanAccess"), provider(p)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -98,11 +98,6 @@ ChanAccess::~ChanAccess()
|
||||
{
|
||||
}
|
||||
|
||||
const Anope::string ChanAccess::serialize_name() const
|
||||
{
|
||||
return "ChanAccess";
|
||||
}
|
||||
|
||||
Serialize::Data ChanAccess::serialize() const
|
||||
{
|
||||
Serialize::Data data;
|
||||
|
||||
+1
-6
@@ -21,7 +21,7 @@
|
||||
serialize_checker<botinfo_map> BotListByNick("BotInfo");
|
||||
serialize_checker<botinfouid_map> BotListByUID("BotInfo");
|
||||
|
||||
BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const Anope::string &nhost, const Anope::string &nreal, const Anope::string &bmodes) : User(nnick, nuser, nhost, "", "", Me, nreal, Anope::CurTime, "", ts6_uid_retrieve()), Flags<BotFlag, BI_END>(BotFlagString), botmodes(bmodes)
|
||||
BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const Anope::string &nhost, const Anope::string &nreal, const Anope::string &bmodes) : User(nnick, nuser, nhost, "", "", Me, nreal, Anope::CurTime, "", ts6_uid_retrieve()), Flags<BotFlag, BI_END>(BotFlagString), Serializable("BotInfo"), botmodes(bmodes)
|
||||
{
|
||||
this->lastmsg = this->created = Anope::CurTime;
|
||||
this->introduced = false;
|
||||
@@ -71,11 +71,6 @@ BotInfo::~BotInfo()
|
||||
BotListByUID->erase(this->uid);
|
||||
}
|
||||
|
||||
const Anope::string BotInfo::serialize_name() const
|
||||
{
|
||||
return "BotInfo";
|
||||
}
|
||||
|
||||
Serialize::Data BotInfo::serialize() const
|
||||
{
|
||||
Serialize::Data data;
|
||||
|
||||
+1
-6
@@ -18,12 +18,7 @@
|
||||
#include "users.h"
|
||||
#include "account.h"
|
||||
|
||||
Memo::Memo() : Flags<MemoFlag>(MemoFlagStrings) { }
|
||||
|
||||
const Anope::string Memo::serialize_name() const
|
||||
{
|
||||
return "Memo";
|
||||
}
|
||||
Memo::Memo() : Flags<MemoFlag>(MemoFlagStrings), Serializable("Memo") { }
|
||||
|
||||
Serialize::Data Memo::serialize() const
|
||||
{
|
||||
|
||||
+1
-6
@@ -29,7 +29,7 @@ static nickservheld_map NickServHelds;
|
||||
* @param nick The nick
|
||||
* @param nickcore The nickcore for this nick
|
||||
*/
|
||||
NickAlias::NickAlias(const Anope::string &nickname, NickCore* nickcore) : Flags<NickNameFlag, NS_END>(NickNameFlagStrings)
|
||||
NickAlias::NickAlias(const Anope::string &nickname, NickCore* nickcore) : Flags<NickNameFlag, NS_END>(NickNameFlagStrings), Serializable("NickAlias")
|
||||
{
|
||||
if (nickname.empty())
|
||||
throw CoreException("Empty nick passed to NickAlias constructor");
|
||||
@@ -240,11 +240,6 @@ time_t NickAlias::GetVhostCreated() const
|
||||
return this->vhost_created;
|
||||
}
|
||||
|
||||
const Anope::string NickAlias::serialize_name() const
|
||||
{
|
||||
return "NickAlias";
|
||||
}
|
||||
|
||||
Serialize::Data NickAlias::serialize() const
|
||||
{
|
||||
Serialize::Data data;
|
||||
|
||||
+1
-6
@@ -19,7 +19,7 @@ serialize_checker<nickcore_map> NickCoreList("NickCore");
|
||||
/** Default constructor
|
||||
* @param display The display nick
|
||||
*/
|
||||
NickCore::NickCore(const Anope::string &coredisplay) : Flags<NickCoreFlag, NI_END>(NickCoreFlagStrings)
|
||||
NickCore::NickCore(const Anope::string &coredisplay) : Flags<NickCoreFlag, NI_END>(NickCoreFlagStrings), Serializable("NickCore")
|
||||
{
|
||||
if (coredisplay.empty())
|
||||
throw CoreException("Empty display passed to NickCore constructor");
|
||||
@@ -60,11 +60,6 @@ NickCore::~NickCore()
|
||||
}
|
||||
}
|
||||
|
||||
const Anope::string NickCore::serialize_name() const
|
||||
{
|
||||
return "NickCore";
|
||||
}
|
||||
|
||||
Serialize::Data NickCore::serialize() const
|
||||
{
|
||||
Serialize::Data data;
|
||||
|
||||
+2
-7
@@ -45,7 +45,7 @@ void XLine::InitRegex()
|
||||
}
|
||||
}
|
||||
|
||||
XLine::XLine(const Anope::string &mask, const Anope::string &reason, const Anope::string &uid) : Mask(mask), Created(0), Expires(0), Reason(reason), UID(uid)
|
||||
XLine::XLine(const Anope::string &mask, const Anope::string &reason, const Anope::string &uid) : Serializable("XLine"), Mask(mask), Created(0), Expires(0), Reason(reason), UID(uid)
|
||||
{
|
||||
regex = NULL;
|
||||
manager = NULL;
|
||||
@@ -53,7 +53,7 @@ XLine::XLine(const Anope::string &mask, const Anope::string &reason, const Anope
|
||||
this->InitRegex();
|
||||
}
|
||||
|
||||
XLine::XLine(const Anope::string &mask, const Anope::string &by, const time_t expires, const Anope::string &reason, const Anope::string &uid) : Mask(mask), By(by), Created(Anope::CurTime), Expires(expires), Reason(reason), UID(uid)
|
||||
XLine::XLine(const Anope::string &mask, const Anope::string &by, const time_t expires, const Anope::string &reason, const Anope::string &uid) : Serializable("XLine"), Mask(mask), By(by), Created(Anope::CurTime), Expires(expires), Reason(reason), UID(uid)
|
||||
{
|
||||
regex = NULL;
|
||||
manager = NULL;
|
||||
@@ -138,11 +138,6 @@ bool XLine::IsRegex() const
|
||||
return !this->Mask.empty() && this->Mask[0] == '/' && this->Mask[this->Mask.length() - 1] == '/';
|
||||
}
|
||||
|
||||
const Anope::string XLine::serialize_name() const
|
||||
{
|
||||
return "XLine";
|
||||
}
|
||||
|
||||
Serialize::Data XLine::serialize() const
|
||||
{
|
||||
Serialize::Data data;
|
||||
|
||||
+6
-29
@@ -23,11 +23,6 @@
|
||||
|
||||
serialize_checker<registered_channel_map> RegisteredChannelList("ChannelInfo");
|
||||
|
||||
const Anope::string BadWord::serialize_name() const
|
||||
{
|
||||
return "BadWord";
|
||||
}
|
||||
|
||||
Serialize::Data BadWord::serialize() const
|
||||
{
|
||||
Serialize::Data data;
|
||||
@@ -61,15 +56,10 @@ Serializable* BadWord::unserialize(Serializable *obj, Serialize::Data &data)
|
||||
return bw;
|
||||
}
|
||||
|
||||
AutoKick::AutoKick() : Flags<AutoKickFlag>(AutoKickFlagString)
|
||||
AutoKick::AutoKick() : Flags<AutoKickFlag>(AutoKickFlagString), Serializable("AutoKick")
|
||||
{
|
||||
}
|
||||
|
||||
const Anope::string AutoKick::serialize_name() const
|
||||
{
|
||||
return "AutoKick";
|
||||
}
|
||||
|
||||
Serialize::Data AutoKick::serialize() const
|
||||
{
|
||||
Serialize::Data data;
|
||||
@@ -121,15 +111,10 @@ Serializable* AutoKick::unserialize(Serializable *obj, Serialize::Data &data)
|
||||
return ak;
|
||||
}
|
||||
|
||||
ModeLock::ModeLock(ChannelInfo *ch, bool s, ChannelModeName n, const Anope::string &p, const Anope::string &se, time_t c) : ci(ch), set(s), name(n), param(p), setter(se), created(c)
|
||||
ModeLock::ModeLock(ChannelInfo *ch, bool s, ChannelModeName n, const Anope::string &p, const Anope::string &se, time_t c) : Serializable("ModeLock"), ci(ch), set(s), name(n), param(p), setter(se), created(c)
|
||||
{
|
||||
}
|
||||
|
||||
const Anope::string ModeLock::serialize_name() const
|
||||
{
|
||||
return "ModeLock";
|
||||
}
|
||||
|
||||
Serialize::Data ModeLock::serialize() const
|
||||
{
|
||||
Serialize::Data data;
|
||||
@@ -192,11 +177,6 @@ Serializable* ModeLock::unserialize(Serializable *obj, Serialize::Data &data)
|
||||
}
|
||||
}
|
||||
|
||||
const Anope::string LogSetting::serialize_name() const
|
||||
{
|
||||
return "LogSetting";
|
||||
}
|
||||
|
||||
Serialize::Data LogSetting::serialize() const
|
||||
{
|
||||
Serialize::Data data;
|
||||
@@ -246,7 +226,8 @@ Serializable* LogSetting::unserialize(Serializable *obj, Serialize::Data &data)
|
||||
/** Default constructor
|
||||
* @param chname The channel name
|
||||
*/
|
||||
ChannelInfo::ChannelInfo(const Anope::string &chname) : Flags<ChannelInfoFlag, CI_END>(ChannelInfoFlagStrings), access("ChanAccess"), akick("AutoKick"),
|
||||
ChannelInfo::ChannelInfo(const Anope::string &chname) : Flags<ChannelInfoFlag, CI_END>(ChannelInfoFlagStrings), Serializable("ChannelInfo"),
|
||||
access("ChanAccess"), akick("AutoKick"),
|
||||
badwords("BadWord"), mode_locks("ModeLock"), log_settings("LogSetting"), botflags(BotServFlagStrings)
|
||||
{
|
||||
if (chname.empty())
|
||||
@@ -291,7 +272,8 @@ ChannelInfo::ChannelInfo(const Anope::string &chname) : Flags<ChannelInfoFlag, C
|
||||
/** Copy constructor
|
||||
* @param ci The ChannelInfo to copy settings to
|
||||
*/
|
||||
ChannelInfo::ChannelInfo(const ChannelInfo &ci) : Flags<ChannelInfoFlag, CI_END>(ChannelInfoFlagStrings), access("ChanAccess"), akick("AutoKick"),
|
||||
ChannelInfo::ChannelInfo(const ChannelInfo &ci) : Flags<ChannelInfoFlag, CI_END>(ChannelInfoFlagStrings), Serializable("ChannelInfo"),
|
||||
access("ChanAccess"), akick("AutoKick"),
|
||||
badwords("BadWord"), mode_locks("ModeLock"), log_settings("LogSetting"), botflags(BotServFlagStrings)
|
||||
{
|
||||
*this = ci;
|
||||
@@ -384,11 +366,6 @@ ChannelInfo::~ChannelInfo()
|
||||
--this->founder->channelcount;
|
||||
}
|
||||
|
||||
const Anope::string ChannelInfo::serialize_name() const
|
||||
{
|
||||
return "ChannelInfo";
|
||||
}
|
||||
|
||||
Serialize::Data ChannelInfo::serialize() const
|
||||
{
|
||||
Serialize::Data data;
|
||||
|
||||
+21
-2
@@ -71,23 +71,32 @@ unsigned stringstream::getMax() const
|
||||
}
|
||||
|
||||
Serializable::Serializable() : last_commit_time(0), id(0)
|
||||
{
|
||||
throw CoreException("Default Serializable constructor?");
|
||||
}
|
||||
|
||||
Serializable::Serializable(const Anope::string &serialize_type) : last_commit_time(0), id(0)
|
||||
{
|
||||
if (serializable_items == NULL)
|
||||
serializable_items = new std::list<Serializable *>();
|
||||
serializable_items->push_back(this);
|
||||
|
||||
this->s_type = SerializeType::Find(serialize_type);
|
||||
|
||||
this->s_iter = serializable_items->end();
|
||||
--this->s_iter;
|
||||
|
||||
FOREACH_MOD(I_OnSerializableConstruct, OnSerializableConstruct(this));
|
||||
}
|
||||
|
||||
Serializable::Serializable(const Serializable &) : last_commit_time(0), id(0)
|
||||
Serializable::Serializable(const Serializable &other) : last_commit_time(0), id(0)
|
||||
{
|
||||
serializable_items->push_back(this);
|
||||
this->s_iter = serializable_items->end();
|
||||
--this->s_iter;
|
||||
|
||||
this->s_type = other.s_type;
|
||||
|
||||
FOREACH_MOD(I_OnSerializableConstruct, OnSerializableConstruct(this));
|
||||
}
|
||||
|
||||
@@ -136,12 +145,17 @@ void Serializable::UpdateTS()
|
||||
this->last_commit_time = Anope::CurTime;
|
||||
}
|
||||
|
||||
SerializeType* Serializable::GetSerializableType() const
|
||||
{
|
||||
return this->s_type;
|
||||
}
|
||||
|
||||
const std::list<Serializable *> &Serializable::GetItems()
|
||||
{
|
||||
return *serializable_items;
|
||||
}
|
||||
|
||||
SerializeType::SerializeType(const Anope::string &n, unserialize_func f) : name(n), unserialize(f), timestamp(0)
|
||||
SerializeType::SerializeType(const Anope::string &n, unserialize_func f, Module *o) : name(n), unserialize(f), owner(o), timestamp(0)
|
||||
{
|
||||
type_order.push_back(this->name);
|
||||
types[this->name] = this;
|
||||
@@ -180,6 +194,11 @@ void SerializeType::UpdateTimestamp()
|
||||
this->timestamp = Anope::CurTime;
|
||||
}
|
||||
|
||||
Module* SerializeType::GetOwner() const
|
||||
{
|
||||
return this->owner;
|
||||
}
|
||||
|
||||
SerializeType *SerializeType::Find(const Anope::string &name)
|
||||
{
|
||||
Anope::map<SerializeType *>::iterator it = types.find(name);
|
||||
|
||||
Reference in New Issue
Block a user