PLCnext API Documentation 23.6.0.37
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 // p0065-71068 - DEF - Confusing warning message of C++ compiler - deactivate this warning for Release 23.6
52 // ARP_DEPRECATED("Do not use this protected member any more, use 'LibraryBase::RegisterComponentType<TComponent>(..)' instead.")
54
55private: // fields
56 const Version buildVersion;
57};
58
60// inline methods of class LibraryBase
61
65{
66 return this->buildVersion;
67}
68
74template<class T>
76{
77 this->AddComponentFactoryMethod(TypeName<T>(), &T::Create);
78}
79
86template<class T>
87inline void LibraryBase::RegisterComponentType(const String& typeName)
88{
89 this->AddComponentFactoryMethod(typeName, &T::Create);
90}
91
92}}} // 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:64
ComponentFactory componentFactory
This field is used to register library specific component factory methods.
Definition: LibraryBase.hpp:53
void RegisterComponentType(void)
This template operation registers the as template parameter passed component type,...
Definition: LibraryBase.hpp:75
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