summaryrefslogtreecommitdiff
path: root/src/channels.cpp
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2014-02-15 14:38:24 +0100
committerAttila Molnar <attilamolnar@hush.com>2014-02-15 14:38:24 +0100
commit0556720b559d7ec5d8badacf0ac9b11e9c864847 (patch)
tree0435a0e5b8e722fe35afb3f820f804bec8c0c7b2 /src/channels.cpp
parent88baaf9e68efd9824b906a69320053734d408e14 (diff)
Add ParamModeBase and ParamMode, change all parameter modes to inherit from ParamMode
- Type of the extension used to store data is a template parameter - The extension is automatically unset when the mode is unset - Handlers inheriting from ParamMode have to provide OnSet() and SerializeParam(); may optionally provide OnUnset() - Transparently handle the case when OnSet() modifies the mode parameter - Remove Channel::custom_mode_params map; ask the mode handlers to serialize their parameters instead
Diffstat (limited to 'src/channels.cpp')
-rw-r--r--src/channels.cpp35
1 files changed, 6 insertions, 29 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index a8f8db43c..448764e1c 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -51,29 +51,6 @@ void Channel::SetMode(ModeHandler* mh, bool on)
modes[mh->GetModeChar() - 65] = on;
}
-void Channel::SetModeParam(ModeHandler* mh, const std::string& parameter)
-{
- char mode = mh->GetModeChar();
- if (parameter.empty())
- {
- custom_mode_params.erase(mode);
- modes[mode-65] = false;
- }
- else
- {
- custom_mode_params[mode] = parameter;
- modes[mode-65] = true;
- }
-}
-
-std::string Channel::GetModeParameter(ModeHandler* mode)
-{
- CustomModeList::iterator n = custom_mode_params.find(mode->GetModeChar());
- if (n != custom_mode_params.end())
- return n->second;
- return "";
-}
-
void Channel::SetTopic(User* u, const std::string& ntopic)
{
this->topic.assign(ntopic, 0, ServerInstance->Config->Limits.MaxTopic);
@@ -628,18 +605,18 @@ const char* Channel::ChanModes(bool showkey)
if (!mh)
continue;
+ ParamModeBase* pm = mh->IsParameterMode();
+ if (!pm)
+ continue;
+
if (n == 'k' - 65 && !showkey)
{
sparam += " <key>";
}
else
{
- const std::string param = this->GetModeParameter(mh);
- if (!param.empty())
- {
- sparam += ' ';
- sparam += param;
- }
+ sparam += ' ';
+ pm->GetParameter(this, sparam);
}
}
}