diff options
author | Adam <Adam@anope.org> | 2010-08-22 00:34:02 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2010-08-22 00:34:02 -0400 |
commit | ada65a3bafd3ae6738a80972cf0d2f31ad19a7ae (patch) | |
tree | afde8d7594adc78beec8feb8090f4a990bd6a56b | |
parent | 8a4c6ae618f767d2a9335da40f507ddccfc77b4b (diff) |
Added a classbase for the major classes, makes dynamic_reference invalidation really work.
This also cleans up a bit of the code in the modestacker.
-rw-r--r-- | include/extensible.h | 2 | ||||
-rw-r--r-- | include/modes.h | 68 | ||||
-rw-r--r-- | include/modules.h | 95 | ||||
-rw-r--r-- | include/opertype.h | 2 | ||||
-rw-r--r-- | include/servers.h | 2 | ||||
-rw-r--r-- | include/services.h | 15 | ||||
-rw-r--r-- | modules/extra/m_mysql.cpp | 6 | ||||
-rw-r--r-- | src/base.cpp | 25 | ||||
-rw-r--r-- | src/modes.cpp | 114 | ||||
-rw-r--r-- | src/module.cpp | 12 | ||||
-rw-r--r-- | src/modulemanager.cpp | 1 | ||||
-rw-r--r-- | src/modules.cpp | 13 |
12 files changed, 142 insertions, 213 deletions
diff --git a/include/extensible.h b/include/extensible.h index ffdd395ee..884ca8ecb 100644 --- a/include/extensible.h +++ b/include/extensible.h @@ -57,7 +57,7 @@ template<typename T> class ExtensibleItemPointerArray : public ExtensibleItemBas T *GetItem() const { return Item; } }; -class CoreExport Extensible +class CoreExport Extensible : public virtual Base { private: typedef std::map<Anope::string, ExtensibleItemBase *> extensible_map; diff --git a/include/modes.h b/include/modes.h index 4d0706a9a..e938a65c6 100644 --- a/include/modes.h +++ b/include/modes.h @@ -74,7 +74,7 @@ enum ModeClass /** This class is the basis of all modes in Anope */ -class CoreExport Mode +class CoreExport Mode : public virtual Base { public: /* Class of mode this is */ @@ -350,9 +350,9 @@ class StackerInfo { public: /* Modes to be added */ - std::list<std::pair<void *, Anope::string> > AddModes; + std::list<std::pair<Base *, Anope::string> > AddModes; /* Modes to be deleted */ - std::list<std::pair<void *, Anope::string> > DelModes; + std::list<std::pair<Base *, Anope::string> > DelModes; /* The type of object this stacker info is for */ StackerType Type; /* Bot this is sent from */ @@ -363,7 +363,7 @@ class StackerInfo * @param Set true if setting, false if unsetting * @param Param The param for the mode */ - void AddMode(void *Mode, bool Set, const Anope::string &Param); + void AddMode(Base *Mode, bool Set, const Anope::string &Param); }; /** This is mode manager @@ -376,13 +376,13 @@ class CoreExport ModeManager { protected: /* List of pairs of user/channels and their stacker info */ - static std::list<std::pair<void *, StackerInfo *> > StackerObjects; + static std::list<std::pair<Base *, StackerInfo *> > StackerObjects; /** Get the stacker info for an item, if one doesnt exist it is created * @param Item The user/channel etc * @return The stacker info */ - static StackerInfo *GetInfo(void *Item); + static StackerInfo *GetInfo(Base *Item); /** Build a list of mode strings to send to the IRCd from the mode stacker * @param info The stacker info for a channel or user @@ -390,24 +390,6 @@ class CoreExport ModeManager */ static std::list<Anope::string> BuildModeStrings(StackerInfo *info); - /** Add a mode to the stacker, internal use only - * @param bi The client to set the modes from - * @param u The user - * @param um The user mode - * @param Set Adding or removing? - * @param Param A param, if there is one - */ - static void StackerAddInternal(BotInfo *bi, User *u, UserMode *um, bool Set, const Anope::string &Param); - - /** Add a mode to the stacker, internal use only - * @param bi The client to set the modes from - * @param c The channel - * @param cm The channel mode - * @param Set Adding or removing? - * @param Param A param, if there is one - */ - static void StackerAddInternal(BotInfo *bi, Channel *c, ChannelMode *cm, bool Set, const Anope::string &Param); - /** Really add a mode to the stacker, internal use only * @param bi The client to set the modes from * @param Object The object, user/channel @@ -416,7 +398,7 @@ class CoreExport ModeManager * @param Param A param, if there is one * @param Type The type this is, user or channel */ - static void StackerAddInternal(BotInfo *bi, void *Object, void *Mode, bool Set, const Anope::string &Param, StackerType Type); + static void StackerAddInternal(BotInfo *bi, Base *Object, Base *Mode, bool Set, const Anope::string &Param, StackerType Type); public: /* List of all modes Anope knows about */ @@ -489,24 +471,6 @@ class CoreExport ModeManager */ static void StackerAdd(BotInfo *bi, Channel *c, ChannelMode *cm, bool Set, const Anope::string &Param = ""); - /** Add a mode to the stacker to be set on a channel - * @param bi The client to set the modes from - * @param c The channel - * @param Name The channel mode name - * @param Set true for setting, false for removing - * @param Param The param, if there is one - */ - static void StackerAdd(BotInfo *bi, Channel *c, ChannelModeName Name, bool Set, const Anope::string &Param = ""); - - /** Add a mode to the stacker to be set on a channel - * @param bi The client to set the modes from - * @param c The channel - * @param Mode The mode char - * @param Set true for setting, false for removing - * @param Param The param, if there is one - */ - static void StackerAdd(BotInfo *bi, Channel *c, const char Mode, bool Set, const Anope::string &Param = ""); - /** Add a mode to the stacker to be set on a user * @param bi The client to set the modes from * @param u The user @@ -516,24 +480,6 @@ class CoreExport ModeManager */ static void StackerAdd(BotInfo *bi, User *u, UserMode *um, bool Set, const Anope::string &Param = ""); - /** Add a mode to the stacker to be set on a user - * @param bi The client to set the modes from - * @param u The user - * @param Name The user mode name - * @param Set true for setting, false for removing - * @param Param The param, if there is one - */ - static void StackerAdd(BotInfo *bi, User *u, UserModeName Name, bool Set, const Anope::string &Param = ""); - - /** Add a mode to the stacker to be set on a user - * @param bi The client to set the modes from - * @param u The user - * @param Mode The mode to be set - * @param Set true for setting, false for removing - * @param Param The param, if there is one - */ - static void StackerAdd(BotInfo *bi, User *u, const char Mode, bool Set, const Anope::string &Param = ""); - /** Process all of the modes in the stacker and send them to the IRCd to be set on channels/users */ static void ProcessModes(); diff --git a/include/modules.h b/include/modules.h index 51581438c..0d279c6c0 100644 --- a/include/modules.h +++ b/include/modules.h @@ -64,7 +64,7 @@ if (true) \ { \ (*_i)->x ; \ } \ - catch (const CoreException &modexcept) \ + catch (const ModuleException &modexcept) \ { \ Alog() << "Exception caught: " << modexcept.GetReason(); \ } \ @@ -96,7 +96,7 @@ if (true) \ break; \ } \ } \ - catch (const CoreException &modexcept) \ + catch (const ModuleException &modexcept) \ { \ Alog() << "Exception caught: " << modexcept.GetReason(); \ } \ @@ -201,7 +201,7 @@ class CallBack; /** Every module in Anope is actually a class. */ -class CoreExport Module +class CoreExport Module : public virtual Base { private: bool permanent; @@ -1249,7 +1249,7 @@ class CallBack : public Timer } }; -class Service +class Service : public virtual Base { public: Module *owner; @@ -1260,55 +1260,66 @@ class Service virtual ~Service(); }; -class dynamic_reference_base +class dynamic_reference_base : public virtual Base { + protected: + bool invalid; public: - dynamic_reference_base(); - - virtual ~dynamic_reference_base(); + dynamic_reference_base() : invalid(false) { } + virtual ~dynamic_reference_base() { } + inline void Invalidate() { this->invalid = true; } }; -extern std::list<dynamic_reference_base *> dyn_references; - template<typename T> class dynamic_reference : public dynamic_reference_base { protected: T *ref; public: - dynamic_reference() : dynamic_reference_base(), ref(NULL) { } - - dynamic_reference(T *obj) : dynamic_reference_base(), ref(obj) { } - - virtual ~dynamic_reference() { } - - virtual operator bool() + dynamic_reference(T *obj) : ref(obj) { - return this->ref; + if (ref) + ref->AddReference(this); } - virtual inline T *operator->() + virtual ~dynamic_reference() { - return this->ref; + if (this->invalid) + { + this->invalid = false; + this->ref = NULL; + } + else if (ref) + ref->DelReference(this); } - void Invalidate() + virtual operator bool() { - this->ref = NULL; + if (this->invalid) + { + this->invalid = false; + this->ref = NULL; + } + return this->ref; } - static void Invalidate(T *obj) + virtual inline void operator=(T *newref) { - for (std::list<dynamic_reference_base *>::iterator it = dyn_references.begin(), it_end = dyn_references.end(); it != it_end;) + if (this->invalid) { - dynamic_reference<void *> *d = static_cast<dynamic_reference<void *> *>(*it); - ++it; - - if (d && d->ref == obj) - { - d->Invalidate(); - } + this->invalid = false; + this->ref = NULL; } + else if (this->ref) + this->ref->DelReference(this); + this->ref = newref; + if (this->ref) + this->ref->AddReference(this); + } + + virtual inline T *operator->() + { + return this->ref; } }; @@ -1319,25 +1330,43 @@ class service_reference : public dynamic_reference<T> Anope::string name; public: - service_reference(Module *o, const Anope::string &n) : dynamic_reference<T>(), owner(o), name(n) + service_reference(Module *o, const Anope::string &n) : dynamic_reference<T>(static_cast<T *>(ModuleManager::GetService(this->name))), owner(o), name(n) { } - ~service_reference() + virtual ~service_reference() { } operator bool() { + if (this->invalid) + { + this->invalid = false; + this->ref = NULL; + } if (!this->ref) + { this->ref = static_cast<T *>(ModuleManager::GetService(this->name)); + if (this->ref) + this->ref->AddReference(this); + } return this->ref; } inline T *operator->() { + if (this->invalid) + { + this->invalid = false; + this->ref = NULL; + } if (!this->ref) + { this->ref = static_cast<T *>(ModuleManager::GetService(this->name)); + if (this->ref) + this->ref->AddReference(this); + } return this->ref; } }; diff --git a/include/opertype.h b/include/opertype.h index 40607b39f..faf074bf8 100644 --- a/include/opertype.h +++ b/include/opertype.h @@ -10,7 +10,7 @@ #include "hashcomp.h" -class CoreExport OperType +class CoreExport OperType : public virtual Base { private: /** The name of this opertype, e.g. "sra". diff --git a/include/servers.h b/include/servers.h index cbf017df8..4abe168db 100644 --- a/include/servers.h +++ b/include/servers.h @@ -74,7 +74,7 @@ enum ServerFlag /** Class representing a server */ -class CoreExport Server : public Flags<ServerFlag> +class CoreExport Server : public virtual Base, public Flags<ServerFlag> { private: /* Server name */ diff --git a/include/services.h b/include/services.h index ca02d087e..2cda56a31 100644 --- a/include/services.h +++ b/include/services.h @@ -193,6 +193,21 @@ extern "C" void __pfnBkCheck() {} #include "anope.h" +class dynamic_reference_base; + +/** The base class that most classes in Anope inherit from + */ +class CoreExport Base +{ + /* References to this base class */ + std::set<dynamic_reference_base *> References; + public: + Base(); + virtual ~Base(); + void AddReference(dynamic_reference_base *r); + void DelReference(dynamic_reference_base *r); +}; + /** This class can be used on its own to represent an exception, or derived to represent a module-specific exception. * When a module whishes to abort, e.g. within a constructor, it should throw an exception using ModuleException or * a class derived from ModuleException. If a module throws an exception during its constructor, the module will not diff --git a/modules/extra/m_mysql.cpp b/modules/extra/m_mysql.cpp index 176899a1b..289273493 100644 --- a/modules/extra/m_mysql.cpp +++ b/modules/extra/m_mysql.cpp @@ -251,17 +251,17 @@ class ModuleSQL : public Module for (unsigned i = this->QueryRequests.size(); i > 0; --i) { - QueryRequest &r = this->QueryRequests[i]; + QueryRequest &r = this->QueryRequests[i - 1]; if (r.interface && r.interface->owner == m) { - if (i == 0) + if (i == 1) { r.service->Lock.Lock(); r.service->Lock.Unlock(); } - this->QueryRequests.erase(this->QueryRequests.begin() + i); + this->QueryRequests.erase(this->QueryRequests.begin() + i - 1); } } diff --git a/src/base.cpp b/src/base.cpp new file mode 100644 index 000000000..0aec072a1 --- /dev/null +++ b/src/base.cpp @@ -0,0 +1,25 @@ +#include "services.h" +#include "modules.h" + +Base::Base() +{ +} + +Base::~Base() +{ + for (std::set<dynamic_reference_base *>::iterator it = this->References.begin(), it_end = this->References.end(); it != it_end; ++it) + { + (*it)->Invalidate(); + } +} + +void Base::AddReference(dynamic_reference_base *r) +{ + this->References.insert(r); +} + +void Base::DelReference(dynamic_reference_base *r) +{ + this->References.erase(r); +} + diff --git a/src/modes.cpp b/src/modes.cpp index ce34e461c..6c060aed8 100644 --- a/src/modes.cpp +++ b/src/modes.cpp @@ -10,7 +10,7 @@ #include "modules.h" /* List of pairs of user/channels and their stacker info */ -std::list<std::pair<void *, StackerInfo *> > ModeManager::StackerObjects; +std::list<std::pair<Base *, StackerInfo *> > ModeManager::StackerObjects; /* List of all modes Anope knows about */ std::map<Anope::string, Mode *> ModeManager::Modes; @@ -420,7 +420,7 @@ void ChannelModeInvex::DelMask(Channel *chan, const Anope::string &mask) } } -void StackerInfo::AddMode(void *Mode, bool Set, const Anope::string &Param) +void StackerInfo::AddMode(Base *Mode, bool Set, const Anope::string &Param) { ChannelMode *cm = NULL; UserMode *um = NULL; @@ -428,17 +428,17 @@ void StackerInfo::AddMode(void *Mode, bool Set, const Anope::string &Param) if (Type == ST_CHANNEL) { - cm = static_cast<ChannelMode *>(Mode); + cm = debug_cast<ChannelMode *>(Mode); if (cm->Type == MODE_PARAM) IsParam = true; } else if (Type == ST_USER) { - um = static_cast<UserMode *>(Mode); + um = debug_cast<UserMode *>(Mode); if (um->Type == MODE_PARAM) IsParam = true; } - std::list<std::pair<void *, Anope::string> > *list, *otherlist; + std::list<std::pair<Base *, Anope::string> > *list, *otherlist; if (Set) { list = &AddModes; @@ -451,7 +451,7 @@ void StackerInfo::AddMode(void *Mode, bool Set, const Anope::string &Param) } /* Loop through the list and find if this mode is already on here */ - std::list<std::pair<void *, Anope::string > >::iterator it, it_end; + std::list<std::pair<Base *, Anope::string > >::iterator it, it_end; for (it = list->begin(), it_end = list->end(); it != it_end; ++it) { /* The param must match too (can have multiple status or list modes), but @@ -489,11 +489,11 @@ void StackerInfo::AddMode(void *Mode, bool Set, const Anope::string &Param) * @param Item The user/channel etc * @return The stacker info */ -StackerInfo *ModeManager::GetInfo(void *Item) +StackerInfo *ModeManager::GetInfo(Base *Item) { - for (std::list<std::pair<void *, StackerInfo *> >::const_iterator it = StackerObjects.begin(), it_end = StackerObjects.end(); it != it_end; ++it) + for (std::list<std::pair<Base *, StackerInfo *> >::const_iterator it = StackerObjects.begin(), it_end = StackerObjects.end(); it != it_end; ++it) { - const std::pair<void *, StackerInfo *> &PItem = *it; + const std::pair<Base *, StackerInfo *> &PItem = *it; if (PItem.first == Item) return PItem.second; } @@ -510,7 +510,7 @@ StackerInfo *ModeManager::GetInfo(void *Item) std::list<Anope::string> ModeManager::BuildModeStrings(StackerInfo *info) { std::list<Anope::string> ret; - std::list<std::pair<void *, Anope::string> >::iterator it, it_end; + std::list<std::pair<Base *, Anope::string> >::iterator it, it_end; Anope::string buf = "+", parambuf; ChannelMode *cm = NULL; UserMode *um = NULL; @@ -528,12 +528,12 @@ std::list<Anope::string> ModeManager::BuildModeStrings(StackerInfo *info) if (info->Type == ST_CHANNEL) { - cm = static_cast<ChannelMode *>(it->first); + cm = debug_cast<ChannelMode *>(it->first); buf += cm->ModeChar; } else if (info->Type == ST_USER) { - um = static_cast<UserMode *>(it->first); + um = debug_cast<UserMode *>(it->first); buf += um->ModeChar; } @@ -557,12 +557,12 @@ std::list<Anope::string> ModeManager::BuildModeStrings(StackerInfo *info) if (info->Type == ST_CHANNEL) { - cm = static_cast<ChannelMode *>(it->first); + cm = debug_cast<ChannelMode *>(it->first); buf += cm->ModeChar; } else if (info->Type == ST_USER) { - um = static_cast<UserMode *>(it->first); + um = debug_cast<UserMode *>(it->first); buf += um->ModeChar; } @@ -579,30 +579,6 @@ std::list<Anope::string> ModeManager::BuildModeStrings(StackerInfo *info) return ret; } -/** Add a mode to the stacker, internal use only - * @param bi The client to set the modes from - * @param u The user - * @param um The user mode - * @param Set Adding or removing? - * @param Param A param, if there is one - */ -void ModeManager::StackerAddInternal(BotInfo *bi, User *u, UserMode *um, bool Set, const Anope::string &Param) -{ - StackerAddInternal(bi, u, um, Set, Param, ST_USER); -} - -/** Add a mode to the stacker, internal use only - * @param bi The client to set the modes from - * @param c The channel - * @param cm The channel mode - * @param Set Adding or removing? - * @param Param A param, if there is one - */ -void ModeManager::StackerAddInternal(BotInfo *bi, Channel *c, ChannelMode *cm, bool Set, const Anope::string &Param) -{ - StackerAddInternal(bi, c, cm, Set, Param, ST_CHANNEL); -} - /** Really add a mode to the stacker, internal use only * @param bi The client to set the modes from * @param Object The object, user/channel @@ -611,7 +587,7 @@ void ModeManager::StackerAddInternal(BotInfo *bi, Channel *c, ChannelMode *cm, b * @param Param A param, if there is one * @param Type The type this is, user or channel */ -void ModeManager::StackerAddInternal(BotInfo *bi, void *Object, void *Mode, bool Set, const Anope::string &Param, StackerType Type) +void ModeManager::StackerAddInternal(BotInfo *bi, Base *Object, Base *Mode, bool Set, const Anope::string &Param, StackerType Type) { StackerInfo *s = GetInfo(Object); s->Type = Type; @@ -619,7 +595,7 @@ void ModeManager::StackerAddInternal(BotInfo *bi, void *Object, void *Mode, bool if (bi) s->bi = bi; else if (Type == ST_CHANNEL) - s->bi = whosends(static_cast<Channel *>(Object)->ci); + s->bi = whosends(debug_cast<Channel *>(Object)->ci); else if (Type == ST_USER) s->bi = NULL; } @@ -778,31 +754,7 @@ char ModeManager::GetStatusChar(char Value) */ void ModeManager::StackerAdd(BotInfo *bi, Channel *c, ChannelMode *cm, bool Set, const Anope::string &Param) { - StackerAddInternal(bi, c, cm, Set, Param); -} - -/** Add a mode to the stacker to be set on a channel - * @param bi The client to set the modes from - * @param c The channel - * @param Name The channel mode name - * @param Set true for setting, false for removing - * @param Param The param, if there is one - */ -void ModeManager::StackerAdd(BotInfo *bi, Channel *c, ChannelModeName Name, bool Set, const Anope::string &Param) -{ - StackerAdd(bi, c, FindChannelModeByName(Name), Set, Param); -} - -/** Add a mode to the stacker to be set on a channel - * @param bi The client to set the modes from - * @param c The channel - * @param Mode The mode char - * @param Set true for setting, false for removing - * @param Param The param, if there is one - */ -void ModeManager::StackerAdd(BotInfo *bi, Channel *c, const char Mode, bool Set, const Anope::string &Param) -{ - StackerAdd(bi, c, FindChannelModeByChar(Mode), Set, Param); + StackerAddInternal(bi, c, cm, Set, Param, ST_CHANNEL); } /** Add a mode to the stacker to be set on a user @@ -814,31 +766,7 @@ void ModeManager::StackerAdd(BotInfo *bi, Channel *c, const char Mode, bool Set, */ void ModeManager::StackerAdd(BotInfo *bi, User *u, UserMode *um, bool Set, const Anope::string &Param) { - StackerAddInternal(bi, u, um, Set, Param); -} - -/** Add a mode to the stacker to be set on a user - * @param bi The client to set the modes from - * @param u The user - * @param Name The user mode name - * @param Set true for setting, false for removing - * @param Param The param, if there is one - */ -void ModeManager::StackerAdd(BotInfo *bi, User *u, UserModeName Name, bool Set, const Anope::string &Param) -{ - StackerAdd(bi, u, FindUserModeByName(Name), Set, Param); -} - -/** Add a mode to the stacker to be set on a user - * @param bi The client to set the modes from - * @param u The user - * @param Mode The mode to be set - * @param Set true for setting, false for removing - * @param Param The param, if there is one - */ -void ModeManager::StackerAdd(BotInfo *bi, User *u, const char Mode, bool Set, const Anope::string &Param) -{ - StackerAdd(bi, u, FindUserModeByChar(Mode), Set, Param); + StackerAddInternal(bi, u, um, Set, Param, ST_USER); } /** Process all of the modes in the stacker and send them to the IRCd to be set on channels/users @@ -847,16 +775,16 @@ void ModeManager::ProcessModes() { if (!StackerObjects.empty()) { - for (std::list<std::pair<void *, StackerInfo *> >::const_iterator it = StackerObjects.begin(), it_end = StackerObjects.end(); it != it_end; ++it) + for (std::list<std::pair<Base *, StackerInfo *> >::const_iterator it = StackerObjects.begin(), it_end = StackerObjects.end(); it != it_end; ++it) { StackerInfo *s = it->second; User *u = NULL; Channel *c = NULL; if (s->Type == ST_USER) - u = static_cast<User *>(it->first); + u = debug_cast<User *>(it->first); else if (s->Type == ST_CHANNEL) - c = static_cast<Channel *>(it->first); + c = debug_cast<Channel *>(it->first); else throw CoreException("ModeManager::ProcessModes got invalid Stacker Info type"); diff --git a/src/module.cpp b/src/module.cpp index 9431137b7..98eb9b4fd 100644 --- a/src/module.cpp +++ b/src/module.cpp @@ -37,6 +37,8 @@ Module::~Module() for (i = 0; i < NUM_LANGS; ++i) this->DeleteLanguage(i); + /* Detach all event hooks for this module */ + ModuleManager::DetachAll(this); /* Clear any active callbacks this module has */ ModuleManager::ClearCallBacks(this); @@ -93,13 +95,3 @@ unsigned Version::GetBuild() const return this->Build; } -Service::Service(Module *o, const Anope::string &n) : owner(o), name(n) -{ - ModuleManager::RegisterService(this); -} - -Service::~Service() -{ - ModuleManager::UnregisterService(this); -} - diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp index f539f273d..49b90ca41 100644 --- a/src/modulemanager.cpp +++ b/src/modulemanager.cpp @@ -249,7 +249,6 @@ void ModuleManager::DeleteModule(Module *m) if (!m || !m->handle) return; - DetachAll(m); ano_module_t handle = m->handle; Anope::string filename = m->filename; diff --git a/src/modules.cpp b/src/modules.cpp index 0a7d813c5..8f9b6b944 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -382,18 +382,13 @@ Version Module::GetVersion() const return Version(VERSION_MAJOR, VERSION_MINOR, VERSION_BUILD); } -std::list<dynamic_reference_base *> dyn_references; - -dynamic_reference_base::dynamic_reference_base() +Service::Service(Module *o, const Anope::string &n) : owner(o), name(n) { - dyn_references.push_back(this); + ModuleManager::RegisterService(this); } -dynamic_reference_base::~dynamic_reference_base() +Service::~Service() { - std::list<dynamic_reference_base *>::iterator it = std::find(dyn_references.begin(), dyn_references.end(), this); - - if (it != dyn_references.end()) - dyn_references.erase(it); + ModuleManager::UnregisterService(this); } |