summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2014-02-21 14:42:16 +0100
committerAttila Molnar <attilamolnar@hush.com>2014-02-21 14:42:16 +0100
commit1b6dda7ad54dd0242cd9eac30f167d76f061d2fa (patch)
treefa46b7bbfdcf5484d82e3984f0c55fc6537f3cfb /include
parent9e123ad1218e8c3ff29cee2a8a6e1b4b6f56b33b (diff)
Assign an id to user modes, parameter chanmodes and simple chanmodes
Diffstat (limited to 'include')
-rw-r--r--include/mode.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/include/mode.h b/include/mode.h
index d3fdabde1..d71423ecf 100644
--- a/include/mode.h
+++ b/include/mode.h
@@ -94,6 +94,8 @@ class ParamModeBase;
class CoreExport ModeHandler : public ServiceProvider
{
public:
+ typedef size_t Id;
+
enum Class
{
MC_PREFIX,
@@ -102,6 +104,11 @@ class CoreExport ModeHandler : public ServiceProvider
MC_OTHER
};
+ private:
+ /** The opaque id of this mode assigned by the mode parser
+ */
+ Id modeid;
+
protected:
/**
* The mode parameter translation type
@@ -213,6 +220,11 @@ class CoreExport ModeHandler : public ServiceProvider
*/
inline char GetModeChar() { return mode; }
+ /** Return the id of this mode which is used in User::modes and
+ * Channel::modes as the index to determine whether a mode is set.
+ */
+ Id GetId() const { return modeid; }
+
/** For user modes, return the current parameter, if any
*/
virtual std::string GetUserParameter(User* useor);
@@ -295,6 +307,8 @@ class CoreExport ModeHandler : public ServiceProvider
virtual void RemoveMode(Channel* channel, irc::modestacker& stack);
inline unsigned int GetLevelRequired() const { return levelrequired; }
+
+ friend class ModeParser;
};
/**
@@ -474,6 +488,9 @@ typedef std::multimap<std::string, ModeWatcher*>::iterator ModeWatchIter;
*/
class CoreExport ModeParser
{
+ public:
+ static const ModeHandler::Id MODEID_MAX = 64;
+
private:
/** Last item in the ModeType enum
*/
@@ -490,6 +507,10 @@ class CoreExport ModeParser
*/
ModeHandler* modehandlers[MODETYPE_LAST][128];
+ /** An array of mode handlers indexed by the mode id
+ */
+ ModeHandler* modehandlersbyid[MODETYPE_LAST][MODEID_MAX];
+
/** A map of mode handlers keyed by their name
*/
ModeHandlerMap modehandlersbyname[MODETYPE_LAST];
@@ -539,6 +560,12 @@ class CoreExport ModeParser
*/
void RecreateModeListFor004Numeric();
+ /** Allocates an unused id for the given mode type, throws a ModuleException if out of ids.
+ * @param mt The type of the mode to allocate the id for
+ * @return The id
+ */
+ ModeHandler::Id AllocateModeId(ModeType mt);
+
/** The string representing the last set of modes to be parsed.
* Use GetLastParse() to get this value, to be used for display purposes.
*/