diff options
Diffstat (limited to 'modules/database/db_sql.cpp')
-rw-r--r-- | modules/database/db_sql.cpp | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/modules/database/db_sql.cpp b/modules/database/db_sql.cpp index b56f884f6..5d213cb9a 100644 --- a/modules/database/db_sql.cpp +++ b/modules/database/db_sql.cpp @@ -18,12 +18,12 @@ class SQLSQLInterface : public Interface public: SQLSQLInterface(Module *o) : Interface(o) { } - void OnResult(const Result &r) anope_override + void OnResult(const Result &r) override { Log(LOG_DEBUG) << "SQL successfully executed query: " << r.finished_query; } - void OnError(const Result &r) anope_override + void OnError(const Result &r) override { if (!r.GetQuery().query.empty()) Log(LOG_DEBUG) << "Error executing query " << r.finished_query << ": " << r.GetError(); @@ -39,7 +39,7 @@ class ResultSQLSQLInterface : public SQLSQLInterface public: ResultSQLSQLInterface(Module *o, Serializable *ob) : SQLSQLInterface(o), obj(ob) { } - void OnResult(const Result &r) anope_override + void OnResult(const Result &r) override { SQLSQLInterface::OnResult(r); if (r.GetID() > 0 && this->obj) @@ -47,7 +47,7 @@ public: delete this; } - void OnError(const Result &r) anope_override + void OnError(const Result &r) override { SQLSQLInterface::OnError(r); delete this; @@ -55,6 +55,13 @@ public: }; class DBSQL : public Module, public Pipe + , public EventHook<Event::Shutdown> + , public EventHook<Event::Restart> + , public EventHook<Event::LoadDatabase> + , public EventHook<Event::SerializableConstruct> + , public EventHook<Event::SerializableDestruct> + , public EventHook<Event::SerializableUpdate> + , public EventHook<Event::SerializeTypeCreate> { ServiceReference<Provider> sql; SQLSQLInterface sqlinterface; @@ -89,7 +96,19 @@ class DBSQL : public Module, public Pipe } public: - DBSQL(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, DATABASE | VENDOR), sql("", ""), sqlinterface(this), shutting_down(false), loading_databases(false), loaded(false), imported(false) + DBSQL(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, DATABASE | VENDOR) + , EventHook<Event::Shutdown>("OnShutdown") + , EventHook<Event::Restart>("OnRestart") + , EventHook<Event::LoadDatabase>("OnLoadDatabase") + , EventHook<Event::SerializableConstruct>("OnSerializableConstruct") + , EventHook<Event::SerializableDestruct>("OnSerializableDestruct") + , EventHook<Event::SerializableUpdate>("OnSerializableUpdate") + , EventHook<Event::SerializeTypeCreate>("OnSerializeTypeCreate") + , sqlinterface(this) + , shutting_down(false) + , loading_databases(false) + , loaded(false) + , imported(false) { @@ -97,7 +116,7 @@ class DBSQL : public Module, public Pipe throw ModuleException("db_sql can not be loaded after db_sql_live"); } - void OnNotify() anope_override + void OnNotify() override { for (std::set<Serializable *>::iterator it = this->updated_items.begin(), it_end = this->updated_items.end(); it != it_end; ++it) { @@ -144,7 +163,7 @@ class DBSQL : public Module, public Pipe this->imported = true; } - void OnReload(Configuration::Conf *conf) anope_override + void OnReload(Configuration::Conf *conf) override { Configuration::Block *block = conf->GetModule(this); this->sql = ServiceReference<Provider>("SQL::Provider", block->Get<const Anope::string>("engine")); @@ -152,18 +171,18 @@ class DBSQL : public Module, public Pipe this->import = block->Get<bool>("import"); } - void OnShutdown() anope_override + void OnShutdown() override { this->shutting_down = true; this->OnNotify(); } - void OnRestart() anope_override + void OnRestart() override { this->OnShutdown(); } - EventReturn OnLoadDatabase() anope_override + EventReturn OnLoadDatabase() override { if (!this->sql) { @@ -186,7 +205,7 @@ class DBSQL : public Module, public Pipe return EVENT_STOP; } - void OnSerializableConstruct(Serializable *obj) anope_override + void OnSerializableConstruct(Serializable *obj) override { if (this->shutting_down || this->loading_databases) return; @@ -195,7 +214,7 @@ class DBSQL : public Module, public Pipe this->Notify(); } - void OnSerializableDestruct(Serializable *obj) anope_override + void OnSerializableDestruct(Serializable *obj) override { if (this->shutting_down) return; @@ -205,7 +224,7 @@ class DBSQL : public Module, public Pipe this->updated_items.erase(obj); } - void OnSerializableUpdate(Serializable *obj) anope_override + void OnSerializableUpdate(Serializable *obj) override { if (this->shutting_down || obj->IsTSCached()) return; @@ -214,7 +233,7 @@ class DBSQL : public Module, public Pipe this->Notify(); } - void OnSerializeTypeCreate(Serialize::Type *sb) anope_override + void OnSerializeTypeCreate(Serialize::Type *sb) override { if (!this->loading_databases && !this->loaded) return; |