PLCnext API Documentation 24.0.0.71
LibraryBase.hpp
1
2//
3// Copyright PHOENIX CONTACT Electronics GmbH
4//
6#pragma once
8#include "Arp/System/Core/ArpVersion.hpp"
9#include "Arp/System/Acf/ILibrary.hpp"
10#include "Arp/System/Acf/ComponentFactory.hpp"
11
12namespace Arp { namespace System { namespace Acf
13{
14
20class LibraryBase : public ILibrary
21{
22private: // usings
23 using FactoryMethod = ComponentFactory::FactoryMethod;
24
25public: // construction/destruction
29 LibraryBase(AppDomain& appDomain, const Version& buildVersion);
31 virtual ~LibraryBase(void);
32
33public: // overridden operations from ILibrary
35 const Version& GetBuildVersion(void)const override;
36
37public: // operations
38 template<class T>
39 void RegisterComponentType(void);
40 template<class T>
41 void RegisterComponentType(const String& typeName);
42
43private: // deleted methods
44 LibraryBase(const LibraryBase& arg) = delete;
45 LibraryBase& operator=(const LibraryBase& arg) = delete;
46
47private: // methods
48 void AddComponentFactoryMethod(const String& componentType, FactoryMethod factoryMethod);
49
50protected: // fields
51 // ARP_DEPRECATED("Do not use of this protected member any more, use 'LibraryBase::RegisterComponentType<TComponent>(..)' instead.")
53
54private: // fields
55 const Version buildVersion;
56};
57
59// inline methods of class LibraryBase
60
64{
65 return this->buildVersion;
66}
67
73template<class T>
75{
76 this->AddComponentFactoryMethod(TypeName<T>(), &T::Create);
77}
78
85template<class T>
86inline void LibraryBase::RegisterComponentType(const String& typeName)
87{
88 this->AddComponentFactoryMethod(typeName, &T::Create);
89}
90
91}}} // end of namesapce Arp::System::Acf
This class represents a single application domain for each process and is implemented as singleton.
Definition: AppDomain.hpp:119
This class represents the version of a special SDK or Arp build.
Definition: BasicVersion.hpp:36
This class is used by Acf libraries to provide a component factory of the library specific components...
Definition: ComponentFactory.hpp:17
IComponent::Ptr(* FactoryMethod)(IApplication &application, const String &componentName)
The prototype of the component factory method, which might be registered to create components.
Definition: ComponentFactory.hpp:20
This interface is used by the Acf to create components dynamiically through configuration (....
Definition: IComponentFactory.hpp:19
Any Acf Library shall implement this interface.
Definition: ILibrary.hpp:22
Any Acf Library shall derive from this base class.
Definition: LibraryBase.hpp:21
const Version & GetBuildVersion(void) const override
Gets the build version of the SDK/Firmware which was used to build this library.
Definition: LibraryBase.hpp:63
ComponentFactory componentFactory
This field is used to register library specific component factory methods.
Definition: LibraryBase.hpp:52
void RegisterComponentType(void)
This template operation registers the as template parameter passed component type,...
Definition: LibraryBase.hpp:74
LibraryBase(AppDomain &appDomain, const Version &buildVersion)
Constructs an isntance of class LibraryBase.
virtual ~LibraryBase(void)
The default destructor.
IComponentFactory & GetComponentFactory(void) override
Gets the component factory of this library to create instances of its provided components.
This (meta programming) class provides the C++ typename of the as template argument passed type.
Definition: TypeName.hxx:67
@ System
System components used by the System, Device, Plc or Io domains.
Root namespace for the PLCnext API