PionNetworkLibrary
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
pion::plugin Class Reference

#include <plugin.hpp>

Inheritance diagram for pion::plugin:

Classes

struct  data_type
 

Public Member Functions

virtual ~plugin ()
 
bool is_open (void) const
 returns true if a shared library is loaded/open More...
 
std::string get_plugin_name (void) const
 returns the name of the plugin that is currently open More...
 
void open (const std::string &plugin_name)
 
void open_file (const std::string &plugin_file)
 
void close (void)
 closes plug-in library More...
 

Static Public Member Functions

static bool find_plugin_file (std::string &path_to_file, const std::string &name)
 
static bool find_config_file (std::string &path_to_file, const std::string &name)
 
static void add_static_entry_point (const std::string &plugin_name, void *create_func, void *destroy_func)
 
static void check_cygwin_path (boost::filesystem::path &final_path, const std::string &path_string)
 
static void add_plugin_directory (const std::string &dir)
 appends a directory to the plug-in search path More...
 
static void reset_plugin_directories (void)
 clears all directories from the plug-in search path More...
 
static void get_all_plugin_names (std::vector< std::string > &plugin_names)
 returns a list of all Plugins found in all Plugin directories More...
 

Protected Member Functions

 plugin (void)
 default constructor is private (use plugin_ptr class to create objects) More...
 
 plugin (const plugin &p)
 copy constructor More...
 
pluginoperator= (const plugin &p)
 assignment operator More...
 
void * get_create_function (void)
 returns a pointer to the plug-in's "create object" function More...
 
void * get_destroy_function (void)
 returns a pointer to the plug-in's "destroy object" function More...
 
void release_data (void)
 releases the plug-in's shared library symbols More...
 
void grab_data (const plugin &p)
 grabs a reference to another plug-in's shared library symbols More...
 

Detailed Description

plugin: base class for plug-in management

Constructor & Destructor Documentation

virtual pion::plugin::~plugin ( )
inlinevirtual
pion::plugin::plugin ( void  )
inlineprotected

default constructor is private (use plugin_ptr class to create objects)

pion::plugin::plugin ( const plugin p)
inlineprotected

copy constructor

Member Function Documentation

void pion::plugin::add_plugin_directory ( const std::string &  dir)
static

appends a directory to the plug-in search path

References check_cygwin_path().

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

void pion::plugin::add_static_entry_point ( const std::string &  plugin_name,
void *  create_func,
void *  destroy_func 
)
static

adds an entry point for a plugin that is statically linked NOTE: USE PION_DECLARE_PLUGIN() macro instead!!!

Parameters
plugin_namethe name of the plugin to add
create_func- pointer to the function to be used in to create plugin object
destroy_func- pointer to the function to be used to release plugin object

References pion::plugin::data_type::m_create_func, pion::plugin::data_type::m_destroy_func, and pion::plugin::data_type::m_lib_handle.

void pion::plugin::check_cygwin_path ( boost::filesystem::path &  final_path,
const std::string &  path_string 
)
static

updates path for cygwin oddities, if necessary

Parameters
final_pathpath object for the file, will be modified if necessary
start_pathoriginal path to the file. if final_path is not valid, this will be appended to PION_CYGWIN_DIRECTORY to attempt attempt correction of final_path for cygwin

References PION_CYGWIN_DIRECTORY.

Referenced by add_plugin_directory().

void pion::plugin::close ( void  )
inline

closes plug-in library

static bool pion::plugin::find_config_file ( std::string &  path_to_file,
const std::string &  name 
)
inlinestatic

searches directories for a valid plug-in configuration file

Parameters
path_to_fileif found, is set to the complete path to the file
namethe name of the configuration file to search for
Returns
true if the configuration file was found

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

static bool pion::plugin::find_plugin_file ( std::string &  path_to_file,
const std::string &  name 
)
inlinestatic

searches directories for a valid plug-in file

Parameters
path_to_filethe path to the plug-in file, if found
thename name of the plug-in to search for
Returns
true if the plug-in file was found

Referenced by open().

void pion::plugin::get_all_plugin_names ( std::vector< std::string > &  plugin_names)
static

returns a list of all Plugins found in all Plugin directories

References get_plugin_name(), pion::plugin::data_type::m_lib_handle, and pion::plugin::data_type::m_plugin_name.

void* pion::plugin::get_create_function ( void  )
inlineprotected

returns a pointer to the plug-in's "create object" function

Referenced by pion::plugin_ptr< InterfaceClassType >::create().

void* pion::plugin::get_destroy_function ( void  )
inlineprotected

returns a pointer to the plug-in's "destroy object" function

Referenced by pion::plugin_ptr< InterfaceClassType >::destroy().

std::string pion::plugin::get_plugin_name ( void  ) const
inline

returns the name of the plugin that is currently open

Referenced by get_all_plugin_names(), and open_file().

void pion::plugin::grab_data ( const plugin p)
protected

grabs a reference to another plug-in's shared library symbols

References pion::plugin::data_type::m_references, and release_data().

Referenced by pion::plugin_ptr< InterfaceClassType >::operator=().

bool pion::plugin::is_open ( void  ) const
inline

returns true if a shared library is loaded/open

void pion::plugin::open ( const std::string &  plugin_name)

opens plug-in library within a shared object file. If the library is already being used by another plugin object, then the existing code will be re-used and the reference count will be increased. Beware that this does NOT check the plug-in's base class (InterfaceClassType), so you must be careful to ensure that the namespace is unique between plug-ins that have different base classes. If the plug-in's name matches an existing plug-in of a different base class, the resulting behavior is undefined (it will probably crash your program).

Parameters
plugin_namename of the plug-in library to open (without extension, etc.)

References find_plugin_file(), pion::plugin::data_type::m_references, open_file(), and release_data().

Referenced by pion::plugin_manager< PluginType >::load().

void pion::plugin::open_file ( const std::string &  plugin_file)

opens plug-in library within a shared object file. If the library is already being used by another plugin object, then the existing code will be re-used and the reference count will be increased. Beware that this does NOT check the plug-in's base class (InterfaceClassType), so you must be careful to ensure that the namespace is unique between plug-ins that have different base classes. If the plug-in's name matches an existing plug-in of a different base class, the resulting behavior is undefined (it will probably crash your program).

Parameters
plugin_fileshared object file containing the plugin code

References get_plugin_name(), pion::plugin::data_type::m_plugin_name, pion::plugin::data_type::m_references, and release_data().

Referenced by open().

plugin& pion::plugin::operator= ( const plugin p)
inlineprotected

assignment operator

void pion::plugin::release_data ( void  )
protected
void pion::plugin::reset_plugin_directories ( void  )
static

clears all directories from the plug-in search path


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