PLCnext API Documentation  21.0.0.35466
ComponentBase.hpp
1 //
3 // Copyright PHOENIX CONTACT Electronics GmbH
4 //
6 #pragma once
7 #include "Arp/System/Core/Arp.h"
8 #include "Arp/System/Acf/ILibrary.hpp"
9 #include "Arp/System/Acf/IComponent.hpp"
10 #include "Arp/System/Rsc/Services/IRscServiceFactory.hpp"
11 
12 namespace Arp { namespace System { namespace Acf
13 {
14 
15 using namespace Arp::System::Rsc::Services;
16 
22 class ComponentBase : public IComponent
23 {
24 public: // construction/destruction
32  ComponentBase(IApplication& application, ILibrary& library, const String& fullName, ComponentCategory category, uint32 startOrder = std::numeric_limits<uint32>::max(), bool isSingleton = false);
34  virtual ~ComponentBase(void) = default;
35 
36 public: // properties
37  IApplication& GetApplication(void)const final;
38  ILibrary& GetLibrary(void)const final;
39  String GetFullName(void)const final;
40  Version GetVersion(void)const final;
41  ComponentCategory GetComponentCategory(void)const final;
42  uint32 GetStartOrder(void)const final;
43  bool IsSingleton(void)const final;
44  bool IsRequired(void)const final;
45 
46 public: // IComponent operations
47  void Initialize(void)override;
48  void LoadSettings(const String& settingsPath)override;
49  void SetupSettings(void)override;
50  void SubscribeServices(void)override;
51  void PublishServices(void)override;
52  void LoadConfig(void)override;
53  void SetupConfig(void)override;
54  void ResetConfig(void)override;
55  void Dispose(void)override;
56  void PowerDown(void)override;
57 
58 protected: // service operations used by derived items
63  template<class TService, class TServiceFactory>
64  void PublishComponentService(void);
65 
66 private: // methods
67  void PublishComponentService(const char* serviceName, IRscServiceFactory* pServiceFactory);
68 
69 private: // deleted methods
70  ComponentBase(const ComponentBase& arg) = delete;
71  ComponentBase& operator=(const ComponentBase& arg) = delete;
72 
73 private: // fields
74  IApplication& application;
75  ILibrary& library;
76  String fullName;
77  ComponentCategory componentCategory = ComponentCategory::None;
78  uint32 startOrder = 0;
79  bool isSingleton = false;
80  bool isRequired = false;
81 };
82 
84 // inline methods of class ComponentBase
85 
87 {
88  return this->application;
89 }
90 
92 {
93  return this->library;
94 }
95 
97 {
98  return this->fullName;
99 }
100 
102 {
103  return this->library.GetBuildVersion();
104 }
105 
107 {
108  return this->componentCategory;
109 }
110 
112 {
113  return this->startOrder;
114 }
115 
116 inline bool ComponentBase::IsSingleton()const
117 {
118  return this->isSingleton;
119 }
120 
121 inline bool ComponentBase::IsRequired()const
122 {
123  return this->isRequired;
124 }
125 
126 template<class TService, class TServiceFactory>
128 {
129  this->PublishComponentService(TService::GetProxyFactory().GetServiceName(), TServiceFactory::Create(*this));
130 }
131 
132 }}} // end of namesapce Arp::System::Acf
bool IsSingleton(void) const final
Determines if this component is a singleton, that is, it&#39;s instantiated only once on the entire syste...
Definition: ComponentBase.hpp:116
Any Acf Library shall implement this interface.
Definition: ILibrary.hpp:21
Namespace for classes and interfaces for the Remote Service Call implementation
Definition: IRscReadEnumerator.hxx:9
std::uint32_t uint32
The Arp unsigned integer type of 4 byte size.
Definition: PrimitiveTypes.hpp:35
This is the most important basic interface of the Arp platform. Any component shall implement this in...
Definition: IComponent.hpp:77
IApplication & GetApplication(void) const final
Gets the applicatopn instance of the actual process which loaded this component.
Definition: ComponentBase.hpp:86
void PublishComponentService(void)
Publishes a component service for this component instance.
Definition: ComponentBase.hpp:127
Use this class as base class for all Acf components.
Definition: ComponentBase.hpp:22
uint32 GetStartOrder(void) const final
Gets the start order of this component.
Definition: ComponentBase.hpp:111
This interface shall be implemented by the application class.
Definition: IApplication.hpp:18
ILibrary & GetLibrary(void) const final
Gets the library instance of this component.
Definition: ComponentBase.hpp:91
This class represents the version of a special SDK or Arp build.
Definition: BasicVersion.hpp:34
Root namespace for the PLCnext API
ComponentCategory GetComponentCategory(void) const final
Gets the ComponentCategory of this component.
Definition: ComponentBase.hpp:106
ComponentCategory
This enumeration determines the category of a component.
Definition: ComponentCategory.hpp:14
bool IsRequired(void) const final
Determines if this component is required.
Definition: ComponentBase.hpp:121
String GetFullName(void) const final
Gets the full qualified name of this component
Definition: ComponentBase.hpp:96
System components used by the System, Device, Plc or Io domains.
Version GetVersion(void) const final
Gets the version of this component which defaults to the build version of the related library...
Definition: ComponentBase.hpp:101