syBR::Game::PluginManager Class Reference

Plugin manager class. More...

#include <PluginManager.hpp>

List of all members.

Public Member Functions

void setErrorLogging (bool enable)
 Set error logging.
const bool getErrorLogging () const
 Get error logging.
bool load (const std::string &name)
 Load a plugin.
bool unload (const std::string &name)
 Unload a plugin.
const PluginDescriptorgetDescriptor (const std::string &name) const
 Get the descriptor of a loaded plugin.

Static Public Member Functions

static bool initializeSingleton (Core::Logger *pLogger)
 Initialize singleton.
static PluginManagergetSingleton (Core::Logger *pLogger)
 Retrieve singleton instance.
static void terminateSingleton (Core::Logger *pLogger)
 Terminate singleton.

Private Member Functions

 PluginManager (Core::Logger *pLogger)
 Constructor.
 ~PluginManager ()
 Destructor.

Private Attributes

Core::Loggerm_pLogger
 Pointer to the logger to be used.
bool m_errorLogging
 Error logging:.
std::map
< std::string,
PluginEntry
m_mapPlugins

Static Private Attributes

static PluginManagersm_pSingleton = NULL
 Singleton instance.


Detailed Description

Plugin manager class.

It is the class responsible of handling plugins loading and management.


Constructor & Destructor Documentation

syBR::Game::PluginManager::PluginManager ( Core::Logger pLogger  )  [private]

Constructor.

Parameters:
pLogger Pointer to the instance of the logger to use

syBR::Game::PluginManager::~PluginManager (  )  [private]

Destructor.


Member Function Documentation

bool syBR::Game::PluginManager::initializeSingleton ( Core::Logger pLogger  )  [static]

Initialize singleton.

Create a new instance of the plugin manager only if none already exists.

Parameters:
pLogger Pointer to the instance of the logger to use
Returns:
One of these:
  • true in case of success
  • false if it failed to create a new instance of the plugin manager when needed

PluginManager * syBR::Game::PluginManager::getSingleton ( Core::Logger pLogger  )  [static]

Retrieve singleton instance.

Parameters:
pLogger Pointer to the instance of the logger to use
Returns:
One of these:
  • Singleton instance if it has been initialized
  • NULL otherwise

void syBR::Game::PluginManager::terminateSingleton ( Core::Logger pLogger  )  [static]

Terminate singleton.

Parameters:
pLogger Pointer to the instance of the logger to use

void syBR::Game::PluginManager::setErrorLogging ( bool  enable  ) 

Set error logging.

Most of the time, this shouldn't be called and the default value (true) should be used. However, in some cases, it is cleaner to not log errors i.e. when writing a tool to select plugins, it would be useful not not display errors as a lot of unrelated dynamic libraries would be loaded by the plugin manager only to find that they are not plugins.

Note that this does not enable/disable all error messages but only those related to the plugin loading/unloading.

Parameters:
enable One of the following values:
  • true to enable error logging (default)
  • false to disable it

const bool syBR::Game::PluginManager::getErrorLogging (  )  const

Get error logging.

Returns:
One of these:
  • true if error logging is enabled
  • false if it is disabled

bool syBR::Game::PluginManager::load ( const std::string &  name  ) 

Load a plugin.

Load a plugin and retrieve its descriptor.

Parameters:
name Filename of the plugin
Returns:
One of these:
  • true if loading was successfull
  • false otherwise

bool syBR::Game::PluginManager::unload ( const std::string &  name  ) 

Unload a plugin.

Remove plugin descriptor and unload plugin

Parameters:
name Name of the plugin to unload
Returns:
One of these:
  • true if unloading is successfull
  • false otherwise

const PluginDescriptor * syBR::Game::PluginManager::getDescriptor ( const std::string &  name  )  const

Get the descriptor of a loaded plugin.

Parameters:
name Name of the plugin whose descriptor is to be retrieved
Returns:
One of these:
  • Pointer to the descriptor if the plugin has been previously loaded
  • NULL otherwise


Member Data Documentation

PluginManager * syBR::Game::PluginManager::sm_pSingleton = NULL [static, private]

Singleton instance.

Core::Logger* syBR::Game::PluginManager::m_pLogger [private]

Pointer to the logger to be used.

bool syBR::Game::PluginManager::m_errorLogging [private]

Error logging:.

It can have the following values:

std::map<std::string, PluginEntry> syBR::Game::PluginManager::m_mapPlugins [private]

Map of loaded plugins


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

Copyright © 2008 by Sebastien Frippiat
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License.
Last modified Tue Dec 30 17:57:33 2008