From 5e9a6b9186a8cbaaf65ae7d9cd9c0c033c91b497 Mon Sep 17 00:00:00 2001 From: brain Date: Fri, 29 Dec 2006 23:34:47 +0000 Subject: Add counter system for umodes to get rid of some O(n) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6163 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/inspircd.h | 4 ++++ include/mode.h | 7 +++++++ include/modes/umode_i.h | 1 + include/modes/umode_o.h | 1 + include/modes/umode_s.h | 1 + include/modes/umode_w.h | 1 + 6 files changed, 15 insertions(+) (limited to 'include') diff --git a/include/inspircd.h b/include/inspircd.h index d3d424384..006e8092e 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -494,6 +494,10 @@ class InspIRCd : public classbase void AddGlobalClone(userrec* user); + /** Number of users with a certain mode set on them + */ + int ModeCount(const char mode); + /** Get the time offset in seconds * @return The current time delta (in seconds) */ diff --git a/include/mode.h b/include/mode.h index b3c580e6c..62374be6c 100644 --- a/include/mode.h +++ b/include/mode.h @@ -132,6 +132,10 @@ class ModeHandler : public Extensible */ char prefix; + /** Number of items with this mode set on them + */ + static unsigned int count; + public: /** * The constructor for ModeHandler initalizes the mode handler. @@ -164,6 +168,9 @@ class ModeHandler : public Extensible * value for this mode prefix. */ char GetPrefix(); + /** Get number of items with this mode set on them + */ + virtual unsigned int GetCount(); /** * Get the 'value' of this modes prefix. * determines which to display when there are multiple. diff --git a/include/modes/umode_i.h b/include/modes/umode_i.h index c8e33b492..cc7d15102 100644 --- a/include/modes/umode_i.h +++ b/include/modes/umode_i.h @@ -22,4 +22,5 @@ class ModeUserInvisible : public ModeHandler public: ModeUserInvisible(InspIRCd* Instance); ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding); + unsigned int GetCount(); }; diff --git a/include/modes/umode_o.h b/include/modes/umode_o.h index 4fe6f6b96..7dfdb4128 100644 --- a/include/modes/umode_o.h +++ b/include/modes/umode_o.h @@ -22,4 +22,5 @@ class ModeUserOperator : public ModeHandler public: ModeUserOperator(InspIRCd* Instance); ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding); + unsigned int GetCount(); }; diff --git a/include/modes/umode_s.h b/include/modes/umode_s.h index 297b49c67..cda223eee 100644 --- a/include/modes/umode_s.h +++ b/include/modes/umode_s.h @@ -22,4 +22,5 @@ class ModeUserServerNotice : public ModeHandler public: ModeUserServerNotice(InspIRCd* Instance); ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding); + unsigned int GetCount(); }; diff --git a/include/modes/umode_w.h b/include/modes/umode_w.h index b1f6e94c7..271e959c4 100644 --- a/include/modes/umode_w.h +++ b/include/modes/umode_w.h @@ -22,4 +22,5 @@ class ModeUserWallops : public ModeHandler public: ModeUserWallops(InspIRCd* Instance); ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding); + unsigned int GetCount(); }; -- cgit v1.2.3