PLCnext API Documentation 23.6.0.37
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

 ModuleFactory (void)=default
 Constructs an ModuleFactory instance.
 
 ModuleFactory (const ModuleFactory &arg)=default
 Copy constructor.
 
 ModuleFactory (ModuleFactory &&arg) noexcept=default
 Move constructor.
 
ModuleFactoryoperator= (const ModuleFactory &arg)=default
 Copy-assignment operator.
 
ModuleFactoryoperator= (ModuleFactory &&arg) noexcept=default
 Move-assignment operator.
 
virtual ~ModuleFactory (void) noexcept=default
 Destructs this instance and frees all resources.
 
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: