summaryrefslogtreecommitdiff
path: root/src/modules.cpp
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2015-11-23 12:46:59 +0100
committerAttila Molnar <attilamolnar@hush.com>2015-11-23 12:46:59 +0100
commita39bd397cd0052dd8e23ba5c4c5dfc9b3a11a70c (patch)
tree4d54899c2f0e2e1d1690a6e468c4cc87f7bb9719 /src/modules.cpp
parentbbc6a0bbbe7475e5e1d0c4f2418c6fe6e0e952b7 (diff)
Extract code that manipulates the ModuleManager::DataProviders map into methods
Diffstat (limited to 'src/modules.cpp')
-rw-r--r--src/modules.cpp30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/modules.cpp b/src/modules.cpp
index 9e653a4ab..0223d12f1 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -564,8 +564,7 @@ void ModuleManager::AddService(ServiceProvider& item)
{
ModeHandler* mh = static_cast<ModeHandler*>(&item);
ServerInstance->Modes->AddMode(mh);
- DataProviders.insert(std::make_pair((mh->GetModeType() == MODETYPE_CHANNEL ? "mode/" : "umode/") + item.name, &item));
- dynamic_reference_base::reset_all();
+ AddReferent((mh->GetModeType() == MODETYPE_CHANNEL ? "mode/" : "umode/") + item.name, &item);
return;
}
case SERVICE_METADATA:
@@ -604,13 +603,7 @@ void ModuleManager::DelService(ServiceProvider& item)
case SERVICE_DATA:
case SERVICE_IOHOOK:
{
- for(std::multimap<std::string, ServiceProvider*>::iterator i = DataProviders.begin(); i != DataProviders.end(); )
- {
- std::multimap<std::string, ServiceProvider*>::iterator curr = i++;
- if (curr->second == &item)
- DataProviders.erase(curr);
- }
- dynamic_reference_base::reset_all();
+ DelReferent(&item);
return;
}
default:
@@ -702,3 +695,22 @@ Module* ModuleManager::Find(const std::string &name)
else
return modfind->second;
}
+
+void ModuleManager::AddReferent(const std::string& name, ServiceProvider* service)
+{
+ DataProviders.insert(std::make_pair(name, service));
+ dynamic_reference_base::reset_all();
+}
+
+void ModuleManager::DelReferent(ServiceProvider* service)
+{
+ for (std::multimap<std::string, ServiceProvider*>::iterator i = DataProviders.begin(); i != DataProviders.end(); )
+ {
+ ServiceProvider* curr = i->second;
+ if (curr == service)
+ DataProviders.erase(i++);
+ else
+ ++i;
+ }
+ dynamic_reference_base::reset_all();
+}