diff options
Diffstat (limited to 'src/base.cpp')
| -rw-r--r-- | src/base.cpp | 147 |
1 files changed, 0 insertions, 147 deletions
diff --git a/src/base.cpp b/src/base.cpp index 7ed53e04b..86261d0f8 100644 --- a/src/base.cpp +++ b/src/base.cpp @@ -66,153 +66,6 @@ void ServiceProvider::RegisterService() { } -ExtensionItem::ExtensionItem(Module* mod, const std::string& Key, ExtensibleType exttype) - : ServiceProvider(mod, Key, SERVICE_METADATA) - , type(exttype) -{ -} - -void* ExtensionItem::GetRaw(const Extensible* container) const -{ - Extensible::ExtensibleStore::const_iterator i = - container->extensions.find(const_cast<ExtensionItem*>(this)); - if (i == container->extensions.end()) - return NULL; - return i->second; -} - -void* ExtensionItem::SetRaw(Extensible* container, void* value) -{ - std::pair<Extensible::ExtensibleStore::iterator,bool> rv = - container->extensions.insert(std::make_pair(this, value)); - if (rv.second) - { - return NULL; - } - else - { - void* old = rv.first->second; - rv.first->second = value; - return old; - } -} - -void* ExtensionItem::UnsetRaw(Extensible* container) -{ - Extensible::ExtensibleStore::iterator i = container->extensions.find(this); - if (i == container->extensions.end()) - return NULL; - void* rv = i->second; - container->extensions.erase(i); - 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; -} - -void ExtensionManager::BeginUnregister(Module* module, std::vector<reference<ExtensionItem> >& list) -{ - ExtMap::iterator i = types.begin(); - while (i != types.end()) - { - ExtMap::iterator me = i++; - ExtensionItem* item = me->second; - if (item->creator == module) - { - list.push_back(item); - types.erase(me); - } - } -} - -ExtensionItem* ExtensionManager::GetItem(const std::string& name) -{ - ExtMap::iterator i = types.find(name); - if (i == types.end()) - return NULL; - return i->second; -} - -void Extensible::UnhookExtensions(const std::vector<reference<ExtensionItem>>& toRemove) -{ - for(std::vector<reference<ExtensionItem> >::const_iterator i = toRemove.begin(); i != toRemove.end(); ++i) - { - ExtensionItem* item = *i; - ExtensibleStore::iterator e = extensions.find(item); - if (e != extensions.end()) - { - item->Delete(this, e->second); - extensions.erase(e); - } - } -} - -Extensible::Extensible() - : culled(false) -{ -} - -Cullable::Result Extensible::Cull() -{ - FreeAllExtItems(); - culled = true; - return Cullable::Cull(); -} - -void Extensible::FreeAllExtItems() -{ - for(ExtensibleStore::iterator i = extensions.begin(); i != extensions.end(); ++i) - { - i->first->Delete(this, i->second); - } - extensions.clear(); -} - -Extensible::~Extensible() -{ - if ((!extensions.empty() || !culled) && ServerInstance) - ServerInstance->Logs.Log("CULLLIST", LOG_DEBUG, "Extensible destructor called without cull @%p", (void*)this); -} - -void ExtensionItem::FromInternal(Extensible* container, const std::string& value) noexcept -{ - FromNetwork(container, value); -} - -void ExtensionItem::FromNetwork(Extensible* container, const std::string& value) noexcept -{ -} - -std::string ExtensionItem::ToHuman(const Extensible* container, void* item) const noexcept -{ - // Try to use the network form by default. - std::string ret = ToNetwork(container, item); - - // If there's no network form then fall back to the internal form. - if (ret.empty()) - ret = ToInternal(container, item); - - return ret; -} - -std::string ExtensionItem::ToInternal(const Extensible* container, void* item) const noexcept -{ - return ToNetwork(container, item); -} - -std::string ExtensionItem::ToNetwork(const Extensible* container, void* item) const noexcept -{ - return std::string(); -} - ModuleException::ModuleException(const std::string &message, Module* who) : CoreException(message, who ? who->ModuleSourceFile : "A Module") { |
