# pion::PionPlugin Class Reference

`#include <PionPlugin.hpp>`

Inherited by pion::PionPluginPtr< InterfaceClassType >.

List of all members.

## Detailed Description

PionPlugin: base class for plug-in management

Definition at line 28 of file PionPlugin.hpp.

## Public Member Functions

virtual | ~PionPlugin ()
bool | is_open (void) const
| returns true if a shared library is loaded/open
std::string | getPluginName (void) const
| returns the name of the plugin that is currently open
void | open (const std::string &plugin_name)
void | openFile (const std::string &plugin_file)
void | openStaticLinked (const std::string &plugin_name, void *create_func, void *destroy_func)
void | close (void)
| closes plug-in library

## Static Public Member Functions

static bool | findPluginFile (std::string &path_to_file, const std::string &name)
static bool | findConfigFile (std::string &path_to_file, const std::string &name)
static bool | findStaticEntryPoint (const std::string &plugin_name, void **create_func, void **destroy_func)
static void | addStaticEntryPoint (const std::string &plugin_name, void *create_func, void *destroy_func)
static void | checkCygwinPath (boost::filesystem::path &final_path, const std::string &path_string)
static void | addPluginDirectory (const std::string &dir)
| appends a directory to the plug-in search path
static void | resetPluginDirectories (void)
| clears all directories from the plug-in search path
static void | getAllPluginNames (std::vector< std::string > &plugin_names)
| returns a list of all Plugins found in all Plugin directories

## Protected Member Functions

| PionPlugin (void)
| default constructor is private (use PionPluginPtr class to create objects)
| PionPlugin (const PionPlugin &p)
| copy constructor
PionPlugin & | operator= (const PionPlugin &p)
| assignment operator
void * | getCreateFunction (void)
| returns a pointer to the plug-in's "create object" function
void * | getDestroyFunction (void)
| returns a pointer to the plug-in's "destroy object" function
void | releaseData (void)
| releases the plug-in's shared library symbols
void | grabData (const PionPlugin &p)
| grabs a reference to another plug-in's shared library symbols

## Classes

class | DirectoryNotFoundException
| exception thrown if the plug-in directory does not exist More...
class | OpenPluginException
| exception thrown if the plug-in file cannot be opened More...
struct | PionPluginData
class | PluginMissingCreateException
| exception thrown if a plug-in library is missing the create() function More...
class | PluginMissingDestroyException
| exception thrown if a plug-in library is missing the destroy() function More...
class | PluginNotFoundException
| exception thrown if the plug-in file cannot be found More...
class | PluginUndefinedException
| exception thrown if the plug-in file cannot be opened More...
class | StaticEntryPoint
| data type for keeping track of the entry points for static plugins

## Member Function Documentation

void pion::PionPlugin::addStaticEntryPoint | ( | const std::string & | plugin_name,
|  | void * | create_func,
|  | void * | destroy_func |
| ) |  |  | `[static]`

adds an entry point for a plugin that is statically linked

Parameters:

  | plugin_name | the 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 367 of file PionPlugin.cpp.

void pion::PionPlugin::checkCygwinPath | ( | boost::filesystem::path & | final_path,
|  | const std::string & | path_string |
| ) |  |  | `[static]`

updates path for cygwin oddities, if necessary

Parameters:

  | final_path | path object for the file, will be modified if necessary
  | start_path | original 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 43 of file PionPlugin.cpp.

Referenced by addPluginDirectory(), and pion::plugins::FileService::setOption().

static bool pion::PionPlugin::findConfigFile | ( | std::string & | path_to_file,
|  | const std::string & | name |
| ) |  |  | `[inline, static]`

searches directories for a valid plug-in configuration file

Parameters:

  | path_to_file | if found, is set to the complete path to the file
  | name | the name of the configuration file to search for

Returns:
  true if the configuration file was found

Definition at line 94 of file PionPlugin.hpp.

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

static bool pion::PionPlugin::findPluginFile | ( | std::string & | path_to_file,
|  | const std::string & | name |
| ) |  |  | `[inline, static]`

searches directories for a valid plug-in file

Parameters:

  | path_to_file | the path to the plug-in file, if found
  | the | name name of the plug-in to search for

Returns:
  true if the plug-in file was found

Definition at line 81 of file PionPlugin.hpp.

Referenced by open().

bool pion::PionPlugin::findStaticEntryPoint | ( | const std::string & | plugin_name,
|  | void ** | create_func,
|  | void ** | destroy_func |
| ) |  |  | `[static]`

finds an entry point for a plugin that is statically linked

Parameters:

  | plugin_name | the name of the plugin to look for
  | 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 347 of file PionPlugin.cpp.

Referenced by pion::PluginManager< PLUGIN_TYPE >::load().

void pion::PionPlugin::open | ( | const std::string & | plugin_name | ) |

opens plug-in library within a shared object file. If the library is already being used by another PionPlugin 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_name | name of the plug-in library to open (without extension, etc.)

Definition at line 70 of file PionPlugin.cpp.

References findPluginFile(), and openFile().

Referenced by pion::PluginManager< PLUGIN_TYPE >::load().

void pion::PionPlugin::openFile | ( | const std::string & | plugin_file | ) |

opens plug-in library within a shared object file. If the library is already being used by another PionPlugin 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_file | shared object file containing the plugin code

Definition at line 80 of file PionPlugin.cpp.

References getPluginName(), pion::PionPlugin::PionPluginData::m_plugin_name, pion::PionPlugin::PionPluginData::m_references, and releaseData().

Referenced by open().

void pion::PionPlugin::openStaticLinked | ( | const std::string & | plugin_name,
|  | void * | create_func,
|  | void * | destroy_func |
| ) |  |  |

opens plug-in library that is statically linked into the program

Parameters:

  | plugin_name | plugin name to be used in future references
  | 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 109 of file PionPlugin.cpp.

References pion::PionPlugin::PionPluginData::m_create_func, pion::PionPlugin::PionPluginData::m_destroy_func, pion::PionPlugin::PionPluginData::m_lib_handle, pion::PionPlugin::PionPluginData::m_plugin_name, pion::PionPlugin::PionPluginData::m_references, and releaseData().

Referenced by pion::PluginManager< PLUGIN_TYPE >::load().

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

- common/include/pion/PionPlugin.hpp
- common/src/PionPlugin.cpp