From 3e5a5e1c669f6027b897f7358d45f92e1552f746 Mon Sep 17 00:00:00 2001 From: Adam Date: Wed, 10 Dec 2014 01:29:18 -0500 Subject: Use a triat class for event names instead of having to manually give them places, which is much less error prone --- include/modules/bs_badwords.h | 1 + include/modules/bs_bot.h | 4 ++++ include/modules/bs_info.h | 1 + include/modules/bs_kick.h | 2 ++ include/modules/chanserv.h | 7 +++++-- include/modules/cs_access.h | 2 ++ include/modules/cs_akick.h | 2 ++ include/modules/cs_drop.h | 2 ++ include/modules/cs_info.h | 1 + include/modules/cs_mode.h | 1 + include/modules/cs_set.h | 3 ++- include/modules/cs_suspend.h | 2 ++ include/modules/dns.h | 3 ++- include/modules/fantasy.h | 3 +++ include/modules/help.h | 2 ++ include/modules/hs_del.h | 2 ++ include/modules/memoserv.h | 12 +++++++----- include/modules/nickserv.h | 13 +++++++++---- include/modules/ns_cert.h | 2 ++ include/modules/ns_drop.h | 1 + include/modules/ns_group.h | 2 ++ include/modules/ns_info.h | 2 ++ include/modules/ns_set.h | 4 +++- include/modules/ns_suspend.h | 6 ++++-- include/modules/ns_update.h | 1 + include/modules/os_defcon.h | 1 + include/modules/os_session.h | 1 + 27 files changed, 67 insertions(+), 16 deletions(-) (limited to 'include/modules') diff --git a/include/modules/bs_badwords.h b/include/modules/bs_badwords.h index df42af6ec..87986ee62 100644 --- a/include/modules/bs_badwords.h +++ b/include/modules/bs_badwords.h @@ -99,3 +99,4 @@ namespace Event }; } +template<> struct EventName { static constexpr const char *const name = "Badwords"; }; diff --git a/include/modules/bs_bot.h b/include/modules/bs_bot.h index f66d57031..fe6534309 100644 --- a/include/modules/bs_bot.h +++ b/include/modules/bs_bot.h @@ -32,3 +32,7 @@ namespace Event virtual void OnBotDelete(ServiceBot *bi) anope_abstract; }; } + +template<> struct EventName { static constexpr const char *const name = "OnBotCreate"; }; +template<> struct EventName { static constexpr const char *const name = "OnBotChange"; }; +template<> struct EventName { static constexpr const char *const name = "OnBotDelete"; }; diff --git a/include/modules/bs_info.h b/include/modules/bs_info.h index 606888f4c..1ebd58c89 100644 --- a/include/modules/bs_info.h +++ b/include/modules/bs_info.h @@ -18,3 +18,4 @@ namespace Event extern CoreExport EventHandlers OnServiceBot; } +template<> struct EventName { static constexpr const char *const name = "OnServiceBot"; }; diff --git a/include/modules/bs_kick.h b/include/modules/bs_kick.h index 4fe234dd0..1346d7427 100644 --- a/include/modules/bs_kick.h +++ b/include/modules/bs_kick.h @@ -128,3 +128,5 @@ namespace Event }; } +template<> struct EventName { static constexpr const char *const name = "OnBotBan"; }; + diff --git a/include/modules/chanserv.h b/include/modules/chanserv.h index 9985f25dc..a6f741c1b 100644 --- a/include/modules/chanserv.h +++ b/include/modules/chanserv.h @@ -164,7 +164,7 @@ namespace ChanServ */ virtual void OnPreChanExpire(Channel *ci, bool &expire) anope_abstract; }; - static EventHandlersReference OnPreChanExpire("OnPreChanExpire"); + static EventHandlersReference OnPreChanExpire; struct CoreExport ChanExpire : Events { @@ -173,7 +173,7 @@ namespace ChanServ */ virtual void OnChanExpire(Channel *ci) anope_abstract; }; - static EventHandlersReference OnChanExpire("OnChanExpire"); + static EventHandlersReference OnChanExpire; } /* It matters that Base is here before Extensible (it is inherited by Serializable) @@ -734,3 +734,6 @@ namespace ChanServ } }; } + +template<> struct EventName { static constexpr const char *const name = "OnPreChanExpire"; }; +template<> struct EventName { static constexpr const char *const name = "OnChanExpire"; }; diff --git a/include/modules/cs_access.h b/include/modules/cs_access.h index b56996ede..54eb3f353 100644 --- a/include/modules/cs_access.h +++ b/include/modules/cs_access.h @@ -24,3 +24,5 @@ namespace Event virtual void OnLevelChange(CommandSource &source, ChanServ::Channel *ci, const Anope::string &priv, int16_t what) anope_abstract; }; } + +template<> struct EventName { static constexpr const char *const name = "OnLevelChange"; }; diff --git a/include/modules/cs_akick.h b/include/modules/cs_akick.h index a5c050e51..966dac15b 100644 --- a/include/modules/cs_akick.h +++ b/include/modules/cs_akick.h @@ -60,3 +60,5 @@ namespace Event virtual void OnAkickDel(CommandSource &source, ChanServ::Channel *ci, const AutoKick *ak) anope_abstract; }; } + +template<> struct EventName { static constexpr const char *const name = "Akick"; }; diff --git a/include/modules/cs_drop.h b/include/modules/cs_drop.h index 49247b3cb..db231059b 100644 --- a/include/modules/cs_drop.h +++ b/include/modules/cs_drop.h @@ -18,3 +18,5 @@ namespace Event virtual EventReturn OnChanDrop(CommandSource &source, ChanServ::Channel *ci) anope_abstract; }; } + +template<> struct EventName { static constexpr const char *const name = "OnChanDrop"; }; diff --git a/include/modules/cs_info.h b/include/modules/cs_info.h index 7b19abd19..f80e3daf2 100644 --- a/include/modules/cs_info.h +++ b/include/modules/cs_info.h @@ -21,3 +21,4 @@ namespace Event }; } +template<> struct EventName { static constexpr const char *const name = "OnChanInfo"; }; diff --git a/include/modules/cs_mode.h b/include/modules/cs_mode.h index a27197533..4d5f9dd2f 100644 --- a/include/modules/cs_mode.h +++ b/include/modules/cs_mode.h @@ -120,3 +120,4 @@ namespace Event }; } +template<> struct EventName { static constexpr const char *const name = "MLock"; }; diff --git a/include/modules/cs_set.h b/include/modules/cs_set.h index 355459f7c..a0e81c888 100644 --- a/include/modules/cs_set.h +++ b/include/modules/cs_set.h @@ -20,6 +20,7 @@ namespace Event */ virtual EventReturn OnSetChannelOption(CommandSource &source, Command *cmd, ChanServ::Channel *ci, const Anope::string &setting) anope_abstract; }; - static EventHandlersReference OnSetChannelOption("OnSetChannelOption"); + static EventHandlersReference OnSetChannelOption; } +template<> struct EventName { static constexpr const char *const name = "OnSetChannelOption"; }; diff --git a/include/modules/cs_suspend.h b/include/modules/cs_suspend.h index 6c561b637..27187ea09 100644 --- a/include/modules/cs_suspend.h +++ b/include/modules/cs_suspend.h @@ -49,3 +49,5 @@ namespace Event extern CoreExport EventHandlers OnChanUnsuspend; } +template<> struct EventName { static constexpr const char *const name = "OnChanSuspend"; }; +template<> struct EventName { static constexpr const char *const name = "OnChanUnsuspend"; }; diff --git a/include/modules/dns.h b/include/modules/dns.h index 7a0a587fa..f1ee94f87 100644 --- a/include/modules/dns.h +++ b/include/modules/dns.h @@ -188,9 +188,10 @@ namespace Event */ virtual void OnDnsRequest(DNS::Query &req, DNS::Query *reply) anope_abstract; }; - static EventHandlersReference OnDnsRequest("OnDnsRequest"); + static EventHandlersReference OnDnsRequest; } +template<> struct EventName { static constexpr const char *const name = "OnDnsRequest"; }; #endif // DNS_H diff --git a/include/modules/fantasy.h b/include/modules/fantasy.h index bb13b959d..1bdd8afdc 100644 --- a/include/modules/fantasy.h +++ b/include/modules/fantasy.h @@ -33,3 +33,6 @@ namespace Event virtual EventReturn OnBotNoFantasyAccess(CommandSource &source, Command *c, ChanServ::Channel *ci, const std::vector ¶ms) anope_abstract; }; } + +template<> struct EventName { static constexpr const char *const name = "OnBotFantasy"; }; +template<> struct EventName { static constexpr const char *const name = "OnBotNoFantasyAccess"; }; diff --git a/include/modules/help.h b/include/modules/help.h index 333e5f9c8..df81aecbf 100644 --- a/include/modules/help.h +++ b/include/modules/help.h @@ -25,3 +25,5 @@ namespace Event virtual void OnPostHelp(CommandSource &source, const std::vector ¶ms) anope_abstract; }; } + +template<> struct EventName { static constexpr const char *const name = "Help"; }; diff --git a/include/modules/hs_del.h b/include/modules/hs_del.h index fdec23b21..9b2ea39ef 100644 --- a/include/modules/hs_del.h +++ b/include/modules/hs_del.h @@ -16,3 +16,5 @@ namespace Event virtual void OnDeleteVhost(NickServ::Nick *na) anope_abstract; }; } + +template<> struct EventName { static constexpr const char *const name = "OnDeleteVhost"; }; diff --git a/include/modules/memoserv.h b/include/modules/memoserv.h index 9a209e27f..b7d49ad3a 100644 --- a/include/modules/memoserv.h +++ b/include/modules/memoserv.h @@ -61,7 +61,7 @@ namespace MemoServ */ virtual void OnMemoSend(const Anope::string &source, const Anope::string &target, MemoInfo *mi, Memo *m) anope_abstract; }; - static EventHandlersReference OnMemoSend("OnMemoSend"); + static EventHandlersReference OnMemoSend; struct CoreExport MemoDel : Events { @@ -72,14 +72,14 @@ namespace MemoServ */ virtual void OnMemoDel(const Anope::string &target, MemoInfo *mi, const Memo *m) anope_abstract; }; - static EventHandlersReference OnMemoDel("OnMemoDel"); + static EventHandlersReference OnMemoDel; } class Memo : public Serialize::Object { protected: using Serialize::Object::Object; -// Memo() : Serialize::Object("Memo") { } + public: virtual MemoInfo *GetMemoInfo() anope_abstract; virtual void SetMemoInfo(MemoInfo *) anope_abstract; @@ -109,8 +109,7 @@ namespace MemoServ { protected: using Serialize::Object::Object; - //using MemoInfo::MemoInfo; - //MemoInfo() : Serialize::Object("MemoInfo") { } + public: virtual Memo *GetMemo(unsigned index) anope_abstract; @@ -148,3 +147,6 @@ namespace MemoServ static Serialize::TypeReference ignore("MemoIgnore"); } + +template<> struct EventName { static constexpr const char *const name = "OnMemoSend"; }; +template<> struct EventName { static constexpr const char *const name = "OnMemoDel"; }; diff --git a/include/modules/nickserv.h b/include/modules/nickserv.h index 84ff39520..a6921cf2e 100644 --- a/include/modules/nickserv.h +++ b/include/modules/nickserv.h @@ -67,7 +67,7 @@ namespace NickServ */ virtual void OnPreNickExpire(Nick *na, bool &expire) anope_abstract; }; - static EventHandlersReference OnPreNickExpire("OnPreNickExpire"); + static EventHandlersReference OnPreNickExpire; struct CoreExport NickExpire : Events { @@ -76,7 +76,7 @@ namespace NickServ */ virtual void OnNickExpire(Nick *na) anope_abstract; }; - static EventHandlersReference OnNickExpire("OnNickExpire"); + static EventHandlersReference OnNickExpire; struct CoreExport NickRegister : Events { @@ -87,7 +87,7 @@ namespace NickServ */ virtual void OnNickRegister(User *user, Nick *na, const Anope::string &password) anope_abstract; }; - static EventHandlersReference OnNickRegister("OnNickRegister"); + static EventHandlersReference OnNickRegister; struct CoreExport NickValidate : Events { @@ -99,7 +99,7 @@ namespace NickServ */ virtual EventReturn OnNickValidate(User *u, Nick *na) anope_abstract; }; - static EventHandlersReference OnNickValidate("OnNickValidate"); + static EventHandlersReference OnNickValidate; } /* A registered nickname. @@ -293,3 +293,8 @@ namespace NickServ static Serialize::TypeReference mode("NSKeepMode"); } + +template<> struct EventName { static constexpr const char *const name = "OnPreNickExpire"; }; +template<> struct EventName { static constexpr const char *const name = "OnNickExpire"; }; +template<> struct EventName { static constexpr const char *const name = "OnNickRegister"; }; +template<> struct EventName { static constexpr const char *const name = "OnNickValidate"; }; diff --git a/include/modules/ns_cert.h b/include/modules/ns_cert.h index 994f0378e..be75fb9bf 100644 --- a/include/modules/ns_cert.h +++ b/include/modules/ns_cert.h @@ -62,3 +62,5 @@ namespace Event }; } + +template<> struct EventName { static constexpr const char *const name = "OnNickCert"; }; diff --git a/include/modules/ns_drop.h b/include/modules/ns_drop.h index 9217a924c..bae9d77b6 100644 --- a/include/modules/ns_drop.h +++ b/include/modules/ns_drop.h @@ -19,3 +19,4 @@ namespace Event extern CoreExport EventHandlers OnNickDrop; } +template<> struct EventName { static constexpr const char *const name = "OnNickDrop"; }; diff --git a/include/modules/ns_group.h b/include/modules/ns_group.h index a254c4412..caa568a9e 100644 --- a/include/modules/ns_group.h +++ b/include/modules/ns_group.h @@ -18,3 +18,5 @@ namespace Event virtual void OnNickGroup(User *u, NickServ::Nick *target) anope_abstract; }; } + +template<> struct EventName { static constexpr const char *const name = "OnNickGroup"; }; diff --git a/include/modules/ns_info.h b/include/modules/ns_info.h index dd593ce59..e816cc356 100644 --- a/include/modules/ns_info.h +++ b/include/modules/ns_info.h @@ -20,3 +20,5 @@ namespace Event virtual void OnNickInfo(CommandSource &source, NickServ::Nick *na, InfoFormatter &info, bool show_hidden) anope_abstract; }; } + +template<> struct EventName { static constexpr const char *const name = "OnNickInfo"; }; diff --git a/include/modules/ns_set.h b/include/modules/ns_set.h index b958b4cf5..c6b86032b 100644 --- a/include/modules/ns_set.h +++ b/include/modules/ns_set.h @@ -20,5 +20,7 @@ namespace Event */ virtual EventReturn OnSetNickOption(CommandSource &source, Command *cmd, NickServ::Account *nc, const Anope::string &setting) anope_abstract; }; - static EventHandlersReference OnSetNickOption("OnSetNickOption"); + static EventHandlersReference OnSetNickOption; } + +template<> struct EventName { static constexpr const char *const name = "OnSetNickOption"; }; diff --git a/include/modules/ns_suspend.h b/include/modules/ns_suspend.h index b985cb218..fcfc0265d 100644 --- a/include/modules/ns_suspend.h +++ b/include/modules/ns_suspend.h @@ -40,12 +40,14 @@ namespace Event virtual void OnNickSuspend(NickServ::Nick *na) anope_abstract; }; - struct CoreExport NickUnsuspended : Events + struct CoreExport NickUnsuspend : Events { /** Called when a nick is unsuspneded * @param na The nick alias */ - virtual void OnNickUnsuspended(NickServ::Nick *na) anope_abstract; + virtual void OnNickUnsuspend(NickServ::Nick *na) anope_abstract; }; } +template<> struct EventName { static constexpr const char *const name = "OnNickSuspend"; }; +template<> struct EventName { static constexpr const char *const name = "OnNickUnsuspend"; }; diff --git a/include/modules/ns_update.h b/include/modules/ns_update.h index d5d01320a..ce75c33ac 100644 --- a/include/modules/ns_update.h +++ b/include/modules/ns_update.h @@ -18,3 +18,4 @@ namespace Event }; } +template<> struct EventName { static constexpr const char *const name = "OnNickUpdate"; }; diff --git a/include/modules/os_defcon.h b/include/modules/os_defcon.h index 81b220eb3..f980d5008 100644 --- a/include/modules/os_defcon.h +++ b/include/modules/os_defcon.h @@ -18,3 +18,4 @@ namespace Event }; } +template<> struct EventName { static constexpr const char *const name = "OnDefconLevel"; }; diff --git a/include/modules/os_session.h b/include/modules/os_session.h index c6af4fb03..b9afd196e 100644 --- a/include/modules/os_session.h +++ b/include/modules/os_session.h @@ -74,3 +74,4 @@ namespace Event }; } +template<> struct EventName { static constexpr const char *const name = "Exception"; }; -- cgit