pion::plugin_manager< PluginType > Class Template Reference

#include <plugin_manager.hpp>

List of all members.

Classes

class  map_type
 data type that maps identifiers to plug-in objects More...

Public Types

typedef boost::function1< void,
PluginType * > 
PluginRunFunction
 data type for a function that may be called by the run() method
typedef boost::function1
< boost::uint64_t, const
PluginType * > 
PluginStatFunction
 data type for a function that may be called by the getStat() method

Public Member Functions

 plugin_manager (void)
 default constructor
virtual ~plugin_manager ()
 default destructor
void clear (void)
 clears all the plug-in objects being managed
bool empty (void) const
 returns true if there are no plug-in objects being managed
void add (const std::string &plugin_id, PluginType *plugin_object_ptr)
void remove (const std::string &plugin_id)
void replace (const std::string &plugin_id, PluginType *plugin_ptr)
PluginType * clone (const std::string &plugin_id)
PluginType * load (const std::string &plugin_id, const std::string &plugin_type)
PluginType * get (const std::string &plugin_id)
const PluginType * get (const std::string &plugin_id) const
plugin_ptr< PluginType > get_lib_ptr (const std::string &plugin_id) const
PluginType * find (const std::string &resource)
void run (PluginRunFunction run_func)
void run (const std::string &plugin_id, PluginRunFunction run_func)
boost::uint64_t get_statistic (PluginStatFunction stat_func) const
boost::uint64_t get_statistic (const std::string &plugin_id, PluginStatFunction stat_func) const

Protected Attributes

map_type m_plugin_map
 collection of plug-in objects being managed
boost::mutex m_plugin_mutex
 mutex to make class thread-safe

Detailed Description

template<typename PluginType>
class pion::plugin_manager< PluginType >

plugin_manager: used to manage a collection of plug-in objects

Definition at line 31 of file plugin_manager.hpp.


Member Function Documentation

template<typename PluginType>
void pion::plugin_manager< PluginType >::add ( const std::string &  plugin_id,
PluginType *  plugin_object_ptr 
) [inline]

adds a new plug-in object

Parameters:
plugin_id unique identifier associated with the plug-in
plugin_object_ptr pointer to the plug-in object to add

Definition at line 188 of file plugin_manager.hpp.

References pion::plugin_manager< PluginType >::m_plugin_map, and pion::plugin_manager< PluginType >::m_plugin_mutex.

Referenced by pion::http::plugin_server::add_service().

template<typename PluginType >
PluginType * pion::plugin_manager< PluginType >::clone ( const std::string &  plugin_id  )  [inline]

clones an existing plug-in object (creates a new one of the same type)

Parameters:
plugin_id unique identifier associated with the plug-in
Returns:
PluginType* pointer to the new plug-in object

Definition at line 229 of file plugin_manager.hpp.

References pion::plugin_manager< PluginType >::m_plugin_map, and pion::plugin_manager< PluginType >::m_plugin_mutex.

template<typename PluginType >
PluginType * pion::plugin_manager< PluginType >::find ( const std::string &  resource  )  [inline]

finds the plug-in object associated with a particular resource (fuzzy match)

Parameters:
resource resource identifier (uri-stem) to search for
Returns:
PluginType* pointer to the matching plug-in object or NULL if not found

Definition at line 295 of file plugin_manager.hpp.

References pion::plugin_manager< PluginType >::m_plugin_map, and pion::plugin_manager< PluginType >::m_plugin_mutex.

template<typename PluginType >
const PluginType * pion::plugin_manager< PluginType >::get ( const std::string &  plugin_id  )  const [inline]

gets the plug-in object associated with a particular plugin_id (exact match)

Parameters:
plugin_id unique identifier associated with the plug-in
Returns:
PluginType* pointer to the matching plug-in object or NULL if not found

Definition at line 273 of file plugin_manager.hpp.

References pion::plugin_manager< PluginType >::m_plugin_map, and pion::plugin_manager< PluginType >::m_plugin_mutex.

template<typename PluginType >
PluginType * pion::plugin_manager< PluginType >::get ( const std::string &  plugin_id  )  [inline]

gets the plug-in object associated with a particular plugin_id (exact match)

