PLCnext API Documentation 23.6.0.37
ComponentBase.hpp
1
2//
3// Copyright PHOENIX CONTACT Electronics GmbH
4//
6#pragma once
8#include "Arp/System/Acf/ILibrary.hpp"
9#include "Arp/System/Acf/IComponent.hpp"
10#include "Arp/System/Rsc/Services/IRscServiceFactory.hpp"
11
12namespace Arp { namespace System { namespace Acf
13{
14
15using namespace Arp::System::Rsc::Services;
16
23{
24public: // construction/destruction
33 IApplication& application,
34 ILibrary& library,
35 const String& fullName,
36 ComponentCategory category,
37 uint32 startOrder = GetDefaultStartOrder(),
38 bool isSingleton = false);
39
41 ~ComponentBase(void)override = default;
42
43public: // properties
44 IApplication& GetApplication(void)const final;
45 ILibrary& GetLibrary(void)const final;
46 String GetFullName(void)const final;
47 Version GetVersion(void)const final;
49 uint32 GetStartOrder(void)const final;
50 bool IsSingleton(void)const final;
51 bool IsRequired(void)const final;
52
53public: // static
54 static uint32 GetDefaultStartOrder(void);
55
56public: // IComponent operations
57 void Initialize(void)override;
58 void LoadSettings(const String& settingsPath)override;
59 void SetupSettings(void)override;
60 void SubscribeServices(void)override;
61 void PublishServices(void)override;
62 void LoadConfig(void)override;
63 void SetupConfig(void)override;
64 void ResetConfig(void)override;
65 void Dispose(void)override;
66 void PowerDown(void)override;
67
68protected: // service operations used by derived items
73 template<class TService, class TServiceFactory>
74 void PublishComponentService(void);
75
76private: // methods
77 void PublishComponentService(const char* serviceName, IRscServiceFactory* pServiceFactory);
78
79private: // deleted methods
80 ComponentBase(const ComponentBase& arg) = delete;
81 ComponentBase& operator=(const ComponentBase& arg) = delete;
82
83private: // fields
84 IApplication& application;
85 ILibrary& library;
86 String fullName;
88 uint32 startOrder = 0;
89 bool isSingleton = false;
90 bool isRequired = false;
91
92private: // static fields
93 static const uint32 maxComponentStartOrder;
94 static const uint32 customComponentStartOrderShift;
95};
96
98// inline methods of class ComponentBase
99
101{
102 return this->application;
103}
104
106{
107 return this->library;
108}
109
111{
112 return this->fullName;
113}
114
116{
117 return this->library.GetBuildVersion();
118}
119
121{
122 return this->componentCategory;
123}
124
126{
127 return this->startOrder;
128}
129
131{
132 return this->isSingleton;
133}
134
136{
137 return this->isRequired;
138}
139
140template<class TService, class TServiceFactory>
142{
143 this->PublishComponentService(TService::GetProxyFactory().GetServiceName(), TServiceFactory::Create(*this));
144}
145
146}}} // end of namesapce Arp::System::Acf
This class represents the version of a special SDK or Arp build.
Definition: BasicVersion.hpp:36
Use this class as base class for all Acf components.
Definition: ComponentBase.hpp:23
void Initialize(void) override
Initializes this component: creates singletons, makes any registrations, creates any resources not de...
Version GetVersion(void) const final
Gets the version of this component which defaults to the build version of the related library.
Definition: ComponentBase.hpp:115
ComponentCategory GetComponentCategory(void) const final
Gets the ComponentCategory of this component.
Definition: ComponentBase.hpp:120
void SubscribeServices(void) override
Subscribes services required by this component.
void PublishServices(void) override
Publishes components services.
bool IsSingleton(void) const final
Determines if this component is a singleton, that is, it's instantiated only once on the entire syste...
Definition: ComponentBase.hpp:130
void LoadSettings(const String &settingsPath) override
Loads components firmware settings.
void LoadConfig(void) override
Loads components project configuration.
String GetFullName(void) const final
Gets the full qualified name of this component
Definition: ComponentBase.hpp:110
IApplication & GetApplication(void) const final
Gets the applicatopn instance of the actual process which loaded this component.
Definition: ComponentBase.hpp:100
void PowerDown(void) override
This operation is called on a power breakdown event and executes component specific actions when powe...
void Dispose(void) override
Disposes component.
ComponentBase(IApplication &application, ILibrary &library, const String &fullName, ComponentCategory category, uint32 startOrder=GetDefaultStartOrder(), bool isSingleton=false)
Constructs an <see cref = "IComponentFactory" / > instance.
void SetupSettings(void) override
Sets up components settings which were loaded in LoadSettings.
~ComponentBase(void) override=default
The default destructor.
bool IsRequired(void) const final
Determines if this component is required.
Definition: ComponentBase.hpp:135
void PublishComponentService(void)
Publishes a component service for this component instance.
Definition: ComponentBase.hpp:141
ILibrary & GetLibrary(void) const final
Gets the library instance of this component.
Definition: ComponentBase.hpp:105
void SetupConfig(void) override
Sets up components configuration which was loaded in LoadConfig.
uint32 GetStartOrder(void) const final
Gets the start order of this component.
Definition: ComponentBase.hpp:125
void ResetConfig(void) override
Resets components project configuration.
This interface shall be implemented by the application class.
Definition: IApplication.hpp:19
This is the most important basic interface of the Arp platform. Any component shall implement this in...
Definition: IComponent.hpp:81
Any Acf Library shall implement this interface.
Definition: ILibrary.hpp:22
virtual const Version & GetBuildVersion(void) const =0
Gets the SDK version of the SDK used to build the shared library.
std::uint32_t uint32
The Arp unsigned integer type of 4 byte size.
Definition: PrimitiveTypes.hpp:36
ComponentCategory
This enumeration determines the category of a component.
Definition: ComponentCategory.hpp:17
@ System
System components used by the System, Device, Plc or Io domains.
Namespace for classes and interfaces for the Remote Service Call implementation
Root namespace for the PLCnext API