25template<
typename TPlugin,
typename TPriorities>
67template<
typename TPlugin,
typename TPriorities>
132 ALIB_ASSERT_ERROR( plugin !=
nullptr,
"FSPLUGINS",
"Nullptr provided for plugin." )
135 std::has_virtual_destructor<TPlugin>::value
137 "Can't take responsibility for plug-in destruction. TPlugin has no virtual destructor.")
143 [plugin,
this](
Slot& ppp)
145 ALIB_ASSERT_ERROR( ppp.plugin->GetPriority() != plugin->GetPriority(),
"FSPLUGINS",
146 "PluginContainer::InsertPlugin(): Plug-in with same priority {} exists",
147 ppp.plugin->GetPriority() )
149 return ppp.plugin->GetPriority() < plugin->GetPriority();
151 Slot { plugin, responsibility == lang::Responsibility::Transfer } );
171 return pair.plugin == plugIn;
179 ALIB_WARNING(
"LANG",
"PluginContainer::RemovePlugin(): Plug-in not found for removal.")
195 "PluginContainer::RemovePlugin(): Index out of bounds: {} >= {}", idx,
CountPlugins() )
213 TPlugin* plugin=
nullptr;
215 [priority, &plugin](
Slot& entry)
217 if( entry.priority == priority)
219 plugin= entry.plugin;
261 return plugins[size_t(number)].plugin;
273 return plugins[size_t(number)].priority;
287 [priority](
Slot& pair) { return pair.priority == priority; } );
304 template<
typename TPluginType>
307 return dynamic_cast<TPluginType*
>(
GetPlugin( priority ) );
316 template<
typename TPluginType>
319 TPluginType* cast=
nullptr;
321 if( (cast=
dynamic_cast<TPluginType*
>( ppp.plugin )) !=
nullptr )
TPlugin * GetPlugin(TPriorities priority)
TPlugin * RemovePlugin(TPriorities priority)
TPriorities PrioritiesType
This exposes the template parameter pTPlugin to the outer world.
void RemovePlugin(integer idx)
TPriorities GetPriority(integer number)
bool RemovePlugin(TPlugin *plugIn)
TPlugin * GetPlugin(integer number)
TPlugin PluginType
This exposes the template parameter pTPlugin to the outer world.
PluginList plugins
The plug-ins we have attached in descending priority order.
void InsertPlugin(TPlugin *plugin, lang::Responsibility responsibility=lang::Responsibility::KeepWithSender)
TPluginType * GetPluginTypeSafe(TPriorities priority)
TPluginType * GetPluginTypeSafe()
std::vector< Slot > PluginList
The list that stores the plugins.
TPriorities PrioritiesType
This exposes the template parameter pTPlugin to the outer world.
PrioritiesType priority
The priority of this plug-in.
TPlugin PluginType
This exposes the template parameter TPlugin to the outer world.
PrioritiesType GetPriority() const
Plugin(PrioritiesType pPriority)
#define ALIB_WARNINGS_IGNORE_UNUSED_LAMBDA_CAPTURE
#define ALIB_WARNINGS_RESTORE
#define ALIB_WARNING(domain,...)
#define ALIB_STATIC_ASSERT(CondVariable, Cond, Message)
#define ALIB_ASSERT_WARNING(cond, domain,...)
#define ALIB_ASSERT_ERROR(cond, domain,...)
platform_specific integer
@ KeepWithSender
Keeps responsibility, e.g., when passing an object.
Type definition for elements of the list of plug-ins with their priority.
TPlugin * plugin
The plug-in.