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/operserv | |
| 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/operserv')
| -rw-r--r-- | include/modules/operserv/defcon.h | 5 | ||||
| -rw-r--r-- | include/modules/operserv/dns.h | 15 | ||||
| -rw-r--r-- | include/modules/operserv/forbid.h | 12 | ||||
| -rw-r--r-- | include/modules/operserv/ignore.h | 13 | ||||
| -rw-r--r-- | include/modules/operserv/info.h | 8 | ||||
| -rw-r--r-- | include/modules/operserv/news.h | 19 | ||||
| -rw-r--r-- | include/modules/operserv/session.h | 14 |
7 files changed, 49 insertions, 37 deletions
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<Event::DefconLevel> { 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("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("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("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("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<ForbidData *> GetForbids() anope_abstract; }; -static ServiceReference<ForbidService> forbid_service("ForbidService", "forbid"); - -static Serialize::TypeReference<ForbidData> 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<Ignore> 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<IgnoreService> 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("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("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("Exception"); - class SessionService : public Service { public: + static constexpr const char *NAME = "session"; + typedef std::unordered_map<cidr, Session *, cidr::hash> 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<SessionService> 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<Event::Exception> { static constexpr const char *const name = "Exception"; }; |