Parameters:
plugin_id unique identifier associated with the plug-in
Returns:
PluginType* pointer to the matching plug-in object or NULL if not found

Definition at line 262 of file plugin_manager.hpp.

References pion::plugin_manager< PluginType >::m_plugin_map, and pion::plugin_manager< PluginType >::m_plugin_mutex.

template<typename PluginType >
plugin_ptr< PluginType > pion::plugin_manager< PluginType >::get_lib_ptr ( const std::string &  plugin_id  )  const [inline]

gets a smart pointer to the plugin shared library for a particular plugin_id (exact match)

Parameters:
plugin_id unique identifier associated with the plug-in
Returns:
plugin_ptr<PluginType> pointer to the plugin shared library if found

Definition at line 284 of file plugin_manager.hpp.

References pion::plugin_manager< PluginType >::m_plugin_map, and pion::plugin_manager< PluginType >::m_plugin_mutex.

template<typename PluginType >
boost::uint64_t pion::plugin_manager< PluginType >::get_statistic ( const std::string &  plugin_id,
PluginStatFunction  stat_func 
) const [inline]

returns a statistic value for a particular plug-in

Parameters:
plugin_id unique identifier associated with the plug-in
stat_func the statistic function to execute

Definition at line 372 of file plugin_manager.hpp.

template<typename PluginType >
boost::uint64_t pion::plugin_manager< PluginType >::get_statistic ( PluginStatFunction  stat_func  )  const [inline]

returns a total statistic value summed for every plug-in being managed

Parameters:
stat_func the statistic function to execute for each plug-in object

Definition at line 359 of file plugin_manager.hpp.

References pion::plugin_manager< PluginType >::m_plugin_map, and pion::plugin_manager< PluginType >::m_plugin_mutex.

template<typename PluginType >
PluginType * pion::plugin_manager< PluginType >::load ( const std::string &  plugin_id,
const std::string &  plugin_type 
) [inline]

loads a new plug-in object

Parameters:
plugin_id unique identifier associated with the plug-in
plugin_type the name or type of the plug-in to load (searches plug-in directories and appends extensions)
Returns:
PluginType* pointer to the new plug-in object

Definition at line 239 of file plugin_manager.hpp.

References pion::plugin_ptr< InterfaceClassType >::create(), pion::plugin_manager< PluginType >::m_plugin_map, pion::plugin_manager< PluginType >::m_plugin_mutex, and pion::plugin::open().

Referenced by pion::http::plugin_server::load_service().

template<typename PluginType >
void pion::plugin_manager< PluginType >::remove ( const std::string &  plugin_id  )  [inline]

removes a plug-in object

Parameters:
plugin_id unique identifier associated with the plug-in

Definition at line 198 of file plugin_manager.hpp.

References pion::plugin_manager< PluginType >::m_plugin_map, and pion::plugin_manager< PluginType >::m_plugin_mutex.

template<typename PluginType>
void pion::plugin_manager< PluginType >::replace ( const std::string &  plugin_id,
PluginType *  plugin_ptr 
) [inline]

replaces an existing plug-in object with a new one

Parameters:
plugin_id unique identifier associated with the plug-in
plugin_ptr pointer to the new plug-in object which will replace the old one

Definition at line 213 of file plugin_manager.hpp.

References pion::plugin_manager< PluginType >::m_plugin_map, and pion::plugin_manager< PluginType >::m_plugin_mutex.

template<typename PluginType >
void pion::plugin_manager< PluginType >::run ( const std::string &  plugin_id,
PluginRunFunction  run_func 
) [inline]

runs a method for a particular plug-in

Parameters:
plugin_id unique identifier associated with the plug-in
run_func the function to execute

Definition at line 348 of file plugin_manager.hpp.

template<typename PluginType >
void pion::plugin_manager< PluginType >::run ( PluginRunFunction  run_func  )  [inline]

runs a method for every plug-in being managed

Parameters:
run_func the function to execute for each plug-in object

Definition at line 337 of file plugin_manager.hpp.

References pion::plugin_manager< PluginType >::m_plugin_map, and pion::plugin_manager< PluginType >::m_plugin_mutex.

Referenced by pion::http::plugin_server::set_service_option().


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

Generated on 16 Sep 2013 for pion by  doxygen 1.6.1