#include <modules.h>
|
| ModuleManager () |
|
| ~ModuleManager () |
|
bool | SetPriority (Module *mod, Implementation i, Priority s, Module *which=NULL) |
|
void | 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) |
|
void | AttachAll (Module *mod) |
|
std::string & | LastError () |
|
bool | Load (const std::string &filename, bool defer=false) |
|
bool | Unload (Module *module) |
|
void | LoadAll () |
|
void | UnloadAll () |
|
void | DoSafeUnload (Module *) |
|
bool | CanUnload (Module *mod) |
|
Module * | Find (const std::string &name) |
|
void | AddService (ServiceProvider &) |
|
void | DelService (ServiceProvider &) |
|
void | AddServices (const ServiceList &list) |
|
void | AddServices (ServiceProvider **list, int count) |
|
ServiceProvider * | FindService (ServiceType Type, const std::string &name) |
|
template<typename T > |
T * | FindDataService (const std::string &name) |
|
const ModuleMap & | GetModules () const |
|
void | AddReferent (const std::string &name, ServiceProvider *service) |
|
void | DelReferent (ServiceProvider *service) |
|
ModuleManager * | operator-> () |
|
ModuleManager takes care of all things module-related in the core.
◆ ModuleManager()
ModuleManager::ModuleManager |
( |
| ) |
|
Simple, bog-standard, boring constructor.
◆ ~ModuleManager()
ModuleManager::~ModuleManager |
( |
| ) |
|
◆ AddReferent()
void ModuleManager::AddReferent |
( |
const std::string & |
name, |
|
|
ServiceProvider * |
service |
|
) |
| |
Make a service referenceable by dynamic_references
- Parameters
-
name | Name that will be used by dynamic_references to find the object |
service | Service to make referenceable by dynamic_references |
◆ AddService()
Register a service provided by a module
◆ AddServices()
void ModuleManager::AddServices |
( |
const ServiceList & |
list | ) |
|
Register all services in a given ServiceList
- Parameters
-
list | The list containing the services to register |
◆ Attach() [1/2]
void ModuleManager::Attach |
( |
Implementation * |
i, |
|
|
Module * |
mod, |
|
|
size_t |
sz |
|
) |
| |
Attach an array of events to a module
- Parameters
-
i | Event types (array) to attach |
mod | Module to attach events to |
sz | The size of the implementation array |
◆ Attach() [2/2]
bool ModuleManager::Attach |
( |
Implementation |
i, |
|
|
Module * |
mod |
|
) |
| |
Attach an event to a module. You may later detach the event with ModuleManager::Detach(). If your module is unloaded, all events are automatically detached.
- Parameters
-
i | Event type to attach |
mod | Module to attach event to |
- Returns
- True if the event was attached
◆ AttachAll()
void ModuleManager::AttachAll |
( |
Module * |
mod | ) |
|
Attach all events to a module (used on module load)
- Parameters
-
mod | Module to attach to all events |
◆ CanUnload()
bool ModuleManager::CanUnload |
( |
Module * |
mod | ) |
|
Check if a module can be unloaded and if yes, prepare it for unload
- Parameters
-
- Returns
- True if the module is unloadable, false otherwise. If true the module must be unloaded in the current main loop iteration.
◆ DelReferent()
Make a service no longer referenceable by dynamic_references
- Parameters
-
service | Service to make no longer referenceable by dynamic_references |
◆ DelService()
Unregister a service provided by a module
◆ Detach()
bool ModuleManager::Detach |
( |
Implementation |
i, |
|
|
Module * |
mod |
|
) |
| |
Detach an event from a module. This is not required when your module unloads, as the core will automatically detach your module from all events it is attached to.
- Parameters
-
i | Event type to detach |
mod | Module to detach event from |
- Returns
- True if the event was detached
◆ DetachAll()
void ModuleManager::DetachAll |
( |
Module * |
mod | ) |
|
Detach all events from a module (used on unload)
- Parameters
-
◆ ExpandModName()
std::string ModuleManager::ExpandModName |
( |
const std::string & |
modname | ) |
|
|
static |
Expands the name of a module by prepending "m_" and appending ".so". No-op if the name already has the ".so" extension.
- Parameters
-
- Returns
- Module name starting with "m_" and ending with ".so"
◆ 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.
- Parameters
-
name | The module name to look up |
- Returns
- 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.
◆ GetModules()
const ModuleMap& ModuleManager::GetModules |
( |
| ) |
const |
|
inline |
Get a map of all loaded modules keyed by their name
- Returns
- A ModuleMap containing all loaded modules
◆ LastError()
std::string & ModuleManager::LastError |
( |
| ) |
|
Returns text describing the last module error
- Returns
- The last error message to occur
◆ Load()
bool ModuleManager::Load |
( |
const std::string & |
filename, |
|
|
bool |
defer = false |
|
) |
| |
Load a given module file
- Parameters
-
filename | The file to load |
defer | Defer module init (loading many modules) |
- Returns
- 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.
◆ SetPriority() [1/2]
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
-
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 PRIORITY_AFTER to set it to be before or after one or more other modules. |
which | If 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/2]
void ModuleManager::SetPriority |
( |
Module * |
mod, |
|
|
Priority |
s |
|
) |
| |
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 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.
- Returns
- true on success; if false, LastError will give a reason
◆ DataProviders
List of data services keyed by name
◆ EventHandlers
Event handler hooks. This needs to be public to be used by FOREACH_MOD and friends.
◆ NewServices
ServiceList* ModuleManager::NewServices |
A list of ServiceProviders waiting to be registered. Non-NULL when constructing a Module, NULL otherwise. When non-NULL ServiceProviders add themselves to this list on creation and the core automatically registers them (that is, call AddService()) after the Module is constructed, and before Module::init() is called. If a service is created after the construction of the Module (for example in init()) it has to be registered manually.
The documentation for this class was generated from the following files:
- include/modules.h
- src/modulemanager.cpp
- src/modules.cpp