pion  5.0.6
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
pion::plugin Class Reference

#include <plugin.hpp>

Inherited by pion::plugin_ptr< InterfaceClassType >.

Classes

struct  data_type
 

Public Member Functions

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

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
 
static void reset_plugin_directories (void)
 clears all directories from the plug-in search path
 
static void get_all_plugin_names (std::vector< std::string > &plugin_names)
 returns a list of all Plugins found in all Plugin directories
 

Protected Member Functions

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

Detailed Description

plugin: base class for plug-in management

Definition at line 30 of file plugin.hpp.

Member Function Documentation

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

Definition at line 390 of file plugin.cpp.

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

Definition at line 48 of file plugin.cpp.

Referenced by add_plugin_directory(), and pion::plugins::FileService::set_option().

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

Definition at line 53 of file plugin.hpp.

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

Definition at line 40 of file plugin.hpp.

Referenced by 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.)

Definition at line 82 of file plugin.cpp.

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

Definition at line 106 of file plugin.cpp.

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

Referenced by open().


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