PionNetworkLibrary
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
pion::plugin_manager< PluginType > Class Template Reference

#include <plugin_manager.hpp>

Collaboration diagram for pion::plugin_manager< PluginType >:

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 More...
 
typedef boost::function1
< boost::uint64_t, const
PluginType * > 
PluginStatFunction
 data type for a function that may be called by the getStat() method More...
 

Public Member Functions

 plugin_manager (void)
 default constructor More...
 
virtual ~plugin_manager ()
 default destructor More...
 
void clear (void)
 clears all the plug-in objects being managed More...
 
bool empty (void) const
 returns true if there are no plug-in objects being managed More...
 
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 More...
 
boost::mutex m_plugin_mutex
 mutex to make class thread-safe More...
 

Detailed Description

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

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

Member Typedef Documentation

template<typename PluginType>
typedef boost::function1<void, PluginType*> pion::plugin_manager< PluginType >::PluginRunFunction

data type for a function that may be called by the run() method

template<typename PluginType>
typedef boost::function1<boost::uint64_t, const PluginType*> pion::plugin_manager< PluginType >::PluginStatFunction

data type for a function that may be called by the getStat() method

Constructor & Destructor Documentation

template<typename PluginType>
pion::plugin_manager< PluginType >::plugin_manager ( void  )
inline

default constructor

template<typename PluginType>
virtual pion::plugin_manager< PluginType >::~plugin_manager ( )
inlinevirtual

default destructor

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_idunique identifier associated with the plug-in
plugin_object_ptrpointer to the plug-in object to add

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

template<typename PluginType>
void pion::plugin_manager< PluginType >::clear ( void  )
inline

clears all the plug-in objects being managed

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_idunique identifier associated with the plug-in
Returns
PluginType* pointer to the new plug-in object

References pion::plugin_manager< PluginType >::find().

template<typename PluginType>
bool pion::plugin_manager< PluginType >::empty ( void  ) const
inline

returns true if there are no plug-in objects being managed

Referenced by pion::plugin_manager< PluginType >::map_type::clear().

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
resourceresource identifier (uri-stem) to search for
Returns
PluginType* pointer to the matching plug-in object or NULL if not found

Referenced by pion::plugin_manager< PluginType >::clone(), pion::plugin_manager< PluginType >::get(), pion::plugin_manager< PluginType >::get_lib_ptr(), pion::plugin_manager< PluginType >::remove(), and pion::plugin_manager< PluginType >::replace().

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_idunique identifier associated with the plug-in
Returns
PluginType* pointer to the matching plug-in object or NULL if not found

References pion::plugin_manager< PluginType >::find().

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_idunique identifier associated with the plug-in
Returns
PluginType* pointer to the matching plug-in object or NULL if not found

References pion::plugin_manager< PluginType >::find().

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_idunique identifier associated with the plug-in
Returns
plugin_ptr<PluginType> pointer to the plugin shared library if found

References pion::plugin_manager< PluginType >::find().

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_functhe statistic function to execute for each plug-in object
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_idunique identifier associated with the plug-in
stat_functhe statistic function to execute
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_idunique identifier associated with the plug-in
plugin_typethe 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

References pion::plugin_ptr< InterfaceClassType >::create(), 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_idunique identifier associated with the plug-in

References pion::plugin_manager< PluginType >::find().

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_idunique identifier associated with the plug-in
plugin_ptrpointer to the new plug-in object which will replace the old one

References pion::plugin_manager< PluginType >::find().

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

runs a method for every plug-in being managed

Parameters
run_functhe function to execute for each plug-in object

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

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_idunique identifier associated with the plug-in
run_functhe function to execute

Member Data Documentation

template<typename PluginType>
map_type pion::plugin_manager< PluginType >::m_plugin_map
protected
template<typename PluginType>
boost::mutex pion::plugin_manager< PluginType >::m_plugin_mutex
mutableprotected

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