InspIRCd  2.0
Public Member Functions | Public Attributes | List of all members
ModuleManager Class Reference

#include <modules.h>

Public Member Functions

 ModuleManager ()
 ~ModuleManager ()
bool SetPriority (Module *mod, Implementation i, Priority s, Module *which=NULL)
bool SetPriority (Module *mod, Implementation i, Priority s, Module **dptr)
bool SetPriority (Module *mod, Priority s)
bool Attach (Implementation i, Module *mod)
bool Detach (Implementation i, Module *mod)
void Attach (Implementation *i, Module *mod, size_t sz)
void DetachAll (Module *mod)
std::string & LastError ()
bool Load (const std::string &filename, bool defer=false)
bool Unload (Module *module)
void Reload (Module *module, HandlerBase1< void, bool > *callback)
void LoadAll ()
void UnloadAll ()
void DoSafeUnload (Module *)
int GetCount ()
ModuleFind (const std::string &name)
void AddService (ServiceProvider &)
void DelService (ServiceProvider &)
void AddServices (ServiceProvider **list, int count)
ServiceProviderFindService (ServiceType Type, const std::string &name)
template<typename T >
T * FindDataService (const std::string &name)
const std::vector< std::string > GetAllModuleNames (int filter)

Public Attributes

IntModuleList EventHandlers [I_END]
std::multimap< std::string, ServiceProvider * > DataProviders

Detailed Description

ModuleManager takes care of all things module-related in the core.

Constructor & Destructor Documentation

◆ ModuleManager()

ModuleManager::ModuleManager ( )

Simple, bog-standard, boring constructor.

◆ ~ModuleManager()

ModuleManager::~ModuleManager ( )


Member Function Documentation

◆ AddService()

void ModuleManager::AddService ( ServiceProvider item)

Register a service provided by a module

◆ Attach() [1/2]

bool ModuleManager::Attach ( Implementation  i,
Module mod 

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.

iEvent type to attach
modModule to attach event to
True if the event was attached

◆ Attach() [2/2]

void ModuleManager::Attach ( Implementation *  i,
Module mod,
size_t  sz 

Attach an array of events to a module

iEvent types (array) to attach
modModule to attach events to
szThe size of the implementation array

◆ DelService()

void ModuleManager::DelService ( ServiceProvider item)

Unregister a service provided by a module

◆ Detach()

bool ModuleManager::Detach ( Implementation  i,
Module mod 

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.

iEvent type to detach
modModule to detach event from
True if the event was detached

◆ DetachAll()

void ModuleManager::DetachAll ( Module mod)

Detach all events from a module (used on unload)

modModule to detach from

◆ Find()

Module * ModuleManager::Find ( const std::string &  name)

Find a module by name, and return a Module* to it. This is preferred over iterating the module lists yourself.

nameThe module name to look up
A pointer to the module, or NULL if the module cannot be found

◆ FindService()

ServiceProvider * ModuleManager::FindService ( ServiceType  Type,
const std::string &  name 

Find a service by name. If multiple modules provide a given service, the first one loaded will be chosen.

◆ GetAllModuleNames()

const std::vector< std::string > ModuleManager::GetAllModuleNames ( int  filter)

Return a list of all modules matching the given filter

filterThis int is a bitmask of flags set in Module::Flags, such as VF_VENDOR or VF_STATIC. If you wish to receive a list of all modules with no filtering, set this to 0.
The list of module names

◆ GetCount()

int ModuleManager::GetCount ( )

Get the total number of currently loaded modules

The number of loaded modules

◆ LastError()

std::string & ModuleManager::LastError ( )

Returns text describing the last module error

The last error message to occur

◆ Load()

bool ModuleManager::Load ( const std::string &  filename,
bool  defer = false 

Load a given module file

filenameThe file to load
deferDefer module init (loading many modules)
True if the module was found and loaded

◆ LoadAll()

void ModuleManager::LoadAll ( )

Called by the InspIRCd constructor to load all modules from the config file.

◆ Reload()

void ModuleManager::Reload ( Module module,
HandlerBase1< void, bool > *  callback 

Run an asynchronous reload of the given module. When the reload is complete, the callback will be run with true if the reload succeeded and false if it did not.

◆ SetPriority() [1/3]

bool ModuleManager::SetPriority ( Module mod,
Implementation  i,
Priority  s,
Module which = NULL 

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.

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 PRIORITY_AFTER to set it to be before or after one or more other modules.
whichIf PRIO_BEFORE or PRIORITY_AFTER is set in parameter 's', then this contains a the module that your module must be placed before or after.

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.

◆ SetPriority() [2/3]

bool ModuleManager::SetPriority ( Module mod,
Implementation  i,
Priority  s,
Module **  dptr 

Backwards compat interface

◆ SetPriority() [3/3]

bool ModuleManager::SetPriority ( Module mod,
Priority  s 

Change the priority of all events in a module.

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 PRIORITY_AFTER, you should use the more fine tuned SetPriority method for this, where you may specify other modules to be prioritized against.

◆ Unload()

bool ModuleManager::Unload ( Module module)

Unload a given module file. Note that the module will not be completely gone until the cull list has finished processing.

true on success; if false, LastError will give a reason

Member Data Documentation

◆ DataProviders

std::multimap<std::string, ServiceProvider*> ModuleManager::DataProviders

List of data services keyed by name

◆ EventHandlers

IntModuleList ModuleManager::EventHandlers[I_END]

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

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