diff options
author | Attila Molnar <attilamolnar@hush.com> | 2015-12-02 13:30:24 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2015-12-02 13:30:24 +0100 |
commit | 860f5cbf1ea159d7d1c3fce2364747a822c50461 (patch) | |
tree | cc4f7e8bb3efc944b8ce101c5db46162b31f2834 /src/modules.cpp | |
parent | 44b5a8fa89d8c2bda767c0d5fe77c4d31061ce2b (diff) | |
parent | 90ab8cf4258a25e8403465ed86296fc74405620d (diff) |
Merge branch 'master+serviceinit'
Diffstat (limited to 'src/modules.cpp')
-rw-r--r-- | src/modules.cpp | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/src/modules.cpp b/src/modules.cpp index 79a71652c..d77221c39 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -528,22 +528,6 @@ void ModuleManager::AddService(ServiceProvider& item) { switch (item.service) { - case SERVICE_COMMAND: - if (!ServerInstance->Parser.AddCommand(static_cast<Command*>(&item))) - throw ModuleException("Command "+std::string(item.name)+" already exists."); - return; - case SERVICE_MODE: - { - 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(); - return; - } - case SERVICE_METADATA: - if (!ServerInstance->Extensions.Register(static_cast<ExtensionItem*>(&item))) - throw ModuleException("Extension " + std::string(item.name) + " already exists."); - return; case SERVICE_DATA: case SERVICE_IOHOOK: { @@ -561,7 +545,7 @@ void ModuleManager::AddService(ServiceProvider& item) return; } default: - throw ModuleException("Cannot add unknown service type"); + item.RegisterService(); } } @@ -576,13 +560,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: @@ -674,3 +652,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(); +} |