InspIRCd  2.0
 All Classes Namespaces Functions Variables Typedefs Enumerations
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 ( )

Simple, bog-standard, boring constructor.

ModuleManager::~ModuleManager ( )

Destructor

Member Function Documentation

void ModuleManager::AddService ( ServiceProvider item)

Register a service provided by a module

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.

Parameters
iEvent type to attach
modModule to attach event to
Returns
True if the event was attached
void ModuleManager::Attach ( Implementation *  i,
Module mod,
size_t  sz 
)

Attach an array of events to a module

Parameters
iEvent types (array) to attach
modModule to attach events to
szThe size of the implementation array
void ModuleManager::DelService ( ServiceProvider item)

Unregister a service provided by a module

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.

Parameters
iEvent type to detach
modModule to detach event from
Returns
True if the event was detached
void ModuleManager::DetachAll ( Module mod)

Detach all events from a module (used on unload)

Parameters
modModule to detach from
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.

Parameters
nameThe module name to look up
Returns
A pointer to the module, or NULL if the module cannot be found
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.

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

Return a list of all modules matching the given filter

Parameters
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.
Returns
The list of module names
int ModuleManager::GetCount ( )
inline

Get the total number of currently loaded modules

Returns
The number of loaded modules
std::string & ModuleManager::LastError ( )

Returns text describing the last module error

Returns
The last error message to occur
bool ModuleManager::Load ( const std::string &  filename,
bool  defer = false 
)

Load a given module file

Parameters
filenameThe file to load
deferDefer module init (loading many modules)
Returns
True if the module was found and loaded
void ModuleManager::LoadAll ( )

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

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.

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.

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 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.

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

Backwards compat interface

bool ModuleManager::SetPriority ( Module mod,
Priority  s 
)

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

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

Member Data Documentation

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

List of data services keyed by name

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: