diff options
-rw-r--r-- | include/extensible.h | 4 | ||||
-rw-r--r-- | src/base.cpp | 6 | ||||
-rw-r--r-- | src/modules.cpp | 4 |
3 files changed, 10 insertions, 4 deletions
diff --git a/include/extensible.h b/include/extensible.h index a2c104377..3453f3e15 100644 --- a/include/extensible.h +++ b/include/extensible.h @@ -69,6 +69,10 @@ class CoreExport ExtensionItem : public ServiceProvider, public usecountbase /** Free the item */ virtual void free(void* item) = 0; + /** Register this object in the ExtensionManager + */ + void RegisterService() CXX11_OVERRIDE; + protected: /** Get the item from the internal map */ void* get_raw(const Extensible* container) const; diff --git a/src/base.cpp b/src/base.cpp index 63b14256e..4111451f8 100644 --- a/src/base.cpp +++ b/src/base.cpp @@ -144,6 +144,12 @@ void* ExtensionItem::unset_raw(Extensible* container) return rv; } +void ExtensionItem::RegisterService() +{ + if (!ServerInstance->Extensions.Register(this)) + throw ModuleException("Extension already exists: " + name); +} + bool ExtensionManager::Register(ExtensionItem* item) { return types.insert(std::make_pair(item->name, item)).second; diff --git a/src/modules.cpp b/src/modules.cpp index f5998f79c..ca13dad73 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -556,10 +556,6 @@ void ModuleManager::AddService(ServiceProvider& item) { switch (item.service) { - 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: { |