RSC  0.17.1
rsc::plugins::Manager Class Reference

Instances of this class manages plugin search path entries and plugins. More...

#include <Manager.h>

Inheritance diagram for rsc::plugins::Manager:
Inheritance graph
Collaboration diagram for rsc::plugins::Manager:
Collaboration graph

Public Member Functions

 Manager ()
 
virtual ~Manager ()
 
std::vector< boost::filesystem::path > getPath () const
 Returns the current plugin search path. More...
 
void addPath (const boost::filesystem::path &path)
 Adds path to the list of search path entries. More...
 
std::set< PluginPtrgetPlugins (const boost::regex &regex=boost::regex(".*")) const
 Returns the set of known plugins, potentially filtered by name according to regular expression regex. More...
 
std::set< PluginPtrgetPlugins (const std::string &regex) const
 Returns the set of known plugins, filtered by name according to regular expression regex. More...
 
PluginPtr getPlugin (const std::string &name) const
 Return the plugin designated by name. More...
 

Private Types

typedef std::vector< boost::filesystem::path > PathList
 
typedef std::map< std::string, PluginPtrPluginMap
 

Private Attributes

logging::LoggerPtr logger
 
PathList path
 
PluginMap plugins
 

Detailed Description

Instances of this class manages plugin search path entries and plugins.

Plugins can be retrieved as #Plugin objects, loaded and unloaded.

Plugins names are constructed from the shared library file name up to the first dot in the file name. Common shared library prefixes are stripped. E.g. libfoo.0.9.so will have the name foo.

Manager instances are not thread-safe and access needs to be synchronized.

Author
jmoringe

Definition at line 60 of file Manager.h.

Member Typedef Documentation

typedef std::vector<boost::filesystem::path> rsc::plugins::Manager::PathList
private

Definition at line 121 of file Manager.h.

typedef std::map<std::string, PluginPtr> rsc::plugins::Manager::PluginMap
private

Definition at line 122 of file Manager.h.

Constructor & Destructor Documentation

rsc::plugins::Manager::Manager ( )

Definition at line 47 of file Manager.cpp.

rsc::plugins::Manager::~Manager ( )
virtual

Definition at line 52 of file Manager.cpp.

Member Function Documentation

void rsc::plugins::Manager::addPath ( const boost::filesystem::path &  path)

Adds path to the list of search path entries.

Parameters
pathA #boost::filesystem::path designating a directory which should be searched for plugins.
Exceptions
exceptionIf path does not exist or is otherwise inaccessible.
runtime_errorIf the path contains a plugin which has the same plugin name as other already loaded plugins. This might also happen for two plugins in the same directory.

Definition at line 59 of file Manager.cpp.

References rsc::plugins::Plugin::create(), logger, path, plugins, RSCINFO, and RSCTRACE.

Here is the call graph for this function:

vector< path > rsc::plugins::Manager::getPath ( ) const

Returns the current plugin search path.

Returns
A #std::vector of #boost::filesystem::path objects.

Definition at line 55 of file Manager.cpp.

References path.

PluginPtr rsc::plugins::Manager::getPlugin ( const std::string &  name) const

Return the plugin designated by name.

Parameters
nameThe name of the plugin which should be returned.
Returns
The requested plugin.
Exceptions
NoSuchObjectIf name does not designate a plugin.

Definition at line 147 of file Manager.cpp.

References plugins.

set< PluginPtr > rsc::plugins::Manager::getPlugins ( const boost::regex &  regex = boost::regex(".*")) const

Returns the set of known plugins, potentially filtered by name according to regular expression regex.

Parameters
regexA regular expression object which is matched against plugin names, causing only matching plugin to be returned.
Returns
A copy of the set of known plugins (or subset thereof).

Definition at line 131 of file Manager.cpp.

References plugins.

Referenced by getPlugins().

Here is the caller graph for this function:

set< PluginPtr > rsc::plugins::Manager::getPlugins ( const std::string &  regex) const

Returns the set of known plugins, filtered by name according to regular expression regex.

Parameters
regexA regular expression string which is matched against plugin names, causing only matching plugin to be returned.
Returns
A copy of the set of known plugins (or subset thereof).

Definition at line 143 of file Manager.cpp.

References getPlugins().

Here is the call graph for this function:

Member Data Documentation

logging::LoggerPtr rsc::plugins::Manager::logger
private

Definition at line 124 of file Manager.h.

Referenced by addPath().

PathList rsc::plugins::Manager::path
private

Definition at line 126 of file Manager.h.

Referenced by addPath(), and getPath().

PluginMap rsc::plugins::Manager::plugins
private

Definition at line 127 of file Manager.h.

Referenced by addPath(), getPlugin(), and getPlugins().


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