template<typename TPlugin, typename TPriorities>
class alib::lang::PluginContainer< TPlugin, TPriorities >
This class usually is used as a base class for types that need to manage simple plug-ins. Within ALib itself, for example classes Configuration and Compiler inherit from this class.
Plug-ins are organized with a prioritization. This means, that plug-ins which are inserted with a higher priority are 'asked' first, and those with a lower value become 'asked' only if higher prioritized plug-ins did not answer.
However, a derived class can deviate from this behavior. Using the typical ALib class design, all internal fields are protected
, hence freely accessible by derived classes.
- Template Parameters
-
TPlugin | The type of the plug-ins managed. This type is publicly exposed as PluginType. |
TPriorities | The enumeration type providing the default "plug-in slots" and priorities of the plug-ins managed. This type is publicly exposed as PrioritiesType. |
Definition at line 89 of file lang/plugins.hpp.
template<typename TPlugin , typename TPriorities >
template<typename TPluginType >
TPluginType * GetPluginTypeSafe |
( |
TPriorities | priority | ) |
|
|
inline |
Same as GetPlugin, but converts the plug-in found to the template type, which has to be explicitly provided with the invocation of this method.
A type-check is performed using standard C++ dynamic_cast
mechanics. If the plugin has a different type, nullptr
is returned.
- Template Parameters
-
TPluginType | The type of the plugin to search. |
- Parameters
-
priority | The priority of the plug-in to return. |
- Returns
- The plug-in of requested type and priority.
nullptr
if not available.
Definition at line 326 of file lang/plugins.hpp.
template<typename TPlugin , typename TPriorities >
Checks if any plug-in is attached. This is useful if optional configuration objects are used. In case no plug-in was attached (by a third party), the effort to declare and search a variable can be omitted.
- Returns
true
if this object has any plugin set, false
otherwise.
Definition at line 259 of file lang/plugins.hpp.
template<typename TPlugin , typename TPriorities >
Remove the plug-in at the given idx from the list of plug-ins.
Responsibility for deletion of removed plug-ins is passed to the remover in case the plug-in was inserted with parameter responsibility set to Responsibility::Transfer.
- Parameters
-
idx | The index of the plug-in to remove. |
Definition at line 212 of file lang/plugins.hpp.
template<typename TPlugin , typename TPriorities >
bool RemovePlugin |
( |
TPlugin * | plugIn | ) |
|
|
inline |
Removes the given plug-in from the list of plug-ins.
Responsibility for deletion of removed plug-ins is passed to the remover in case the plug-in was inserted with parameter responsibility set to Responsibility::Transfer.
- Parameters
-
plugIn | The plug-in to be removed. |
- Returns
true
if the plug-in was removed, else false
, which indicates that the given plug-in was not found.
Definition at line 187 of file lang/plugins.hpp.
template<typename TPlugin , typename TPriorities >
TPlugin * RemovePlugin |
( |
TPriorities | priority | ) |
|
|
inline |
Remove the plug-in with the given priority.
Responsibility for deletion of removed plug-ins is passed to the remover in case the plug-in was inserted with parameter responsibility set to Responsibility::Transfer.
- Parameters
-
priority | The priority of the plug-in to remove. |
- Returns
true
if the plug-in was removed, else false
, which indicates that no plug-in with the given priority was found.
Definition at line 231 of file lang/plugins.hpp.