PLCnext API Documentation 25.0.2.69
LibraryBase.hpp
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
7#ifndef ARP_USE_ARP_SYSTEM_ACF_COMMONS
8#include "Arp/Base/Acf/Commons/LibraryBase.hpp"
9namespace Arp::System::Acf
10{
12}
13#else
14#include "Arp/System/Core/Arp.h"
15#include "Arp/System/Core/ArpVersion.hpp"
16#include "Arp/System/Acf/ILibrary.hpp"
17#include "Arp/System/Acf/ComponentFactory.hpp"
18
19namespace Arp { namespace System { namespace Acf
20{
21
27class LibraryBase : public ILibrary
28{
29private: // usings
30 using FactoryMethod = ComponentFactory::FactoryMethod;
31
32public: // construction/destruction
36 LibraryBase(AppDomain& appDomain, const ArpVersion& buildVersion);
37 LibraryBase(LibraryBase&&) = default;
38 LibraryBase(const LibraryBase&) = delete;
39 LibraryBase& operator=(LibraryBase&&) = default;
40 LibraryBase& operator=(const LibraryBase&) = delete;
41 ~LibraryBase(void)override;
42
43public: // overridden operations from ILibrary
44 IComponentFactory& GetComponentFactory(void)override;
45 const ArpVersion& GetBuildVersion(void)const override;
46
47public: // operations
48 template<class T>
49 void RegisterComponentType(void);
50 template<class T>
51 void RegisterComponentType(const String& typeName);
52
53private: // deleted methods
54
55
56private: // methods
57 void AddComponentFactoryMethod(const String& componentType, FactoryMethod factoryMethod);
58
59protected: // fields
60 // ARP_DEPRECATED("Do not use this protected member any more, use 'LibraryBase::RegisterComponentType<TComponent>(..)' instead.")
61 ComponentFactory componentFactory;
62
63private: // fields
64 const ArpVersion buildVersion;
65};
66
68// inline methods of class LibraryBase
69
72inline const ArpVersion& LibraryBase::GetBuildVersion()const
73{
74 return this->buildVersion;
75}
76
82template<class T>
84{
85 this->AddComponentFactoryMethod(TypeName<T>(), &T::Create);
86}
87
94template<class T>
95inline void LibraryBase::RegisterComponentType(const String& typeName)
96{
97 this->AddComponentFactoryMethod(typeName, &T::Create);
98}
99
100}}} // end of namesapce Arp::System::Acf
101
102#endif // ndef ARP_USE_ARP_SYSTEM_ACF_COMMONS
This class serves as base class of all Library classes in Arp component projects.
Definition: LibraryBase.hpp:18
IComponentFactory::FactoryMethod FactoryMethod
The prototype of the component factory method.
Definition: LibraryBase.hpp:23
const ArpVersion & GetBuildVersion(void) const override
Gets the version of the firmware or SDK which was used to build the shared library.
Definition: LibraryBase.cpp:71
void RegisterComponentType(void)
Registers a type of a component of this library.
Definition: LibraryBase.hpp:79
~LibraryBase(void) override
The default destructor.
IComponentFactory & GetComponentFactory(void) override
Gets the component factory of this library to create instances of its provided components.
Definition: LibraryBase.cpp:65
LibraryBase(const ArpVersion &libraryVersion=ArpVersion{})
Constructs a LibraryBase instance.
Definition: LibraryBase.cpp:47
This is the namespace of the Application Component Framework.
Definition: ComponentBase.hpp:72
Root namespace for the PLCnext API