Static Public Member Functions | Static Public Attributes | Static Private Member Functions

ModuleManager Class Reference

#include <modules.h>

Static Public Member Functions

static void CleanupRuntimeDirectory ()
static ModuleReturn LoadModule (const Anope::string &modname, User *u)
static ModuleReturn UnloadModule (Module *m, User *u)
static ModuleFindModule (const Anope::string &name)
static ModuleFindFirstOf (ModType type)
static void RequireVersion (int major, int minor, int patch)
static bool SetPriority (Module *mod, Implementation i, Priority s, Module **modules=NULL, size_t sz=1)
static bool SetPriority (Module *mod, Priority s)
static bool Attach (Implementation i, Module *mod)
static bool Detach (Implementation i, Module *mod)
static void DetachAll (Module *mod)
static void Attach (Implementation *i, Module *mod, size_t sz)
static void ClearCallBacks (Module *m)
static void UnloadAll ()

Static Public Attributes

static std::list< Module * > Modules
static std::vector< Module * > EventHandlers [I_END]

Static Private Member Functions

static ModuleReturn DeleteModule (Module *m)

Detailed Description

Used to manage modules.

Definition at line 1027 of file modules.h.


Member Function Documentation

bool ModuleManager::Attach ( Implementation  i,
Module mod 
) [static]

Attach an event to a module. You may later detatch the event with ModuleManager::Detach(). If your module is unloaded, all events are automatically detatched.

Parameters:
i Event type to attach
mod Module to attach event to
Returns:
True if the event was attached

Definition at line 318 of file modulemanager.cpp.

References EventHandlers.

Referenced by Attach(), BotServCore::BotServCore(), BSAutoAssign::BSAutoAssign(), BSKick::BSKick(), ChanServCore::ChanServCore(), CSAccess::CSAccess(), CSAKick::CSAKick(), CSEntryMessage::CSEntryMessage(), CSFlags::CSFlags(), CSLog::CSLog(), CSSeen::CSSeen(), CSSet::CSSet(), CSSetMisc::CSSetMisc(), CSStats::CSStats(), CSSuspend::CSSuspend(), CSTop::CSTop(), DBFlatFile::DBFlatFile(), DBMySQL::DBMySQL(), DBOld::DBOld(), DBPlain::DBPlain(), DBSQL::DBSQL(), EMD5::EMD5(), ENone::ENone(), EOld::EOld(), ESHA1::ESHA1(), ESHA256::ESHA256(), GlobalCore::GlobalCore(), HelpChannel::HelpChannel(), HostServCore::HostServCore(), HSRequest::HSRequest(), HTTPD::HTTPD(), LDAPOper::LDAPOper(), MChanstats::MChanstats(), MemoServCore::MemoServCore(), ModuleDNS::ModuleDNS(), ModuleDNSBL::ModuleDNSBL(), ModuleLDAP::ModuleLDAP(), ModuleProxyScan::ModuleProxyScan(), ModuleRewrite::ModuleRewrite(), ModuleSQL::ModuleSQL(), ModuleSQLAuthentication::ModuleSQLAuthentication(), ModuleSQLite::ModuleSQLite(), ModuleSQLOper::ModuleSQLOper(), ModuleXMLRPC::ModuleXMLRPC(), NickServCore::NickServCore(), NSAJoin::NSAJoin(), NSCert::NSCert(), NSIdentifyLDAP::NSIdentifyLDAP(), NSMaxEmail::NSMaxEmail(), NSRecover::NSRecover(), NSResetPass::NSResetPass(), NSSet::NSSet(), NSSetMisc::NSSetMisc(), NSSuspend::NSSuspend(), OperServCore::OperServCore(), OSDefcon::OSDefcon(), OSForbid::OSForbid(), OSIgnore::OSIgnore(), OSLogin::OSLogin(), OSLogSearch::OSLogSearch(), OSNews::OSNews(), OSNOOP::OSNOOP(), OSSession::OSSession(), ProtoBahamut::ProtoBahamut(), ProtoHybrid::ProtoHybrid(), ProtoInspIRCd::ProtoInspIRCd(), ProtongIRCd::ProtongIRCd(), ProtoUnreal::ProtoUnreal(), SSLModule::SSLModule(), and StatusUpdate::StatusUpdate().

void ModuleManager::Attach ( Implementation i,
Module mod,
size_t  sz 
) [static]

Attach an array of events to a module

Parameters:
i Event types (array) to attach
mod Module to attach events to

Definition at line 338 of file modulemanager.cpp.

References Attach().

void ModuleManager::CleanupRuntimeDirectory (  )  [static]

Clean up the module runtime directory

Definition at line 26 of file modulemanager.cpp.

References Anope::string::c_str(), closedir(), Anope::DataDir, LOG_DEBUG, opendir(), and readdir().

Referenced by main().

void ModuleManager::ClearCallBacks ( Module m  )  [static]

Delete all callbacks attached to a module

Parameters:
m The module

Definition at line 452 of file modulemanager.cpp.

References Module::callbacks.

Referenced by Module::~Module().

ModuleReturn ModuleManager::DeleteModule ( Module m  )  [static, private]

Call the module_delete function to safely delete the module

Parameters:
m the module to delete
Returns:
MOD_ERR_OK on success, anything else on fail

Definition at line 288 of file modulemanager.cpp.

