Anope IRC Services  Version 2.0
Static Public Member Functions | Static Public Attributes | Static Private Member Functions
ModuleManager Class Reference

#include <modules.h>

Static Public Member Functions

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 void DetachAll (Module *mod)
 
static void UnloadAll ()
 

Static Public Attributes

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

Static Private Member Functions

static ModuleReturn DeleteModule (Module *m)
 

Detailed Description

Used to manage modules.

Definition at line 1109 of file modules.h.

Member Function Documentation

ModuleReturn ModuleManager::DeleteModule ( Module m)
staticprivate

Call the module_delete function to safely delete the module

Parameters
mthe module to delete
Returns
MOD_ERR_OK on success, anything else on fail

Definition at line 333 of file modulemanager.cpp.

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

Referenced by LoadModule(), and UnloadModule().

void ModuleManager::DetachAll ( Module mod)
static

Detach all events from a module (used on unload)

Parameters
modModule to detach from

Definition at line 365 of file modulemanager.cpp.

References EventHandlers, and I_SIZE.

Referenced by ProtoInspIRCd20::ProtoInspIRCd20(), 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
majorThe major version
minorThe minor vesion
patchThe patch version

Definition at line 309 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
modThe module to change the priority of
iThe event to change the priority of
sThe 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.
modulesIf 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.
szThe 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 384 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
modThe module to set the priority of
sThe 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 376 of file modulemanager.cpp.

References I_SIZE, and SetPriority().

void ModuleManager::UnloadAll ( )
static

Unloading all modules except the protocol module.

Definition at line 478 of file modulemanager.cpp.

References FindModule(), Modules, MT_END, Module::name, Module::type, and UnloadModule().

Referenced by main().

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

Unload the given module.

Parameters
mthe module to unload
uthe user who unloaded it
Returns
MOD_ERR_OK on success, anything else on fail

Definition at line 273 of file modulemanager.cpp.

References DeleteModule(), FOREACH_MOD, and MOD_ERR_PARAMS.

Referenced by CommandOSModReLoad::Execute(), CommandOSModUnLoad::Execute(), main(), Configuration::Conf::Post(), UnloadAll(), ProtoCharybdis::~ProtoCharybdis(), ProtoInspIRCd20::~ProtoInspIRCd20(), ProtoPlexus::~ProtoPlexus(), and ProtoRatbox::~ProtoRatbox().

Field Documentation

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

Event handler hooks.

Definition at line 1114 of file modules.h.

Referenced by DetachAll(), LoadModule(), and SetPriority().

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

List of all modules loaded in Anope

Definition at line 1118 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: