PLCnext API Documentation 25.0.2.69
Public Types | Public Member Functions | List of all members
Arp::System::Commons::Extensibility::ModuleFactory< TModuleInterface > Class Template Reference

Factory class for extension modules More...

#include <ModuleFactory.hxx>

Public Types

using ModuleInterfacePtr = std::unique_ptr< TModuleInterface >
 
using FactoryFunction = std::function< ModuleInterfacePtr()>
 
using FactoryFunctions = std::vector< std::pair< String, FactoryFunction > >
 

Public Member Functions

ModuleInterfacePtr Create (const String &moduleName) const
 Creates a module instance More...
 
std::vector< StringGetModuleNames () const
 Returns all known module names
 
void AddFactoryFunction (const String &moduleName, FactoryFunction function)
 Adds a factory function More...
 

Detailed Description

template<typename TModuleInterface>
class Arp::System::Commons::Extensibility::ModuleFactory< TModuleInterface >

Factory class for extension modules

Template Parameters
TModuleInterfaceType of the base class for the modules

This class is used as an internal factory used by the ModuleLibraryBase.

Member Function Documentation

◆ AddFactoryFunction()

template<typename TModuleInterface >
void Arp::System::Commons::Extensibility::ModuleFactory< TModuleInterface >::AddFactoryFunction ( const String moduleName,
FactoryFunction  function 
)

Adds a factory function

Parameters
moduleNameName of the module, typically the common type name
functionFunction pointer to the factory function

Throws an exception if the name is already present.

◆ Create()

template<typename TModuleInterface >
ModuleFactory< TModuleInterface >::ModuleInterfacePtr Arp::System::Commons::Extensibility::ModuleFactory< TModuleInterface >::Create ( const String moduleName) const

Creates a module instance

Parameters
moduleNameName of the module, typically the common type name
Returns
std::unique_ptr to the created module, nullptr if the was no factory function with the given name

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