sipxportlib
Version 3.3
|
#include <PluginHooks.h>
Public Member Functions | |
PluginHooks (const char *hookFactoryName, const char *hookPrefix) | |
Construct a manager for a set of hooks. More... | |
~PluginHooks () | |
void | readConfig (OsConfigDb &configDb) |
Read what hooks are configured, and instantiate and configure each hook. More... | |
size_t | entries () const |
Return the total number of plugins within. More... | |
Protected Attributes | |
UtlString | mFactory |
The factory routine name for this hook class. More... | |
UtlString | mPrefix |
The prefix name for the OsConfigDb values. More... | |
UtlSortedList | mConfiguredHooks |
The list of configured hooks. More... | |
Friends | |
class | PluginIterator |
A PluginHooks object is used to add dynamically loaded libraries (a "plugin") to a program at run time. The module to be loaded must implement a class derived from the Plugin abstract class.
An object of this class manages all the configured plugin hooks for a program. A class of plugin hooks is identified by a factory routine name used to obtain a hook instance from the dynamic library, and an OsConfigDb prefix string:
The libraries are loaded and configured by the readConfig method:
To invoke the plugins, see PluginIterator.
PluginHooks | ( | const char * | hookFactoryName, |
const char * | hookPrefix | ||
) |
Construct a manager for a set of hooks.
hookFactoryName | The factory routine name for this hook class. |
hookPrefix | The prefix name for the OsConfigDb values. |
~PluginHooks | ( | ) |
void readConfig | ( | OsConfigDb & | configDb | ) |
Read what hooks are configured, and instantiate and configure each hook.
This method actually reads the program configuration from the configDb passed in. Each entry that has the prefix followed by "_HOOK_LIBRARY" configures a plugin library.
For the example code above, it would look for entries like:
The readConfig method:
Configuration entries for each hook instance are made with entries like:
Each instance has its own set of configuration entries:
The readConfig method in the hook (which must inherit from Plugin) is passed its own subhash of the configuration data, stripping everything through the '.' following the instance name, so in the example above, the CopyAction hook would be passed the equivalent of this configuration:
readConfig can be called more than once.
size_t entries | ( | ) | const |
Return the total number of plugins within.
|
friend |
|
protected |
The factory routine name for this hook class.
|
protected |
The prefix name for the OsConfigDb values.
|
protected |
The list of configured hooks.