dlvhex
2.5.0
|
Collects and administrates all available plugins. More...
#include <include/dlvhex2/PluginContainer.h>
Data Structures | |
struct | LoadedPlugin |
Public Types | |
typedef boost::shared_ptr < LoadedPlugin > | LoadedPluginPtr |
typedef std::vector < LoadedPluginPtr > | LoadedPluginVector |
typedef std::vector < PluginInterfacePtr > | PluginInterfaceVector |
Public Member Functions | |
PluginContainer () | |
Constructor. | |
~PluginContainer () | |
Destructor. | |
void | loadPlugins (const std::string &searchpath="") |
Search for plugins in searchpath and open those that are plugins. | |
void | addInternalPlugin (PluginInterfacePtr plugin) |
Add a PluginInterface to the container. | |
const std::vector < PluginInterfacePtr > & | getPlugins () const |
Get container with plugins loaded so far. | |
void | printUsage (std::ostream &o) |
Calls printUsage for each loaded plugin. | |
Private Member Functions | |
PluginContainer (const PluginContainer &p) | |
Copy-constructor. | |
void | addInternalPlugin (LoadedPluginPtr lplugin) |
Add loaded plugin (do not extract plugin atoms). | |
Private Attributes | |
std::string | searchPath |
Current search path. | |
LoadedPluginVector | plugins |
Loaded plugins. | |
PluginInterfaceVector | pluginInterfaces |
Loaded plugins (interface ptrs). |
Collects and administrates all available plugins.
The PluginContainer loads and manages dynamically loaded and internal plugins. It is not aware of the configuration or usage of plugins or plugin atoms in a ProgramCtx.
Important: memory allocation policy: * PluginInterface objects are passed by pointer from the extern "C" plugin import function, they are wrapped in a non-deleting smart pointer by the PluginContainer and must be deallocated by the library itself. * PluginAtom objects are created by PluginInterface::getAtoms and then owned by a smart pointer in the PluginContainer. These smart pointers must contain a "deleter" compiled into the library.
Definition at line 67 of file PluginContainer.h.
typedef boost::shared_ptr<LoadedPlugin> PluginContainer::LoadedPluginPtr |
Definition at line 118 of file PluginContainer.h.
typedef std::vector<LoadedPluginPtr> PluginContainer::LoadedPluginVector |
Definition at line 120 of file PluginContainer.h.
typedef std::vector<PluginInterfacePtr> PluginContainer::PluginInterfaceVector |
Definition at line 121 of file PluginContainer.h.
PluginContainer::PluginContainer | ( | const PluginContainer & | p | ) | [private] |
Copy-constructor.
Must not be used, would duplicate library unloads.
c | Other PluginContainer. |
Constructor.
Definition at line 276 of file PluginContainer.cpp.
Destructor.
Unloads shared libraries (if shared_ptr reference counts are ok).
Definition at line 281 of file PluginContainer.cpp.
References DBGLOG, LOG, pluginInterfaces, and WARNING().
void PluginContainer::addInternalPlugin | ( | PluginInterfacePtr | plugin | ) |
Add a PluginInterface to the container.
The smart pointer will not be reconfigured, so if you need to use a custom "deleter", do it before you call this method.
plugin | Pointer to an internal plugin. |
Definition at line 357 of file PluginContainer.cpp.
Referenced by loadPlugins().
void PluginContainer::addInternalPlugin | ( | LoadedPluginPtr | lplugin | ) | [private] |
Add loaded plugin (do not extract plugin atoms).
lplugin | Pointer to the loaded plugin. |
Definition at line 347 of file PluginContainer.cpp.
References LOG, and pluginInterfaces.
const std::vector<PluginInterfacePtr>& PluginContainer::getPlugins | ( | ) | const [inline] |
Get container with plugins loaded so far.
Definition at line 106 of file PluginContainer.h.
void PluginContainer::loadPlugins | ( | const std::string & | searchpath = "" | ) |
Search for plugins in searchpath and open those that are plugins.
May be called multiple times with different paths. Paths may be separated by ":" just like LD_LIBRARY_PATH.
searchpath | Path(es) to search. |
Definition at line 316 of file PluginContainer.cpp.
References addInternalPlugin(), LOG_SCOPE, and searchPath.
void PluginContainer::printUsage | ( | std::ostream & | o | ) |
Calls printUsage for each loaded plugin.
o | Stream to print the output to. |
Definition at line 364 of file PluginContainer.cpp.
References pluginInterfaces.
Loaded plugins (interface ptrs).
Definition at line 135 of file PluginContainer.h.
Referenced by addInternalPlugin(), printUsage(), and ~PluginContainer().
LoadedPluginVector PluginContainer::plugins [private] |
Loaded plugins.
Definition at line 132 of file PluginContainer.h.
std::string PluginContainer::searchPath [private] |