Logo Search packages:      
Sourcecode: condor version File versions  Download package

PluginManager< PluginType > Class Template Reference

#include <PluginManager.h>

List of all members.


Detailed Description

template<class PluginType>
class PluginManager< PluginType >

NOTE: dlopen and dlfcn.h must be available for this code to work.

This plugin manager is primarily to provide a single place for the code in initialize(), and to hold the registered plugins. A daemon specific plugin manager should be created for each daemon. For instance, a daemon that has plugins will need to have a DaemonPlugin class that provides an API the plugins for that daemon must implement, and a DaemonPluginManager that provides a place for plugins to register and may implement functions that apply to all registered plugins. Example:

class ExamplePlugin { public: ExamplePlugin() { PluginManager<ExamplePlugin>::registerPlugin(this); } virtual void action() = 0; };

class ExamplePluginManager : public PluginManager<ExamplePlugin> { public: static void actionAll() { ExamplePlugin *plugin; SimpleList<ExamplePlugin *> plugins = getPlugins(); plugins.Rewind(); while (plugins.Next(plugin)) { plugin->action(); } } };

template PluginManager<ExamplePlugin>; template SimpleList<ExamplePlugin *>;

Then somewhere in the Example daemon's initialization:

ExamplePluginManager::initialize();

And somewhere in the Example daemon:

ExamplePluginManager::actionAll();

An ExamplePlugin may look like this:

struct ExampleExamplePlugin : public ExamplePlugin { void action() { printf("Action\n"); } }; static ExampleExamplePlugin instance;

The Load() function checks param("PLUGINS") for a list of plugin object files, failing that it checks for param("PLUGIN_DIR") and takes all files in the directory ending in ".so" as possible plugins. If neither param is found, nothing is done. It is advised that configurations contain SUBSYSTEM.PLUGINS or SUBSYSTEM.PLUGIN_DIR to avoid trying to load plugins for one daemon in another. Once initialize() has a list of plugins it tries to dlopen them and reports errors. The plugins themselves must have a static instance of themselves and the plugin class they implement must have a constructor that registers the plugins. initialize() does not lookup a symbol in the plugins object file to call for registration.

Definition at line 88 of file PluginManager.h.


Static Public Member Functions

static SimpleList< PluginType * > & getPlugins ()
static void Load ()
static bool registerPlugin (PluginType *)

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

Generated by  Doxygen 1.6.0   Back to index