summaryrefslogtreecommitdiff
path: root/src/modules.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-11-04 15:29:49 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-11-04 15:29:49 +0000
commitbf44023d115745d4a6a1ce06ff291ffb73480efb (patch)
tree36cd5194e73b3fb3187d8895849ecf0f65ec3944 /src/modules.cpp
parentc0abad99489eb0ce0a52d98f9d6f76790a6a2db4 (diff)
Development/Hooking in full swing now: WARNING, this will break ALL modules for the time being until complete!
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8497 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules.cpp')
-rw-r--r--src/modules.cpp35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/modules.cpp b/src/modules.cpp
index d9fca88cd..601aeabef 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -191,8 +191,7 @@ void Module::OnBufferFlushed(User*) { }
void Module::OnText(User*, void*, int, const std::string&, char, CUList&) { }
-ModuleManager::ModuleManager(InspIRCd* Ins)
-: ModCount(0), Instance(Ins)
+ModuleManager::ModuleManager(InspIRCd* Ins) : ModCount(0), Instance(Ins)
{
for (int n = I_BEGIN + 1; n != I_END; ++n)
EventHandlers.push_back(std::list<Module*>());
@@ -202,6 +201,38 @@ ModuleManager::~ModuleManager()
{
}
+bool ModuleManager::Attach(Implementation i, Module* mod)
+{
+ if (std::find(EventHandlers[i].begin(), EventHandlers[i].end(), mod) != EventHandlers[i].end())
+ return false;
+
+ EventHandlers[i].push_back(mod);
+ return true;
+}
+
+bool ModuleManager::Detach(Implementation i, Module* mod)
+{
+ EventHandlerIter x = std::find(EventHandlers[i].begin(), EventHandlers[i].end(), mod);
+
+ if (x == EventHandlers[i].end())
+ return false;
+
+ EventHandlers[i].erase(x);
+ return true;
+}
+
+void ModuleManager::Attach(Implementation* i, Module* mod, size_t sz)
+{
+ for (size_t n = 0; n < sz; ++n)
+ Attach(i[n], mod);
+}
+
+void ModuleManager::DetachAll(Module* mod)
+{
+ for (size_t n = I_BEGIN + 1; n != I_END; ++n)
+ Detach((Implementation)n, mod);
+}
+
const char* ModuleManager::LastError()
{
return MODERR;