X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fmodules.h;h=710a39193546dff81c4b0fbb6911ed66421a122b;hb=1f38b9adb576580d8e8638fefc5c7cb157f90a5c;hp=52e41a1fc49f1a47332045c04a51a96474a9fc38;hpb=8710724b5518ae9858309e548514f76e620a8459;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/modules.h b/include/modules.h index 52e41a1fc..710a39193 100644 --- a/include/modules.h +++ b/include/modules.h @@ -122,12 +122,10 @@ struct ModResult { * 'FOREACH_MOD(OnConnect,(user));' */ #define FOREACH_MOD(y,x) do { \ - EventHandlerIter safei; \ - IntModuleList& _handlers = ServerInstance->Modules->EventHandlers[I_ ## y]; \ - for (EventHandlerIter _i = _handlers.begin(); _i != _handlers.end(); ) \ + const IntModuleList& _handlers = ServerInstance->Modules->EventHandlers[I_ ## y]; \ + for (IntModuleList::const_reverse_iterator _i = _handlers.rbegin(), _next; _i != _handlers.rend(); _i = _next) \ { \ - safei = _i; \ - ++safei; \ + _next = _i+1; \ try \ { \ (*_i)->y x ; \ @@ -136,7 +134,6 @@ struct ModResult { { \ ServerInstance->Logs->Log("MODULE", LOG_DEFAULT, "Exception caught: %s",modexcept.GetReason()); \ } \ - _i = safei; \ } \ } while (0); @@ -148,9 +145,10 @@ struct ModResult { */ #define DO_EACH_HOOK(n,v,args) \ do { \ - IntModuleList& _handlers = ServerInstance->Modules->EventHandlers[I_ ## n]; \ - for (EventHandlerIter _i = _handlers.begin(); _i != _handlers.end(); ++_i) \ + const IntModuleList& _handlers = ServerInstance->Modules->EventHandlers[I_ ## n]; \ + for (IntModuleList::const_reverse_iterator _i = _handlers.rbegin(), _next; _i != _handlers.rend(); _i = _next) \ { \ + _next = _i+1; \ try \ { \ v = (*_i)->n args; @@ -278,6 +276,11 @@ enum Implementation */ class CoreExport Module : public classbase, public usecountbase { + /** Detach an event from this module + * @param i Event type to detach + */ + void DetachEvent(Implementation i); + public: /** File that this module was loaded from */ @@ -1270,6 +1273,11 @@ class CoreExport ModuleManager */ void DetachAll(Module* mod); + /** Attach all events to a module (used on module load) + * @param mod Module to attach to all events + */ + void AttachAll(Module* mod); + /** Returns text describing the last module error * @return The last error message to occur */