References Anope::string::c_str(), dlclose(), dlerror(), dlsym(), Anope::string::empty(), Module::filename, function_cast(), Module::handle, LOG_DEBUG, and Module::name.

Referenced by LoadModule(), and UnloadModule().

bool ModuleManager::Detach ( Implementation  i,
Module mod 
) [static]

Detatch an event from a module. This is not required when your module unloads, as the core will automatically detatch your module from all events it is attached to.

Parameters:
i Event type to detach
mod Module to detach event from
Detach true if the event was detached

Definition at line 327 of file modulemanager.cpp.

References EventHandlers.

Referenced by DetachAll(), and DBPlain::OnLoadDatabase().

void ModuleManager::DetachAll ( Module mod  )  [static]

Detach all events from a module (used on unload)

Parameters:
mod Module to detach from

Definition at line 344 of file modulemanager.cpp.

References Detach(), and I_BEGIN.

Referenced by ProtoInspIRCd::ProtoInspIRCd(), and Module::~Module().

Module * ModuleManager::FindFirstOf ( ModType  type  )  [static]
Module * ModuleManager::FindModule ( const Anope::string name  )  [static]
ModuleReturn ModuleManager::LoadModule ( const Anope::string modname,
User u 
) [static]
void ModuleManager::RequireVersion ( int  major,
int  minor,
int  patch 
) [static]

Checks whether this version of Anope is at least major.minor.patch.build Throws a ModuleException if not

Parameters:
major The major version
minor The minor vesion
patch The patch version

Definition at line 264 of file modulemanager.cpp.

References stringify(), Anope::VersionMajor(), Anope::VersionMinor(), Anope::VersionPatch(), and Anope::VersionShort().

bool ModuleManager::SetPriority ( Module mod,
Implementation  i,
Priority  s,
Module **  modules = NULL,
size_t  sz = 1 
) [static]

Change the priority of one event in a module. Each module event has a list of modules which are attached to that event type. If you wish to be called before or after other specific modules, you may use this method (usually within void Module::Prioritize()) to set your events priority. You may use this call in other methods too, however, this is not supported behaviour for a module.

Parameters:
mod The module to change the priority of
i The event to change the priority of
s The state you wish to use for this event. Use one of PRIO_FIRST to set the event to be first called, PRIO_LAST to set it to be the last called, or PRIO_BEFORE and PRIO_AFTER to set it to be before or after one or more other modules.
modules If PRIO_BEFORE or PRIO_AFTER is set in parameter 's', then this contains a list of one or more modules your module must be placed before or after. Your module will be placed before the highest priority module in this list for PRIO_BEFORE, or after the lowest priority module in this list for PRIO_AFTER.
sz The number of modules being passed for PRIO_BEFORE and PRIO_AFTER. Defaults to 1, as most of the time you will only want to prioritize your module to be before or after one other module.

To change the priority of a module, we first find its position in the vector, then we find the position of the other modules in the vector that this module wants to be before/after. We pick off either the first or last of these depending on which they want, and we make sure our module is *at least* before or after the first or last of this subset, depending again on the type of priority.

Definition at line 358 of file modulemanager.cpp.

References EventHandlers, PRIORITY_AFTER, PRIORITY_BEFORE, PRIORITY_DONTCARE, PRIORITY_FIRST, and PRIORITY_LAST.

Referenced by NSIdentifyLDAP::NSIdentifyLDAP(), OSSession::OSSession(), ProtoUnreal::ProtoUnreal(), and SetPriority().

bool ModuleManager::SetPriority ( Module mod,
Priority  s 
) [static]

Change the priority of all events in a module.

Parameters:
mod The module to set the priority of
s The priority of all events in the module. Note that with this method, it is not possible to effectively use PRIO_BEFORE or PRIO_AFTER, you should use the more fine tuned SetPriority method for this, where you may specify other modules to be prioritized against.

Definition at line 350 of file modulemanager.cpp.

References I_BEGIN, and SetPriority().

void ModuleManager::UnloadAll (  )  [static]

Unloading all modules except the protocol module.

Definition at line 458 of file modulemanager.cpp.

References FindModule(), Modules, MT_BEGIN, PROTOCOL, and UnloadModule().

Referenced by main().

ModuleReturn ModuleManager::UnloadModule ( Module m,
User u 
) [static]

Unload the given module.

Parameters:
m the module to unload
u the user who unloaded it
Returns:
MOD_ERR_OK on success, anything else on fail

Definition at line 228 of file modulemanager.cpp.

References DeleteModule(), FOREACH_MOD, and I_OnModuleUnload.

Referenced by DoneModules(), CommandOSModUnLoad::Execute(), CommandOSModReLoad::Execute(), main(), UnloadAll(), ProtoInspIRCd::~ProtoInspIRCd(), ProtoPlexus::~ProtoPlexus(), and ProtoRatbox::~ProtoRatbox().


Field Documentation

std::vector< Module * > ModuleManager::EventHandlers [static]

Event handler hooks. This needs to be public to be used by FOREACH_MOD and friends.

Definition at line 1037 of file modules.h.

Referenced by Attach(), Detach(), and SetPriority().

std::list< Module * > ModuleManager::Modules [static]

List of all modules loaded in Anope

Definition at line 1032 of file modules.h.

Referenced by CommandOSModList::Execute(), FindFirstOf(), FindModule(), Module::Module(), UnloadAll(), and Module::~Module().


The documentation for this class was generated from the following files: