pion::PluginManager< PLUGIN_TYPE > Class Template Reference

#include <PluginManager.hpp>

List of all members.


Detailed Description

template<typename PLUGIN_TYPE>
class pion::PluginManager< PLUGIN_TYPE >

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

Definition at line 30 of file PluginManager.hpp.

Public Types

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

Public Member Functions

 PluginManager (void)
 default constructor
virtual ~PluginManager ()
 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, PLUGIN_TYPE *plugin_object_ptr)
void remove (const std::string &plugin_id)
void replace (const std::string &plugin_id, PLUGIN_TYPE *plugin_ptr)
PLUGIN_TYPE * clone (const std::string &plugin_id)
PLUGIN_TYPE * load (const std::string &plugin_id, const std::string &plugin_type)
PLUGIN_TYPE * get (const std::string &plugin_id)
const PLUGIN_TYPE * get (const std::string &plugin_id) const
PionPluginPtr< PLUGIN_TYPE > getLibPtr (const std::string &plugin_id) const
PLUGIN_TYPE * find (const std::string &resource)
void run (PluginRunFunction run_func)
void run (const std::string &plugin_id, PluginRunFunction run_func)
boost::uint64_t getStatistic (PluginStatFunction stat_func) const
boost::uint64_t getStatistic (const std::string &plugin_id, PluginStatFunction stat_func) const

Protected Attributes

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

Classes

class  DuplicatePluginException
 exception thrown if we try to add or load a duplicate plug-in More...
class  PluginMap
 data type that maps identifiers to plug-in objects More...
class  PluginNotFoundException
 exception thrown if a plug-in cannot be found More...


Member Function Documentation

template<typename PLUGIN_TYPE>
void pion::PluginManager< PLUGIN_TYPE >::add ( const std::string &  plugin_id,
PLUGIN_TYPE *  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 201 of file PluginManager.hpp.

References pion::PluginManager< PLUGIN_TYPE >::m_plugin_map, and pion::PluginManager< PLUGIN_TYPE >::m_plugin_mutex.

Referenced by pion::net::WebServer::addService().

template<typename PLUGIN_TYPE>
PLUGIN_TYPE * pion::PluginManager< PLUGIN_TYPE >::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:
PLUGIN_TYPE* pointer to the new plug-in object

Definition at line 242 of file PluginManager.hpp.

References pion::PluginManager< PLUGIN_TYPE >::m_plugin_map, and pion::PluginManager< PLUGIN_TYPE >::m_plugin_mutex.

template<typename PLUGIN_TYPE>
PLUGIN_TYPE * pion::PluginManager< PLUGIN_TYPE >::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:
PLUGIN_TYPE* pointer to the matching plug-in object or NULL if not found

Definition at line 319 of file PluginManager.hpp.

References pion::PluginManager< PLUGIN_TYPE >::m_plugin_map, and pion::PluginManager< PLUGIN_TYPE >::m_plugin_mutex.

template<typename PLUGIN_TYPE>
const PLUGIN_TYPE * pion::PluginManager< PLUGIN_TYPE >::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:
PLUGIN_TYPE* pointer to the matching plug-in object or NULL if not found

Definition at line 297 of file PluginManager.hpp.

References pion::PluginManager< PLUGIN_TYPE >::m_plugin_map, and pion::PluginManager< PLUGIN_TYPE >::m_plugin_mutex.

template<typename PLUGIN_TYPE>
PLUGIN_TYPE * pion::PluginManager< PLUGIN_TYPE >::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:
PLUGIN_TYPE* pointer to the matching plug-in object or NULL if not found

Definition at line 286 of file PluginManager.hpp.

References pion::PluginManager< PLUGIN_TYPE >::m_plugin_map, and pion::PluginManager< PLUGIN_TYPE >::m_plugin_mutex.

Referenced by pion::PluginManager< PLUGIN_TYPE >::getStatistic(), and pion::PluginManager< PLUGIN_TYPE >::run().

template<typename PLUGIN_TYPE>
PionPluginPtr< PLUGIN_TYPE > pion::PluginManager< PLUGIN_TYPE >::getLibPtr ( 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:
PionPluginPtr<PLUGIN_TYPE> pointer to the plugin shared library if found

Definition at line 308 of file PluginManager.hpp.

References pion::PluginManager< PLUGIN_TYPE >::m_plugin_map, and pion::PluginManager< PLUGIN_TYPE >::m_plugin_mutex.

template<typename PLUGIN_TYPE>
boost::uint64_t pion::PluginManager< PLUGIN_TYPE >::getStatistic ( 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 396 of file PluginManager.hpp.

References pion::PluginManager< PLUGIN_TYPE >::get().

template<typename PLUGIN_TYPE>
boost::uint64_t pion::PluginManager< PLUGIN_TYPE >::getStatistic ( 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 383 of file PluginManager.hpp.

References pion::PluginManager< PLUGIN_TYPE >::m_plugin_map, and pion::PluginManager< PLUGIN_TYPE >::m_plugin_mutex.

template<typename PLUGIN_TYPE>
PLUGIN_TYPE * pion::PluginManager< PLUGIN_TYPE >::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:
PLUGIN_TYPE* pointer to the new plug-in object

Definition at line 252 of file PluginManager.hpp.

References pion::PionPluginPtr< InterfaceClassType >::create(), pion::PionPlugin::findStaticEntryPoint(), pion::PluginManager< PLUGIN_TYPE >::m_plugin_map, pion::PluginManager< PLUGIN_TYPE >::m_plugin_mutex, pion::PionPlugin::open(), and pion::PionPlugin::openStaticLinked().

Referenced by pion::net::WebServer::loadService().

template<typename PLUGIN_TYPE>
void pion::PluginManager< PLUGIN_TYPE >::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 211 of file PluginManager.hpp.

References pion::PluginManager< PLUGIN_TYPE >::m_plugin_map, and pion::PluginManager< PLUGIN_TYPE >::m_plugin_mutex.

template<typename PLUGIN_TYPE>
void pion::PluginManager< PLUGIN_TYPE >::replace ( const std::string &  plugin_id,
PLUGIN_TYPE *  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 226 of file PluginManager.hpp.

References pion::PluginManager< PLUGIN_TYPE >::m_plugin_map, and pion::PluginManager< PLUGIN_TYPE >::m_plugin_mutex.

template<typename PLUGIN_TYPE>
void pion::PluginManager< PLUGIN_TYPE >::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 372 of file PluginManager.hpp.

References pion::PluginManager< PLUGIN_TYPE >::get().

template<typename PLUGIN_TYPE>
void pion::PluginManager< PLUGIN_TYPE >::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 361 of file PluginManager.hpp.

References pion::PluginManager< PLUGIN_TYPE >::m_plugin_map, and pion::PluginManager< PLUGIN_TYPE >::m_plugin_mutex.

Referenced by pion::net::WebServer::setServiceOption().


The documentation for this class was generated from the following file:
Generated on Fri Apr 30 14:48:54 2010 for pion-net by  doxygen 1.4.7