diff options
| author | Adam <Adam@anope.org> | 2016-07-28 21:29:35 -0400 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2016-07-28 21:29:35 -0400 |
| commit | 0e758a2ac23dc4a001e8e126cec14588da9a9769 (patch) | |
| tree | 45df813323e023c5c89db7279426c4ad0943b4a9 /include/modules/botserv | |
| parent | a3c8afae00c54d5b95c620248b51f90679d7d53f (diff) | |
Allow serializable fields to use storage in the respective objects.
Split service management code nito a proper servicemanager. Make service
references managed instead of lazy lookup. Also made events and
serializable use service manager instead of their respective systems for
management
Diffstat (limited to 'include/modules/botserv')
| -rw-r--r-- | include/modules/botserv/badwords.h | 18 | ||||
| -rw-r--r-- | include/modules/botserv/bot.h | 15 | ||||
| -rw-r--r-- | include/modules/botserv/info.h | 6 | ||||
| -rw-r--r-- | include/modules/botserv/kick.h | 28 |
4 files changed, 41 insertions, 26 deletions
diff --git a/include/modules/botserv/badwords.h b/include/modules/botserv/badwords.h index 87986ee62..6f2205a97 100644 --- a/include/modules/botserv/badwords.h +++ b/include/modules/botserv/badwords.h @@ -31,6 +31,8 @@ class BadWord : public Serialize::Object protected: using Serialize::Object::Object; public: + static constexpr const char *NAME = "badword"; + virtual ~BadWord() = default; virtual ChanServ::Channel *GetChannel() anope_abstract; @@ -43,11 +45,12 @@ class BadWord : public Serialize::Object virtual void SetType(const BadWordType &) anope_abstract; }; -static Serialize::TypeReference<BadWord> badword("BadWord"); - -struct BadWords : public Service +class BadWords : public Service { - BadWords(Module *me) : Service(me, "BadWords", "badwords") { } + public: + static constexpr const char *NAME = "badwords"; + + BadWords(Module *me) : Service(me, NAME) { } /** Add a badword to the badword list * @param word The badword @@ -79,12 +82,14 @@ struct BadWords : public Service virtual void ClearBadWords(ChanServ::Channel *) anope_abstract; }; -static ServiceReference<BadWords> badwords("BadWords", "badwords"); - namespace Event { struct CoreExport BadWordEvents : Events { + static constexpr const char *NAME = "badwords"; + + using Events::Events; + /** Called before a badword is added to the badword list * @param ci The channel * @param bw The badword @@ -99,4 +104,3 @@ namespace Event }; } -template<> struct EventName<Event::BadWordEvents> { static constexpr const char *const name = "Badwords"; }; diff --git a/include/modules/botserv/bot.h b/include/modules/botserv/bot.h index fe6534309..e07b75f9a 100644 --- a/include/modules/botserv/bot.h +++ b/include/modules/botserv/bot.h @@ -10,6 +10,10 @@ namespace Event { struct CoreExport BotCreate : Events { + static constexpr const char *NAME = "botcreate"; + + using Events::Events; + /** Called when a new bot is made * @param bi The bot */ @@ -18,6 +22,10 @@ namespace Event struct CoreExport BotChange : Events { + static constexpr const char *NAME = "botchange"; + + using Events::Events; + /** Called when a bot is changed * @param bi The bot */ @@ -26,6 +34,10 @@ namespace Event struct CoreExport BotDelete : Events { + static constexpr const char *NAME = "botdelete"; + + using Events::Events; + /** Called when a bot is deleted * @param bi The bot */ @@ -33,6 +45,3 @@ namespace Event }; } -template<> struct EventName<Event::BotCreate> { static constexpr const char *const name = "OnBotCreate"; }; -template<> struct EventName<Event::BotChange> { static constexpr const char *const name = "OnBotChange"; }; -template<> struct EventName<Event::BotDelete> { static constexpr const char *const name = "OnBotDelete"; }; diff --git a/include/modules/botserv/info.h b/include/modules/botserv/info.h index 1ebd58c89..92bac8892 100644 --- a/include/modules/botserv/info.h +++ b/include/modules/botserv/info.h @@ -11,11 +11,13 @@ namespace Event { struct CoreExport ServiceBotEvent : Events { + static constexpr const char *NAME = "servicebotevent"; + + using Events::Events; + /** Called when a user uses botserv/info on a bot or channel. */ virtual void OnServiceBot(CommandSource &source, ServiceBot *bi, ChanServ::Channel *ci, InfoFormatter &info) anope_abstract; }; - extern CoreExport EventHandlers<ServiceBotEvent> OnServiceBot; } -template<> struct EventName<Event::ServiceBotEvent> { static constexpr const char *const name = "OnServiceBot"; }; diff --git a/include/modules/botserv/kick.h b/include/modules/botserv/kick.h index 1346d7427..4d0461739 100644 --- a/include/modules/botserv/kick.h +++ b/include/modules/botserv/kick.h @@ -1,14 +1,10 @@ /* BotServ core functions * - * (C) 2003-2014 Anope Team + * (C) 2003-2016 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. * - * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - * - * */ class KickerData : public Serialize::Object @@ -17,6 +13,8 @@ class KickerData : public Serialize::Object using Serialize::Object::Object; public: + static constexpr const char *const NAME = "kickerdata"; + virtual ChanServ::Channel *GetChannel() anope_abstract; virtual void SetChannel(ChanServ::Channel *) anope_abstract; @@ -102,15 +100,16 @@ class KickerData : public Serialize::Object virtual void SetDontKickVoices(const bool &) anope_abstract; }; -static Serialize::TypeReference<KickerData> kickerdata("KickerData"); - inline KickerData *GetKickerData(ChanServ::Channel *ci) { - KickerData *kd = ci->GetRef<KickerData *>(kickerdata); - if (!kd && kickerdata) + KickerData *kd = ci->GetRef<KickerData *>(); + if (!kd) { - kd = kickerdata.Create(); - kd->SetChannel(ci); + kd = Serialize::New<KickerData *>(); + if (kd != nullptr) + { + kd->SetChannel(ci); + } } return kd; } @@ -119,6 +118,10 @@ namespace Event { struct CoreExport BotBan : Events { + static constexpr const char *NAME = "botban"; + + using Events::Events; + /** Called when a bot places a ban * @param u User being banned * @param ci Channel the ban is placed on @@ -127,6 +130,3 @@ namespace Event virtual void OnBotBan(User *u, ChanServ::Channel *ci, const Anope::string &mask) anope_abstract; }; } - -template<> struct EventName<Event::BotBan> { static constexpr const char *const name = "OnBotBan"; }; - |
