summaryrefslogtreecommitdiff
path: root/include/modules/memoserv.h
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/memoserv.h
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/memoserv.h')
-rw-r--r--include/modules/memoserv.h34
1 files changed, 18 insertions, 16 deletions
diff --git a/include/modules/memoserv.h b/include/modules/memoserv.h
index b7d49ad3a..e84276039 100644
--- a/include/modules/memoserv.h
+++ b/include/modules/memoserv.h
@@ -17,6 +17,8 @@ namespace MemoServ
class MemoServService : public Service
{
public:
+ static constexpr const char *NAME = "memoserv";
+
enum MemoResult
{
MEMO_SUCCESS,
@@ -25,7 +27,7 @@ namespace MemoServ
MEMO_TARGET_FULL
};
- MemoServService(Module *m) : Service(m, "MemoServService", "MemoServ")
+ MemoServService(Module *m) : Service(m, "MemoServService", NAME)
{
}
@@ -42,17 +44,19 @@ namespace MemoServ
*/
virtual void Check(User *u) anope_abstract;
- virtual Memo *CreateMemo() anope_abstract;
virtual MemoInfo *GetMemoInfo(const Anope::string &targ, bool &is_registered, bool &is_chan, bool create) anope_abstract;
-
- virtual Ignore *CreateIgnore() anope_abstract;
};
- static ServiceReference<MemoServService> service("MemoServService", "MemoServ");
+
+ extern MemoServService *service;
namespace Event
{
struct CoreExport MemoSend : Events
{
+ static constexpr const char *NAME = "memosend";
+
+ using Events::Events;
+
/** Called when a memo is sent
* @param source The source of the memo
* @param target The target of the memo
@@ -61,10 +65,13 @@ namespace MemoServ
*/
virtual void OnMemoSend(const Anope::string &source, const Anope::string &target, MemoInfo *mi, Memo *m) anope_abstract;
};
- static EventHandlersReference<MemoSend> OnMemoSend;
struct CoreExport MemoDel : Events
{
+ static constexpr const char *NAME = "memodel";
+
+ using Events::Events;
+
/** Called when a memo is deleted
* @param target The target the memo is being deleted from (nick or channel)
* @param mi The memo info
@@ -72,7 +79,6 @@ namespace MemoServ
*/
virtual void OnMemoDel(const Anope::string &target, MemoInfo *mi, const Memo *m) anope_abstract;
};
- static EventHandlersReference<MemoDel> OnMemoDel;
}
class Memo : public Serialize::Object
@@ -81,6 +87,8 @@ namespace MemoServ
using Serialize::Object::Object;
public:
+ static constexpr const char *const NAME = "memo";
+
virtual MemoInfo *GetMemoInfo() anope_abstract;
virtual void SetMemoInfo(MemoInfo *) anope_abstract;
@@ -100,8 +108,6 @@ namespace MemoServ
virtual void SetReceipt(const bool &) anope_abstract;
};
- static Serialize::TypeReference<Memo> memo("Memo");
-
/* Memo info structures. Since both nicknames and channels can have memos,
* we encapsulate memo data in a MemoInfo to make it easier to handle.
*/
@@ -111,6 +117,7 @@ namespace MemoServ
using Serialize::Object::Object;
public:
+ static constexpr const char *const NAME = "memoinfo";
virtual Memo *GetMemo(unsigned index) anope_abstract;
@@ -130,23 +137,18 @@ namespace MemoServ
virtual std::vector<Ignore *> GetIgnores() anope_abstract;
};
- static Serialize::TypeReference<MemoInfo> memoinfo("MemoInfo");
-
class Ignore : public Serialize::Object
{
protected:
using Serialize::Object::Object;
public:
+ static constexpr const char *const NAME = "memoignore";
+
virtual MemoInfo *GetMemoInfo() anope_abstract;
virtual void SetMemoInfo(MemoInfo *) anope_abstract;
virtual Anope::string GetMask() anope_abstract;
virtual void SetMask(const Anope::string &mask) anope_abstract;
};
-
- static Serialize::TypeReference<Ignore> ignore("MemoIgnore");
}
-
-template<> struct EventName<MemoServ::Event::MemoSend> { static constexpr const char *const name = "OnMemoSend"; };
-template<> struct EventName<MemoServ::Event::MemoDel> { static constexpr const char *const name = "OnMemoDel"; };