charon-core  0.3.1
AbstractPluginLoader Class Referenceabstract

Abstract base class for a plugin loader. More...

#include <charon-core/AbstractPluginLoader.h>

Inheritance diagram for AbstractPluginLoader:

Classes

class  PluginException
 Plugin Exception class. More...
 

Public Member Functions

 AbstractPluginLoader (const std::string &name, std::vector< std::string > &plpaths, std::string &lSuffix, PluginManagerInterface::PluginVersionCheckLevel versionCheck=PluginManagerInterface::PluginVersionIgnore)
 Default constructor. More...
 
virtual ~AbstractPluginLoader ()
 Default Destructor. More...
 
virtual ParameteredObjectcreateInstance (const std::string &name, ParameteredObject::template_type t=ParameteredObject::TYPE_DOUBLE) throw (PluginException)
 Creates an instance of the loaded plugin and returns a pointer to it. More...
 
virtual void destroyInstance (ParameteredObject *p) throw (PluginException)
 Deletes an instance of the loaded plugin. More...
 
virtual const std::string & getName () const
 Get the name of the plugin. More...
 
virtual void load ()=0 throw (PluginException)
 Loads the plugin. More...
 
virtual void unload ()=0 throw (PluginException)
 Unloads the plugin. More...
 

Protected Attributes

PluginManagerInterface::PluginVersionCheckLevel _versionCheck
 should the Loader ignore embedded charon-core version strings?
 
ParameteredObject *(* create )(const std::string &, ParameteredObject::template_type)
 Function pointer to the constructor of the plugin.
 
void(* destroy )(ParameteredObject *)
 Function pointer to the destructor of the plugin.
 
ParameteredObject::build_type(* getBuildType )()
 Function pointer to the getBuildType function of the plugin.
 
std::string & libSuffix
 Lib suffix e.g. _d for debug builds.
 
std::string pluginName
 The name of the Plugin (without prefix "lib" and without extension)
 
std::vector< std::string > & pluginPaths
 Paths where the plugins are stored.
 

Detailed Description

If you want to develop an own plugin loader, implement this class.

Definition at line 40 of file AbstractPluginLoader.h.

Constructor & Destructor Documentation

AbstractPluginLoader::AbstractPluginLoader ( const std::string &  name,
std::vector< std::string > &  plpaths,
std::string &  lSuffix,
PluginManagerInterface::PluginVersionCheckLevel  versionCheck = PluginManagerInterface::PluginVersionIgnore 
)

Transforms the given plugin name to lowercase

Parameters
nameThe name of the Plugin (without prefix "lib" and without extension)
plpathslist of paths which are searched for the plugin
lSuffixsuffix which will be appended to the plugin name before search operations. This is typically used to append _d for searching debug libraries.
versionChecken/disable additional version check for plugins

Definition at line 24 of file AbstractPluginLoader.cpp.

AbstractPluginLoader::~AbstractPluginLoader ( )
virtual

Unloads the plugin from the memory.

Definition at line 64 of file AbstractPluginLoader.cpp.

Member Function Documentation

ParameteredObject * AbstractPluginLoader::createInstance ( const std::string &  name,
ParameteredObject::template_type  t = ParameteredObject::TYPE_DOUBLE 
)
throw (PluginException
)
virtual
Warning
Do NOT call delete on an instance of a loaded plugin. Use destroyInstance(ParameteredObject *) instead.
See Also
destroyInstance(ParameteredObject * p)
Parameters
nameName of the new instance
tTemplate type.
Returns
Pointer to the new instance
Exceptions
AbstractPluginLoader::PluginException

Definition at line 41 of file AbstractPluginLoader.cpp.

References create().

void AbstractPluginLoader::destroyInstance ( ParameteredObject p)
throw (PluginException
)
virtual
Warning
Do NOT call delete on an instance of a loaded plugin.
Parameters
pPointer to the instance that will be deleted
Exceptions
AbstractPluginLoader::PluginException

Definition at line 53 of file AbstractPluginLoader.cpp.

References destroy().

const std::string & AbstractPluginLoader::getName ( ) const
virtual
Returns
Name of the plugin

Definition at line 37 of file AbstractPluginLoader.cpp.

References pluginName.

virtual void AbstractPluginLoader::load ( )
throw (PluginException
)
pure virtual

Loads the shared library referring to the given plugin name into the memory and initializes the function pointers to the constructor and destructor of the plugin.

Exceptions
AbstractPluginLoader::PluginException

Implemented in WindowsPluginLoader, and UnixPluginLoader.

virtual void AbstractPluginLoader::unload ( )
throw (PluginException
)
pure virtual

Removes the shared library from the memory. Existing instances of the plugin will become obsolete.

Exceptions
AbstractPluginLoader::PluginException

Implemented in WindowsPluginLoader, and UnixPluginLoader.


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