10#ifndef HPP_ALIB_LANG_PLUGINS
11#define HPP_ALIB_LANG_PLUGINS 1
13#if !defined(HPP_ALIB) && !defined(ALIB_DOX)
19#if !defined(HPP_ALIB_LANG_COMMONENUMS_DEFS)
23#if !defined (HPP_ALIB_ENUMS_BITWISE)
27#if !defined (_GLIBCXX_VECTOR) && !defined(_VECTOR_)
31#if !defined (_GLIBCXX_ALGORITHM) && !defined(_ALGORITHM_)
52template<
typename pTPlugin,
typename pTPriorities>
123 ALIB_ASSERT_ERROR( plugin !=
nullptr,
"FSPLUGINS",
"Nullptr provided for plugin." )
125 static_assert( std::has_virtual_destructor<TPlugin>::value
127 "Can't take responsibility for plug-in destruction. TPlugin has no virtual destructor." );
130 [priority](
Slot& ppp)
132 ALIB_ASSERT_ERROR( ppp.priority != priority,
"FSPLUGINS",
133 "PluginContainer::InsertPlugin(): Plug-in with same priority exists" )
135 return ppp.priority < priority;
160 return pair.plugin == plugIn;
168 ALIB_WARNING(
"PluginContainer::RemovePlugin(): Plug-in not found for removal." )
184 "FSPLUGINS: PluginContainer::RemovePlugin(): Index out of bounds: ", idx )
204 [priority, &plugin](
Slot& entry)
206 if( entry.priority == priority)
208 plugin= entry.plugin;
216 "PluginContainer::RemovePlugin(): No Plug-in was removed " )
251 return plugins[
static_cast<size_t>(number)].plugin;
265 [priority](
Slot& pair) { return pair.priority == priority; } );
282 template<
typename TPluginType>
285 return dynamic_cast<TPluginType*
>(
GetPlugin( priority ) );
294 template<
typename TPluginType>
297 TPluginType* casted=
nullptr;
299 if( (casted=
dynamic_cast<TPluginType*
>( ppp.plugin )) != nullptr )
void InsertPlugin(TPlugin *plugin, TPriorities priority, lang::Responsibility responsibility=lang::Responsibility::KeepWithSender)
void RemovePlugin(integer idx)
TPlugin * GetPlugin(integer number)
bool RemovePlugin(TPlugin *plugIn)
TPlugin * RemovePlugin(TPriorities priority)
TPlugin * GetPlugin(TPriorities priority)
TPluginType * GetPluginTypeSafe()
std::vector< Slot > plugins
TPluginType * GetPluginTypeSafe(TPriorities priority)
#define ALIB_WARNING(...)
#define ALIB_ASSERT_MODULE(modulename)
#define ALIB_ASSERT_ERROR(cond,...)
#define ALIB_ASSERT_WARNING(cond,...)
platform_specific integer
@ KeepWithSender
Keeps responsibility, e.g. when passing an object.
@ Transfer
Transfers responsibility to the receiving party.
TPriorities priority
The priority of the plug-in.
TPlugin * plugin
The plug-in.