diff options
| author | Adam <Adam@anope.org> | 2014-12-10 01:29:18 -0500 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2014-12-10 01:29:18 -0500 |
| commit | 3e5a5e1c669f6027b897f7358d45f92e1552f746 (patch) | |
| tree | 5be9d41890d79eb0472f374b3f2a0ab9b36b1941 | |
| parent | 42238034490fb5479d787bd1695750387d508200 (diff) | |
Use a triat class for event names instead of having to manually give them places, which is much less error prone
116 files changed, 508 insertions, 365 deletions
diff --git a/include/event.h b/include/event.h index a8c8999cd..1cc39a67e 100644 --- a/include/event.h +++ b/include/event.h @@ -59,6 +59,9 @@ struct Caller<EventHandler, Func, EventReturn, Args...> } }; +template<typename T> +struct EventName; + template<typename EventHandler> class EventHook; @@ -69,7 +72,7 @@ class EventHandlers : public Service friend class EventHook<EventHandler>; public: - EventHandlers(Module *o, const Anope::string &ename) : Service(o, "EventHandlers", ename) + EventHandlers(Module *o) : Service(o, "EventHandlers", EventName<EventHandler>::name) { } @@ -85,7 +88,7 @@ class EventHandlersReference { ServiceReference<EventHandlers<EventHandler>> ref; public: - EventHandlersReference(const Anope::string &name) : ref("EventHandlers", name) { } + EventHandlersReference() : ref("EventHandlers", EventName<EventHandler>::name) { } explicit operator bool() { @@ -131,7 +134,7 @@ class EventHook : public EventHandler } priority; - EventHook(const Anope::string &name, Priority p = Priority::LAST) : handlers(this, name), priority(p) + EventHook(Priority p = Priority::LAST) : handlers(this, EventName<EventHandler>::name), priority(p) { handlers.Check(); } @@ -1013,3 +1016,88 @@ namespace Event extern CoreExport EventHandlers<SerializeEvents> OnSerialize; } +template<> struct EventName<Event::PreUserKicked> { static constexpr const char *const name = "OnPreUserKicked"; }; +template<> struct EventName<Event::UserKicked> { static constexpr const char *const name = "OnUserKicked"; }; +template<> struct EventName<Event::PreBotAssign> { static constexpr const char *const name = "OnPreBotAssign"; }; +template<> struct EventName<Event::BotAssign> { static constexpr const char *const name = "OnBotAssign"; }; +template<> struct EventName<Event::BotUnAssign> { static constexpr const char *const name = "OnBotUnAssign"; }; +template<> struct EventName<Event::UserConnect> { static constexpr const char *const name = "OnUserConnect"; }; +template<> struct EventName<Event::NewServer> { static constexpr const char *const name = "OnNewServer"; }; +template<> struct EventName<Event::UserNickChange> { static constexpr const char *const name = "OnUserNickChange"; }; +template<> struct EventName<Event::PreCommand> { static constexpr const char *const name = "OnPreCommand"; }; +template<> struct EventName<Event::PostCommand> { static constexpr const char *const name = "OnPostCommand"; }; +template<> struct EventName<Event::SaveDatabase> { static constexpr const char *const name = "OnSaveDatabase"; }; +template<> struct EventName<Event::LoadDatabase> { static constexpr const char *const name = "OnLoadDatabase"; }; +template<> struct EventName<Event::Encrypt> { static constexpr const char *const name = "OnEncrypt"; }; +template<> struct EventName<Event::Decrypt> { static constexpr const char *const name = "OnDecrypt"; }; +template<> struct EventName<Event::CreateBot> { static constexpr const char *const name = "OnCreateBot"; }; +template<> struct EventName<Event::DelBot> { static constexpr const char *const name = "OnDelBot"; }; +template<> struct EventName<Event::PrePartChannel> { static constexpr const char *const name = "OnPrePartChannel"; }; +template<> struct EventName<Event::PartChannel> { static constexpr const char *const name = "OnPartChannel"; }; +template<> struct EventName<Event::LeaveChannel> { static constexpr const char *const name = "OnLeaveChannel"; }; +template<> struct EventName<Event::JoinChannel> { static constexpr const char *const name = "OnJoinChannel"; }; +template<> struct EventName<Event::TopicUpdated> { static constexpr const char *const name = "OnTopicUpdated"; }; +template<> struct EventName<Event::PreServerConnect> { static constexpr const char *const name = "OnPreServerConnect"; }; +template<> struct EventName<Event::ServerConnect> { static constexpr const char *const name = "OnServerConnect"; }; +template<> struct EventName<Event::PreUplinkSync> { static constexpr const char *const name = "OnPreUplinkSync"; }; +template<> struct EventName<Event::ServerDisconnect> { static constexpr const char *const name = "OnServerDisconnect"; }; +template<> struct EventName<Event::Restart> { static constexpr const char *const name = "OnRestart"; }; +template<> struct EventName<Event::Shutdown> { static constexpr const char *const name = "OnShutdown"; }; +template<> struct EventName<Event::AddXLine> { static constexpr const char *const name = "OnAddXLine"; }; +template<> struct EventName<Event::DelXLine> { static constexpr const char *const name = "OnDelXLine"; }; +template<> struct EventName<Event::IsServicesOperEvent> { static constexpr const char *const name = "OnIsServicesOper"; }; +template<> struct EventName<Event::ServerQuit> { static constexpr const char *const name = "OnServerQuit"; }; +template<> struct EventName<Event::UserQuit> { static constexpr const char *const name = "OnUserQuit"; }; +template<> struct EventName<Event::PreUserLogoff> { static constexpr const char *const name = "OnPreUserLogoff"; }; +template<> struct EventName<Event::PostUserLogoff> { static constexpr const char *const name = "OnPostUserLogoff"; }; +template<> struct EventName<Event::AccessDel> { static constexpr const char *const name = "OnAccessDel"; }; +template<> struct EventName<Event::AccessAdd> { static constexpr const char *const name = "OnAccessAdd"; }; +template<> struct EventName<Event::AccessClear> { static constexpr const char *const name = "OnAccessClear"; }; +template<> struct EventName<Event::ChanRegistered> { static constexpr const char *const name = "OnChanRegistered"; }; +template<> struct EventName<Event::CreateChan> { static constexpr const char *const name = "OnCreateChan"; }; +template<> struct EventName<Event::DelChan> { static constexpr |
