ModManager Class Reference

#include <modules.h>

Inheritance diagram for ModManager:

Inheritance graph
[legend]
Collaboration diagram for ModManager:

Collaboration graph
[legend]
List of all members.

Detailed Description

Central module manager, keeping track of which modules are currently loaded, and providing an API for loading/unloading modules.

Definition at line 197 of file modules.h.


Public Member Functions

bool loadModule (const std::string &name)
 Load a module.
bool unloadModule (const std::string &name)
 Unload a module.
void getList (std::vector< std::pair< std::string, std::string > > *ret) const
 Get the list of loaded modules.

Static Public Member Functions

static ModManagerinstance ()
 Retrives the single instance of this Singleton class.

Private Types

typedef std::map< std::string,
ModuleBase * >::iterator 
Iter
 Iterator for the above map.
typedef std::map< std::string,
ModuleBase * >::const_iterator 
CIter
 Constant iterator for the above map.

Private Member Functions

 ModManager ()
 Constructor.
 ~ModManager ()
 Destructor.
 ModManager (ModManager &)
ModManageroperator= (const ModManager &)
void onInit ()
 Initialize ModManager class.
void onExit ()
 Shutdown/cleanup this class.
HNMODULE load (const std::string &name)
 Load a module using os-specific methods.
ModuleBaseinitialize (HNMODULE plg)
 Initialize a module using os-specific methods.

Private Attributes

std::map< std::string, ModuleBase * > m_list
 Map of loaded modules.

Friends

class HydraNode
struct Initializer

Member Typedef Documentation

typedef std::map<std::string, ModuleBase*>::const_iterator ModManager::CIter [private]
 

Constant iterator for the above map.

Reimplemented from Object.

Definition at line 243 of file modules.h.

typedef std::map<std::string, ModuleBase*>::iterator ModManager::Iter [private]
 

Iterator for the above map.

Reimplemented from Object.

Definition at line 241 of file modules.h.


Constructor & Destructor Documentation

ModManager::ModManager  )  [private]
 

Constructor.

Definition at line 105 of file modules.cpp.

ModManager::~ModManager  )  [private]
 

Destructor.

Definition at line 107 of file modules.cpp.

ModManager::ModManager ModManager  )  [private]
 


Member Function Documentation

void ModManager::getList std::vector< std::pair< std::string, std::string > > *  ret  )  const
 

Get the list of loaded modules.

Parameters:
ret Vector which is to be filled with list of all loaded modules. First element in the vector pair is the unix name of the module, second is the module description.

Definition at line 349 of file modules.cpp.

References CHECK_THROW, and m_list.

ModuleBase * ModManager::initialize HNMODULE  plg  )  [private]
 

Initialize a module using os-specific methods.

Parameters:
plg Module handle to be initialized, generally previously returned by load().
Returns:
Pointer to abstract ModuleBase class representing this module.
Exceptions:
std::runtime_error if anything goes wrong.

Definition at line 182 of file modules.cpp.

References CHECK_THROW, logTrace(), ModuleBase::onInit(), and TRACE_MOD.

Referenced by loadModule().

Here is the call graph for this function:

ModManager & ModManager::instance  )  [static]
 

Retrives the single instance of this Singleton class.

Definition at line 109 of file modules.cpp.

Referenced by HydraNode::cleanup(), and HydraNode::initModules().

HNMODULE ModManager::load const std::string &  name  )  [private]
 

Load a module using os-specific methods.

Parameters:
name Path to the module to be loaded.
Returns:
Module handle.
Exceptions:
std::runtime_error if module loading fails for any reason.

Definition at line 146 of file modules.cpp.

References CHECK, logTrace(), and TRACE_MOD.

Referenced by loadModule().

Here is the call graph for this function:

bool ModManager::loadModule const std::string &  name  ) 
 

Load a module.

The module is searched in standard module directories.

Parameters:
name Name of the module to be loaded.
Returns:
True if loading succeeded, false otherwise.

Definition at line 215 of file modules.cpp.

References Log::addPreStr(), initialize(), Log::instance(), load(), logError(), logMsg(), logWarning(), m_list, and Log::remPreStr().

Referenced by HydraNode::initModules().

Here is the call graph for this function:

void ModManager::onExit  )  [private]
 

Shutdown/cleanup this class.

Should be called on application shutdown from HydraNode class.

Definition at line 132 of file modules.cpp.

References Log::addPreStr(), Log::instance(), m_list, and Log::remPreStr().

Referenced by HydraNode::cleanup().

Here is the call graph for this function:

void ModManager::onInit  )  [private]
 

Initialize ModManager class.

Should be called from HydraNode class on application startup.

Definition at line 115 of file modules.cpp.

References Log::addPreStr(), builtIn(), Detail::InitializerBase::doInit(), ModuleBase::getName(), Log::instance(), logMsg(), m_list, ModuleBase::onInit(), and Log::remPreStr().

Referenced by HydraNode::initModules().

Here is the call graph for this function:

ModManager& ModManager::operator= const ModManager  )  [private]
 

bool ModManager::unloadModule const std::string &  name  ) 
 

Unload a module.

The module should have been previously loaded with loadModule() function.

Parameters:
name Module to be unloaded.
Returns:
True if successful, false otherwise.

Definition at line 291 of file modules.cpp.

References logError(), logMsg(), logTrace(), logWarning(), and TRACE_MOD.

Here is the call graph for this function:


Friends And Related Function Documentation

friend class HydraNode [friend]
 

Definition at line 245 of file modules.h.

friend struct Initializer [friend]
 

Definition at line 246 of file modules.h.


Member Data Documentation

std::map<std::string, ModuleBase*> ModManager::m_list [private]
 

Map of loaded modules.

Definition at line 239 of file modules.h.

Referenced by getList(), loadModule(), onExit(), and onInit().


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