diff options
Diffstat (limited to 'src/extensible.cpp')
-rw-r--r-- | src/extensible.cpp | 63 |
1 files changed, 18 insertions, 45 deletions
diff --git a/src/extensible.cpp b/src/extensible.cpp index 485ac7fb7..597e23cf8 100644 --- a/src/extensible.cpp +++ b/src/extensible.cpp @@ -1,72 +1,45 @@ /* + * Anope IRC Services * - * (C) 2003-2017 Anope Team - * Contact us at team@anope.org + * Copyright (C) 2013-2017 Anope Team <team@anope.org> * - * Please read COPYING and README for further details. + * This file is part of Anope. Anope is free software; you can + * redistribute it and/or modify it under the terms of the GNU + * General Public License as published by the Free Software + * Foundation, version 2. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see see <http://www.gnu.org/licenses/>. */ #include "extensible.h" -static std::set<ExtensibleBase *> extensible_items; - -ExtensibleBase::ExtensibleBase(Module *m, const Anope::string &n) : Service(m, "Extensible", n) +ExtensibleBase::ExtensibleBase(Module *m, const Anope::string &n) : ExtensibleBase(m, "Extensible", n) { - extensible_items.insert(this); } -ExtensibleBase::~ExtensibleBase() +ExtensibleBase::ExtensibleBase(Module *m, const Anope::string &t, const Anope::string &n) : Service(m, t, n) { - extensible_items.erase(this); } Extensible::~Extensible() { - UnsetExtensibles(); -} - -void Extensible::UnsetExtensibles() -{ while (!extension_items.empty()) (*extension_items.begin())->Unset(this); } -bool Extensible::HasExt(const Anope::string &name) const +bool Extensible::HasExtOK(const Anope::string &name) { ExtensibleRef<void *> ref(name); if (ref) return ref->HasExt(this); - Log(LOG_DEBUG) << "HasExt for nonexistent type " << name << " on " << static_cast<const void *>(this); + Anope::Logger.Debug("HasExt for nonexistent type {0} on {1}", name, static_cast<const void *>(this)); return false; } -void Extensible::ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) -{ - for (std::set<ExtensibleBase *>::iterator it = e->extension_items.begin(); it != e->extension_items.end(); ++it) - { - ExtensibleBase *eb = *it; - eb->ExtensibleSerialize(e, s, data); - } -} - -void Extensible::ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) -{ - for (std::set<ExtensibleBase *>::iterator it = extensible_items.begin(); it != extensible_items.end(); ++it) - { - ExtensibleBase *eb = *it; - eb->ExtensibleUnserialize(e, s, data); - } -} - -template<> -bool* Extensible::Extend(const Anope::string &name, const bool &what) -{ - ExtensibleRef<bool> ref(name); - if (ref) - return ref->Set(this); - - Log(LOG_DEBUG) << "Extend for non-existent type " << name << " on " << static_cast<void *>(this); - return NULL; -} - |