From 0e758a2ac23dc4a001e8e126cec14588da9a9769 Mon Sep 17 00:00:00 2001 From: Adam Date: Thu, 28 Jul 2016 21:29:35 -0400 Subject: 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 --- include/modules/operserv/defcon.h | 5 ++++- include/modules/operserv/dns.h | 15 ++++++++------- include/modules/operserv/forbid.h | 12 +++++++----- include/modules/operserv/ignore.h | 13 ++++++------- include/modules/operserv/info.h | 8 ++++---- include/modules/operserv/news.h | 19 ++++++++++++------- include/modules/operserv/session.h | 14 ++++++++------ 7 files changed, 49 insertions(+), 37 deletions(-) (limited to 'include/modules/operserv') diff --git a/include/modules/operserv/defcon.h b/include/modules/operserv/defcon.h index f980d5008..f46609db3 100644 --- a/include/modules/operserv/defcon.h +++ b/include/modules/operserv/defcon.h @@ -11,6 +11,10 @@ namespace Event { struct CoreExport DefconLevel : Events { + static constexpr const char *NAME = "defconlevel"; + + using Events::Events; + /** Called when defcon level changes * @param level The level */ @@ -18,4 +22,3 @@ namespace Event }; } -template<> struct EventName { static constexpr const char *const name = "OnDefconLevel"; }; diff --git a/include/modules/operserv/dns.h b/include/modules/operserv/dns.h index d76cd3d62..a6f4e33b2 100644 --- a/include/modules/operserv/dns.h +++ b/include/modules/operserv/dns.h @@ -13,18 +13,20 @@ class DNSZone : public Serialize::Object using Serialize::Object::Object; public: + static constexpr const char *const NAME = "dnszone"; + virtual Anope::string GetName() anope_abstract; virtual void SetName(const Anope::string &) anope_abstract; }; -static Serialize::TypeReference dnszone("DNSZone"); - class DNSServer : public Serialize::Object { protected: using Serialize::Object::Object; public: + static constexpr const char *const NAME = "dnsserver"; + virtual DNSZone *GetZone() anope_abstract; virtual void SetZone(DNSZone *) anope_abstract; @@ -38,14 +40,14 @@ class DNSServer : public Serialize::Object virtual void SetPool(const bool &) anope_abstract; }; -static Serialize::TypeReference dnsserver("DNSServer"); - class DNSZoneMembership : public Serialize::Object { protected: using Serialize::Object::Object; public: + static constexpr const char *const NAME = "dnszonemembership"; + virtual DNSServer *GetServer() anope_abstract; virtual void SetServer(DNSServer *) anope_abstract; @@ -53,14 +55,14 @@ class DNSZoneMembership : public Serialize::Object virtual void SetZone(DNSZone *) anope_abstract; }; -static Serialize::TypeReference dnszonemembership("DNSZoneMembership"); - class DNSIP : public Serialize::Object { protected: using Serialize::Object::Object; public: + static constexpr const char *const NAME = "dnsip"; + virtual DNSServer *GetServer() anope_abstract; virtual void SetServer(DNSServer *) anope_abstract; @@ -68,5 +70,4 @@ class DNSIP : public Serialize::Object virtual void SetIP(const Anope::string &) anope_abstract; }; -static Serialize::TypeReference dnsip("DNSIP"); diff --git a/include/modules/operserv/forbid.h b/include/modules/operserv/forbid.h index 9b21defec..9fb1cd692 100644 --- a/include/modules/operserv/forbid.h +++ b/include/modules/operserv/forbid.h @@ -1,9 +1,10 @@ /* * - * (C) 2013-2014 Anope Team + * (C) 2013-2016 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. + * */ enum ForbidType @@ -21,6 +22,8 @@ class ForbidData : public Serialize::Object using Serialize::Object::Object; public: + static constexpr const char *NAME = "forbid"; + virtual Anope::string GetMask() anope_abstract; virtual void SetMask(const Anope::string &) anope_abstract; @@ -43,14 +46,13 @@ class ForbidData : public Serialize::Object class ForbidService : public Service { public: - ForbidService(Module *m) : Service(m, "ForbidService", "forbid") { } + static constexpr const char *NAME = "forbid"; + + ForbidService(Module *m) : Service(m, NAME) { } virtual ForbidData *FindForbid(const Anope::string &mask, ForbidType type) anope_abstract; virtual std::vector GetForbids() anope_abstract; }; -static ServiceReference forbid_service("ForbidService", "forbid"); - -static Serialize::TypeReference forbiddata("ForbidData"); diff --git a/include/modules/operserv/ignore.h b/include/modules/operserv/ignore.h index 2326b5575..ab793c533 100644 --- a/include/modules/operserv/ignore.h +++ b/include/modules/operserv/ignore.h @@ -13,6 +13,8 @@ class Ignore : public Serialize::Object { public: + static constexpr const char *NAME = "ignore"; + using Serialize::Object::Object; virtual Anope::string GetMask() anope_abstract; @@ -28,16 +30,13 @@ class Ignore : public Serialize::Object virtual void SetTime(const time_t &) anope_abstract; }; -static Serialize::TypeReference ignoretype("IgnoreData"); - class IgnoreService : public Service { - protected: - IgnoreService(Module *c) : Service(c, "IgnoreService", "ignore") { } - public: + static constexpr const char *NAME = "ignore"; + + IgnoreService(Module *c) : Service(c, NAME) { } + virtual Ignore *Find(const Anope::string &mask) anope_abstract; }; -static ServiceReference ignore_service("IgnoreService", "ignore"); - diff --git a/include/modules/operserv/info.h b/include/modules/operserv/info.h index 6e819158d..6b3674bc1 100644 --- a/include/modules/operserv/info.h +++ b/include/modules/operserv/info.h @@ -1,9 +1,10 @@ /* * - * (C) 2014 Anope Team + * (C) 2014-2016 Anope Team * Contact us at team@anope.org * * Please read COPYING and README for further details. + * */ class OperInfo : public Serialize::Object @@ -12,6 +13,8 @@ class OperInfo : public Serialize::Object using Serialize::Object::Object; public: + static constexpr const char *const NAME = "operinfo"; + virtual Serialize::Object *GetTarget() anope_abstract; virtual void SetTarget(Serialize::Object *) anope_abstract; @@ -24,6 +27,3 @@ class OperInfo : public Serialize::Object virtual time_t GetCreated() anope_abstract; virtual void SetCreated(const time_t &) anope_abstract; }; - -static Serialize::TypeReference operinfo("OperInfo"); - diff --git a/include/modules/operserv/news.h b/include/modules/operserv/news.h index 07627b1bc..43f7a1aaf 100644 --- a/include/modules/operserv/news.h +++ b/include/modules/operserv/news.h @@ -1,5 +1,13 @@ -#ifndef OS_NEWS -#define OS_NEWS +/* + * + * (C) 2016 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + * + */ + +#pragma once enum NewsType { @@ -11,6 +19,8 @@ enum NewsType class NewsItem : public Serialize::Object { public: + static constexpr const char *const NAME = "newsitem"; + using Serialize::Object::Object; virtual NewsType GetNewsType() anope_abstract; @@ -25,8 +35,3 @@ class NewsItem : public Serialize::Object virtual time_t GetTime() anope_abstract; virtual void SetTime(const time_t &) anope_abstract; }; - -static Serialize::TypeReference newsitem("NewsItem"); - -#endif // OS_NEWS - diff --git a/include/modules/operserv/session.h b/include/modules/operserv/session.h index b9afd196e..1afa9e48a 100644 --- a/include/modules/operserv/session.h +++ b/include/modules/operserv/session.h @@ -16,6 +16,7 @@ class Exception : public Serialize::Object using Serialize::Object::Object; public: + static constexpr const char *NAME = "exception"; virtual Anope::string GetMask() anope_abstract; virtual void SetMask(const Anope::string &) anope_abstract; @@ -36,14 +37,14 @@ class Exception : public Serialize::Object virtual void SetExpires(const time_t &) anope_abstract; }; -static Serialize::TypeReference exception("Exception"); - class SessionService : public Service { public: + static constexpr const char *NAME = "session"; + typedef std::unordered_map SessionMap; - SessionService(Module *m) : Service(m, "SessionService", "session") { } + SessionService(Module *m) : Service(m, NAME) { } virtual Exception *FindException(User *u) anope_abstract; @@ -54,12 +55,14 @@ class SessionService : public Service virtual SessionMap &GetSessions() anope_abstract; }; -static ServiceReference session_service("SessionService", "session"); - namespace Event { struct CoreExport Exception : Events { + static constexpr const char *NAME = "exception"; + + using Events::Events; + /** Called after an exception has been added * @param ex The exception * @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it @@ -74,4 +77,3 @@ namespace Event }; } -template<> struct EventName { static constexpr const char *const name = "Exception"; }; -- cgit