dlvhex  2.5.0
PluginContainer Class Reference

Collects and administrates all available plugins. More...

#include <include/dlvhex2/PluginContainer.h>

Collaboration diagram for PluginContainer:

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

Detailed Description

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.


Member Typedef Documentation

typedef boost::shared_ptr<LoadedPlugin> PluginContainer::LoadedPluginPtr

Definition at line 118 of file PluginContainer.h.

Definition at line 120 of file PluginContainer.h.

Definition at line 121 of file PluginContainer.h.


Constructor & Destructor Documentation

Copy-constructor.

Must not be used, would duplicate library unloads.

Parameters:
cOther 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().


Member Function Documentation

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.

Parameters:
pluginPointer to an internal plugin.

Definition at line 357 of file PluginContainer.cpp.

Referenced by loadPlugins().

Add loaded plugin (do not extract plugin atoms).

Parameters:
lpluginPointer 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.

Returns:
Vector of 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.

Parameters:
searchpathPath(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.

Parameters:
oStream to print the output to.

Definition at line 364 of file PluginContainer.cpp.

References pluginInterfaces.


Field Documentation

Loaded plugins (interface ptrs).

Definition at line 135 of file PluginContainer.h.

Referenced by addInternalPlugin(), printUsage(), and ~PluginContainer().

Loaded plugins.

Definition at line 132 of file PluginContainer.h.

std::string PluginContainer::searchPath [private]

Current search path.

Definition at line 129 of file PluginContainer.h.

Referenced by loadPlugins().


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