modules::ModManager Class Reference

Module manager. More...

#include <manager.h>

List of all members.

Public Types

typedef std::list< Module * > list_type
 Type of the list of modules.
enum  {
  errSuccess = 0, errOpen = 1, errLookup = 2, errUnavailable = 3,
  errConfig = 4, errLoad = 5, errCore = 6, errNonZeroRefs = 7,
  errStop = 8
}
 Possible error codes for the error_code() function. More...

Public Member Functions

 ModManager (Core &core, ConfModuleA const &confmodule)
 Constructor.
 ~ModManager ()
 Destructor.
void broadcast (int state, Module &sender, int msg, void *arg)
 Sends a notification message to all modules in load order.
void broadcast_reverse (int state, Module &sender, int msg, void *arg)
 Sends a notification message to all modules in reverse load order.
Modulefind (std::string const &name)
 Finds a loaded module by name.
Modulefind (std::string const &name, int state)
 Finds a module by name and state.
bool load (std::string const &name)
 Loads a module.
bool load (LoadModule const &lm)
 Loads modules as specified by the load-module directive.
bool reload ()
 Reloads the configuration for all modules.
void start ()
 Starts all modules.
void stop ()
 Stops all modules.
bool unload (Module &module)
 Unloads a module.
Corecore () const
 Returns the core.
std::string const & error () const
 Returns a description of the last error that occured.
int error_code () const
 Returns the code of the last error that occured.
void global (conf::ConfGlobalQ &global)
 Sets the ConfGlobalQ object used to configure modules.
list_type const & modules () const
 Returns the list of loaded modules.
bool started () const
 Returns whether the modules manager is started.


Detailed Description

The module manager is responsible to load, unload and maintain a list of modules used by the program.


Member Enumeration Documentation

anonymous enum
 

Enumerator:
errSuccess  No error.
errOpen  Library open error.
errLookup  Library lookup error (can't find *_get or *_release).
errUnavailable  Module unavailable (*_get failed).
errConfig  Module configuration error.
errLoad  Module::load() failed.
errCore  Forbidden operation on the core module.
errNonZeroRefs  Reference count is non-zero.
errStop  Can't stop module.


Constructor & Destructor Documentation

modules::ModManager::ModManager Core core,
ConfModuleA const &  confmodule
 

Constructor.

Parameters:
[in] core The core module (must be valid until the module manager is destroyed).
[in] confmodule The conf-module directive (must be valid until the module manager is destroyed).


Member Function Documentation

void modules::ModManager::broadcast int  state,
Module sender,
int  msg,
void *  arg
 

Calls the Module::notify() function for all modules in a given state, in the order they were loaded, using the given parameters.

Parameters:
[in] state An or'ed set of states the module must have to receive the notification (the msLoaded state is implied).
[in] sender The module sending the notification. This module, which can be NULL, won't get the notification.
[in] msg The notification message.
[in] arg An optional parameter that may be used to pass additional data.
See also:
Module::notify()

void modules::ModManager::broadcast_reverse int  state,
Module sender,
int  msg,
void *  arg
 

Calls the Module::notify() function for all modules in a given state, in the reverse order they were loaded, using the given parameters.

Parameters:
[in] state An or'ed set of states the module must have to receive the notification (the msLoaded state is implied).
[in] sender The module sending the notification. This module, which can be NULL, won't get the notification.
[in] msg The notification message.
[in] arg An optional parameter that may be used to pass additional data.
See also:
Module::notify()

std::string const& modules::ModManager::error  )  const [inline]
 

Returns a description of the last error that occured, after a failed call to load() or unload().

Returns:
The last error.
See also:
load(std::string const &), unload()

int modules::ModManager::error_code  )  const [inline]
 

Returns the code of the last error that occured, after a failed call to load() or unload().

Returns:
The last error code.
See also:
load(std::string const &), unload()

Module* modules::ModManager::find std::string const &  name,
int  state
 

Finds a module by name and state.

Parameters:
[in] name The name of the module to find (case-sensitive).
[in] state An or'ed set of states the module must have to be found.
Returns:
A pointer to the matching Module object, or 0 if no module by this name and state is found.

Module* modules::ModManager::find std::string const &  name  ) 
 

Finds a loaded module with the given name.

Parameters:
[in] name The name of the module to find (case-sensitive).
Returns:
A pointer to the matching Module object, or 0 if no module by this name is loaded.

void modules::ModManager::global conf::ConfGlobalQ global  )  [inline]
 

Sets the ConfGlobalQ object used to configure modules.

This function is for use by the core module only.

bool modules::ModManager::load LoadModule const &  lm  ) 
 

Loads modules listed through the given load-module directive.

Parameters:
[in] lm The load-module directive.
Returns:
true if all modules have been loaded successfully, false otherwise.

bool modules::ModManager::load std::string const &  name  ) 
 

Loads a module.

A successful load does NOT guarantee that the module is in the Module::msLoaded state yet. Other modules calling this function should wait to get the Module::mnLoaded notification before using the module.

The module is started by this function as well, but only if the start() function has already been called by the core.

Parameters:
[in] name The module name.
Returns:
true if the module has been loaded successfully, false otherwise. Modules can only be loaded once; all subsequent loading attempts will do nothing but will still return true.

list_type const& modules::ModManager::modules  )  const [inline]
 

Returns the list of loaded modules. The core is NOT in this list.

Returns:
The list of loaded modules.

bool modules::ModManager::reload  ) 
 

Reloads the configuration for all modules.

This function is for use by the core module only.

void modules::ModManager::start  ) 
 

Starts all modules, and sets the module manager to the started state.

This function is for use by the core module only.

See also:
started()

void modules::ModManager::stop  ) 
 

Stops all modules.

This function is for use by the core module only.

bool modules::ModManager::unload Module module  ) 
 

Unloads a module. The module is first stopped if it was started. If it fails, then the module is NOT unloaded.

A module can't be unloaded if its reference count is non-zero and you can't unload the core module. Attempting to do so will result in a failure.

Parameters:
[in] module The module to be unloaded.
Returns:
true on success, false otherwise.


The documentation for this class was generated from the following file:
Generated on Sun May 20 21:32:21 2007 for Epona API by  doxygen 1.4.6