1
0
mirror of https://github.com/anope/anope.git synced 2026-06-26 12:56:39 +02:00

Made service_reference type safe

This commit is contained in:
Adam
2011-08-25 16:21:21 -04:00
parent 8c4417cad1
commit f025d1b495
164 changed files with 86 additions and 374 deletions
-44
View File
@@ -9,7 +9,6 @@
#include "modules.h"
#include <algorithm> // std::find
std::map<Anope::string, Service *> ModuleManager::ServiceProviders;
std::vector<Module *> ModuleManager::EventHandlers[I_END];
void ModuleManager::CleanupRuntimeDirectory()
@@ -498,46 +497,3 @@ void ModuleManager::UnloadAll()
}
}
/** Register a service
* @oaram s The service
* @return true if it was successfully registeed, else false (service name colision)
*/
bool ModuleManager::RegisterService(Service *s)
{
return ModuleManager::ServiceProviders.insert(std::make_pair(s->name, s)).second;
}
/** Unregister a service
* @param s The service
* @return true if it was unregistered successfully
*/
bool ModuleManager::UnregisterService(Service *s)
{
return ModuleManager::ServiceProviders.erase(s->name);
}
/** Get a service
* @param name The service name
* @param s The service
* @return The service
*/
Service *ModuleManager::GetService(const Anope::string &name)
{
std::map<Anope::string, Service *>::const_iterator it = ModuleManager::ServiceProviders.find(name);
if (it != ModuleManager::ServiceProviders.end())
return it->second;
return NULL;
}
/** Get the existing service key names
* @return The keys
*/
std::vector<Anope::string> ModuleManager::GetServiceKeys()
{
std::vector<Anope::string> keys;
for (std::map<Anope::string, Service *>::const_iterator it = ModuleManager::ServiceProviders.begin(), it_end = ModuleManager::ServiceProviders.end(); it != it_end; ++it)
keys.push_back(it->first);
return keys;
}