summaryrefslogtreecommitdiff
path: root/include/modules/chanserv
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2016-07-28 21:29:35 -0400
committerAdam <Adam@anope.org>2016-07-28 21:29:35 -0400
commit0e758a2ac23dc4a001e8e126cec14588da9a9769 (patch)
tree45df813323e023c5c89db7279426c4ad0943b4a9 /include/modules/chanserv
parenta3c8afae00c54d5b95c620248b51f90679d7d53f (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/chanserv')
-rw-r--r--include/modules/chanserv/access.h42
-rw-r--r--include/modules/chanserv/akick.h11
-rw-r--r--include/modules/chanserv/drop.h5
-rw-r--r--include/modules/chanserv/entrymsg.h5
-rw-r--r--include/modules/chanserv/info.h5
-rw-r--r--include/modules/chanserv/log.h11
-rw-r--r--include/modules/chanserv/main/chanaccess.h31
-rw-r--r--include/modules/chanserv/mode.h22
-rw-r--r--include/modules/chanserv/set.h6
-rw-r--r--include/modules/chanserv/set_misc.h7
-rw-r--r--include/modules/chanserv/suspend.h17
11 files changed, 120 insertions, 42 deletions
diff --git a/include/modules/chanserv/access.h b/include/modules/chanserv/access.h
index 54eb3f353..35fad81d3 100644
--- a/include/modules/chanserv/access.h
+++ b/include/modules/chanserv/access.h
@@ -7,14 +7,16 @@
*
*/
-static Serialize::TypeReference<ChanServ::ChanAccess> accesschanaccess("AccessChanAccess");
-static Serialize::TypeReference<ChanServ::ChanAccess> flagschanaccess("FlagsChanAccess");
-static Serialize::TypeReference<ChanServ::ChanAccess> xopchanaccess("XOPChanAccess");
+#include "main/chanaccess.h"
namespace Event
{
struct CoreExport LevelChange : Events
{
+ static constexpr const char *NAME = "levelchange";
+
+ using Events::Events;
+
/** Called when a level for a channel is changed
* @param source The source of the command
* @param ci The channel the level was changed on
@@ -25,4 +27,36 @@ namespace Event
};
}
-template<> struct EventName<Event::LevelChange> { static constexpr const char *const name = "OnLevelChange"; };
+class AccessChanAccess : public ChanAccessImpl
+{
+ public:
+ static constexpr const char *NAME = "accesschanaccess";
+
+ using ChanAccessImpl::ChanAccessImpl;
+
+ virtual int GetLevel() anope_abstract;
+ virtual void SetLevel(const int &) anope_abstract;
+};
+
+class XOPChanAccess : public ChanAccessImpl
+{
+ public:
+ static constexpr const char *NAME = "xopchanaccess";
+
+ using ChanAccessImpl::ChanAccessImpl;
+
+ virtual const Anope::string &GetType() anope_abstract;
+ virtual void SetType(const Anope::string &) anope_abstract;
+};
+
+class FlagsChanAccess : public ChanAccessImpl
+{
+ public:
+ static constexpr const char *NAME = "flagschanaccess";
+
+ using ChanAccessImpl::ChanAccessImpl;
+
+ virtual const Anope::string &GetFlags() anope_abstract;
+ virtual void SetFlags(const Anope::string &) anope_abstract;
+};
+
diff --git a/include/modules/chanserv/akick.h b/include/modules/chanserv/akick.h
index 966dac15b..cc7f0aaec 100644
--- a/include/modules/chanserv/akick.h
+++ b/include/modules/chanserv/akick.h
@@ -1,6 +1,6 @@
/*
*
- * (C) 2014 Anope Team
+ * (C) 2014-2016 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
@@ -15,6 +15,8 @@ class CoreExport AutoKick : public Serialize::Object
protected:
using Serialize::Object::Object;
public:
+ static constexpr const char *const NAME = "akick";
+
virtual ~AutoKick() = default;
virtual ChanServ::Channel *GetChannel() anope_abstract;
@@ -39,12 +41,14 @@ class CoreExport AutoKick : public Serialize::Object
virtual void SetLastUsed(const time_t &) anope_abstract;
};
-static Serialize::TypeReference<AutoKick> autokick("AutoKick");
-
namespace Event
{
struct CoreExport Akick : Events
{
+ static constexpr const char *NAME = "akick";
+
+ using Events::Events;
+
/** Called after adding an akick to a channel
* @param source The source of the command
* @param ci The channel
@@ -61,4 +65,3 @@ namespace Event
};
}
-template<> struct EventName<Event::Akick> { static constexpr const char *const name = "Akick"; };
diff --git a/include/modules/chanserv/drop.h b/include/modules/chanserv/drop.h
index db231059b..50f2627c2 100644
--- a/include/modules/chanserv/drop.h
+++ b/include/modules/chanserv/drop.h
@@ -11,6 +11,10 @@ namespace Event
{
struct CoreExport ChanDrop : Events
{
+ static constexpr const char *NAME = "chandrop";
+
+ using Events::Events;
+
/** Called right before a channel is dropped
* @param source The user dropping the channel
* @param ci The channel
@@ -19,4 +23,3 @@ namespace Event
};
}
-template<> struct EventName<Event::ChanDrop> { static constexpr const char *const name = "OnChanDrop"; };
diff --git a/include/modules/chanserv/entrymsg.h b/include/modules/chanserv/entrymsg.h
index b5804068f..452057509 100644
--- a/include/modules/chanserv/entrymsg.h
+++ b/include/modules/chanserv/entrymsg.h
@@ -1,5 +1,5 @@
/*
- * (C) 2003-2014 Anope Team
+ * (C) 2003-2016 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
@@ -12,6 +12,8 @@ class EntryMsg : public Serialize::Object
using Serialize::Object::Object;
public:
+ static constexpr const char *const NAME = "entrymsg";
+
virtual ChanServ::Channel *GetChannel() anope_abstract;
virtual void SetChannel(ChanServ::Channel *) anope_abstract;
@@ -25,5 +27,4 @@ class EntryMsg : public Serialize::Object
virtual void SetWhen(const time_t &) anope_abstract;
};
-static Serialize::TypeReference<EntryMsg> entrymsg("EntryMsg");
diff --git a/include/modules/chanserv/info.h b/include/modules/chanserv/info.h
index f80e3daf2..d487e3075 100644
--- a/include/modules/chanserv/info.h
+++ b/include/modules/chanserv/info.h
@@ -11,6 +11,10 @@ namespace Event
{
struct CoreExport ChanInfo : Events
{
+ static constexpr const char *NAME = "chaninfo";
+
+ using Events::Events;
+
/** Called when a user requests info for a channel
* @param source The user requesting info
* @param ci The channel the user is requesting info for
@@ -21,4 +25,3 @@ namespace Event
};
}
-template<> struct EventName<Event::ChanInfo> { static constexpr const char *const name = "OnChanInfo"; };
diff --git a/include/modules/chanserv/log.h b/include/modules/chanserv/log.h
index d940f5e87..b579a05ed 100644
--- a/include/modules/chanserv/log.h
+++ b/include/modules/chanserv/log.h
@@ -1,12 +1,10 @@
/* ChanServ 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 LogSetting : public Serialize::Object
@@ -15,6 +13,8 @@ class LogSetting : public Serialize::Object
using Serialize::Object::Object;
public:
+ static constexpr const char *const NAME = "logsetting";
+
virtual ChanServ::Channel *GetChannel() anope_abstract;
virtual void SetChannel(ChanServ::Channel *) anope_abstract;
@@ -39,6 +39,3 @@ class LogSetting : public Serialize::Object
virtual time_t GetCreated() anope_abstract;
virtual void SetCreated(const time_t &) anope_abstract;
};
-
-static Serialize::TypeReference<LogSetting> logsetting("LogSetting");
-
diff --git a/include/modules/chanserv/main/chanaccess.h b/include/modules/chanserv/main/chanaccess.h
new file mode 100644
index 000000000..7a297c405
--- /dev/null
+++ b/include/modules/chanserv/main/chanaccess.h
@@ -0,0 +1,31 @@
+#pragma once
+
+class ChanAccessImpl : public ChanServ::ChanAccess
+{
+ public:
+ ChanAccessImpl(Serialize::TypeBase *type) : ChanServ::ChanAccess(type) { }
+ ChanAccessImpl(Serialize::TypeBase *type, Serialize::ID id) : ChanServ::ChanAccess(type, id) { }
+
+ ChanServ::Channel *GetChannel() override;
+ void SetChannel(ChanServ::Channel *ci) override;
+
+ Anope::string GetCreator() override;
+ void SetCreator(const Anope::string &c) override;
+
+ time_t GetLastSeen() override;
+ void SetLastSeen(const time_t &t) override;
+
+ time_t GetCreated() override;
+ void SetCreated(const time_t &t) override;
+
+ Anope::string GetMask() override;
+ void SetMask(const Anope::string &) override;
+
+ Serialize::Object *GetObj() override;
+ void SetObj(Serialize::Object *) override;
+
+ Anope::string Mask() override;
+ NickServ::Account *GetAccount() override;
+
+ bool Matches(const User *u, NickServ::Account *acc) override;
+};
diff --git a/include/modules/chanserv/mode.h b/include/modules/chanserv/mode.h
index 4c7965e2a..78b7d861f 100644
--- a/include/modules/chanserv/mode.h
+++ b/include/modules/chanserv/mode.h
@@ -1,12 +1,10 @@
/* ChanServ 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 ModeLock : public Serialize::Object
@@ -15,6 +13,8 @@ class ModeLock : public Serialize::Object
using Serialize::Object::Object;
public:
+ static constexpr const char *const NAME = "modelock";
+
virtual ChanServ::Channel *GetChannel() anope_abstract;
virtual void SetChannel(ChanServ::Channel *) anope_abstract;
@@ -34,12 +34,12 @@ class ModeLock : public Serialize::Object
virtual void SetCreated(const time_t &) anope_abstract;
};
-static Serialize::TypeReference<ModeLock> modelock("ModeLock");
-
class ModeLocks : public Service
{
public:
- ModeLocks(Module *me) : Service(me, "ModeLocks", "mlocks") { }
+ static constexpr const char *NAME = "mlocks";
+
+ ModeLocks(Module *me) : Service(me, NAME) { }
typedef std::vector<ModeLock *> ModeList;
@@ -98,12 +98,14 @@ class ModeLocks : public Service
virtual Anope::string GetMLockAsString(ChanServ::Channel *, bool complete) const anope_abstract;
};
-static ServiceReference<ModeLocks> mlocks("ModeLocks", "mlocks");
-
namespace Event
{
struct CoreExport MLockEvents : Events
{
+ static constexpr const char *NAME = "mlockevents";
+
+ using Events::Events;
+
/** Called when a mode is about to be mlocked
* @param ci The channel the mode is being locked on
* @param lock The mode lock
@@ -119,5 +121,3 @@ namespace Event
virtual EventReturn OnUnMLock(ChanServ::Channel *ci, ModeLock *lock) anope_abstract;
};
}
-
-template<> struct EventName<Event::MLockEvents> { static constexpr const char *const name = "MLock"; };
diff --git a/include/modules/chanserv/set.h b/include/modules/chanserv/set.h
index a0e81c888..1c5de3227 100644
--- a/include/modules/chanserv/set.h
+++ b/include/modules/chanserv/set.h
@@ -11,6 +11,10 @@ namespace Event
{
struct CoreExport SetChannelOption : Events
{
+ static constexpr const char *NAME = "setchanneloption";
+
+ using Events::Events;
+
/** Called when a chanserv/set command is used
* @param source The source of the command
* @param cmd The command
@@ -20,7 +24,5 @@ namespace Event
*/
virtual EventReturn OnSetChannelOption(CommandSource &source, Command *cmd, ChanServ::Channel *ci, const Anope::string &setting) anope_abstract;
};
- static EventHandlersReference<SetChannelOption> OnSetChannelOption;
}
-template<> struct EventName<Event::SetChannelOption> { static constexpr const char *const name = "OnSetChannelOption"; };
diff --git a/include/modules/chanserv/set_misc.h b/include/modules/chanserv/set_misc.h
index 65b92cc89..bdde80213 100644
--- a/include/modules/chanserv/set_misc.h
+++ b/include/modules/chanserv/set_misc.h
@@ -1,5 +1,5 @@
/*
- * (C) 2014 Anope Team
+ * (C) 2014-2016 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
@@ -11,6 +11,8 @@ class CSMiscData : public Serialize::Object
using Serialize::Object::Object;
public:
+ static constexpr const char *const NAME = "csmiscdata";
+
virtual ChanServ::Channel *GetChannel() anope_abstract;
virtual void SetChannel(ChanServ::Channel *) anope_abstract;
@@ -20,6 +22,3 @@ class CSMiscData : public Serialize::Object
virtual Anope::string GetData() anope_abstract;
virtual void SetData(const Anope::string &) anope_abstract;
};
-
-static Serialize::TypeReference<CSMiscData> csmiscdata("CSMiscData");
-
diff --git a/include/modules/chanserv/suspend.h b/include/modules/chanserv/suspend.h
index 27187ea09..93702c107 100644
--- a/include/modules/chanserv/suspend.h
+++ b/include/modules/chanserv/suspend.h
@@ -1,5 +1,5 @@
/*
- * (C) 2014 Anope Team
+ * (C) 2014-2016 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
@@ -12,6 +12,8 @@ class CSSuspendInfo : public Serialize::Object
using Serialize::Object::Object;
public:
+ static constexpr const char *const NAME = "cssuspendinfo";
+
virtual ChanServ::Channel *GetChannel() anope_abstract;
virtual void SetChannel(ChanServ::Channel *) anope_abstract;
@@ -28,12 +30,14 @@ class CSSuspendInfo : public Serialize::Object
virtual void SetExpires(const time_t &) anope_abstract;
};
-static Serialize::TypeReference<CSSuspendInfo> cssuspendinfo("CSSuspendInfo");
-
namespace Event
{
struct CoreExport ChanSuspend : Events
{
+ static constexpr const char *NAME = "chansuspend";
+
+ using Events::Events;
+
/** Called when a channel is suspended
* @param ci The channel
*/
@@ -41,13 +45,14 @@ namespace Event
};
struct CoreExport ChanUnsuspend : Events
{
+ static constexpr const char *NAME = "chanunsuspend";
+
+ using Events::Events;
+
/** Called when a channel is unsuspended
* @param ci The channel
*/
virtual void OnChanUnsuspend(ChanServ::Channel *ci) anope_abstract;
};
- extern CoreExport EventHandlers<ChanUnsuspend> OnChanUnsuspend;
}
-template<> struct EventName<Event::ChanSuspend> { static constexpr const char *const name = "OnChanSuspend"; };
-template<> struct EventName<Event::ChanUnsuspend> { static constexpr const char *const name = "OnChanUnsuspend"; };