summaryrefslogtreecommitdiff
path: root/src/extensible.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2014-11-24 14:27:23 -0500
committerAdam <Adam@anope.org>2014-11-24 14:27:23 -0500
commit42238034490fb5479d787bd1695750387d508200 (patch)
treec93c62e0e1c936e656ae5b9ee1b62380ce2a194c /src/extensible.cpp
parentd492923610d9c9146b2a2b63de38deab2cfd4ca7 (diff)
Rewrite serializable to have field level granularity
Represent serializable objects in a digraph, and as a result made most object relationships implicitly defined, and use the graph to trace references between objects to determine relationships. Edges may also be marked as having a dependency of the object they point to, which allows for automatic cleanup and deletion of most objects when no longer needed. Additionally, this allows not having to require in-memory copies of everything when using external databases. db_sql has been rewritten for this and now always requires a database to function. db_sql with MySQL now requires InnoDB to make use of transactions and foreign key constraints.
Diffstat (limited to 'src/extensible.cpp')
-rw-r--r--src/extensible.cpp41
1 files changed, 6 insertions, 35 deletions
diff --git a/src/extensible.cpp b/src/extensible.cpp
index 37206f7c1..e0e35e6ea 100644
--- a/src/extensible.cpp
+++ b/src/extensible.cpp
@@ -10,25 +10,25 @@
#include "extensible.h"
-static std::set<ExtensibleBase *> extensible_items;
+ExtensibleBase::ExtensibleBase(Module *m, const Anope::string &n) : ExtensibleBase(m, "Extensible", n)
+{
+}
-ExtensibleBase::ExtensibleBase(Module *m, const Anope::string &n) : Service(m, "Extensible", n)
+ExtensibleBase::ExtensibleBase(Module *m, const Anope::string &t, const Anope::string &n) : Service(m, t, n)
{
- extensible_items.insert(this);
}
ExtensibleBase::~ExtensibleBase()
{
- extensible_items.erase(this);
}
Extensible::~Extensible()
{
while (!extension_items.empty())
- (*extension_items.begin())->Unset(this);
+ extension_items[0]->Unset(this);
}
-bool Extensible::HasExt(const Anope::string &name) const
+bool Extensible::HasExtOK(const Anope::string &name)
{
ExtensibleRef<void *> ref(name);
if (ref)
@@ -38,32 +38,3 @@ bool Extensible::HasExt(const Anope::string &name) const
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 nonexistant type " << name << " on " << static_cast<void *>(this);
- return NULL;
-}
-