PLCnext API Documentation 25.0.2.69
RscServiceProxyBase.hxx
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
8#include "Arp/Base/Rsc/Commons/Rsc.hpp"
9#include "Arp/Base/Rsc/Commons/Services/IRscServiceProxy.hpp"
10
11namespace Arp::Base::Rsc::Commons::Services
12{
13
19template<class T>
20class RscServiceProxyBase : public IRscServiceProxy, public T
21{
22protected: // usings
23 using ServiceType = T;
24
25public: // construction
26 RscServiceProxyBase(RscHandle providerHandle, RscHandle serviceHandle, RscClient& rscClient);
27
28public: // IServiceProxy operations
29 RscClient& GetRscClient(void)const;
30 String GetServiceName(void)const override;
31 String GetServiceProviderName(void)const override;
32 RscHandle GetServiceHandle(void)override;
33 RscHandle GetServiceProviderHandle(void)override;
34 void ReadServiceHandles(void)override;
35
36private: // fields
37 RscClient& rscClient;
38 RscHandle rscServiceHandle = 0;
39 RscHandle rscServiceProviderHandle = 0;
40};
41
43// inline methods of class RscServiceProxyBase
44
50template<class T>
51inline RscServiceProxyBase<T>::RscServiceProxyBase(RscHandle providerHandle, RscHandle serviceHandle, RscClient& rscClient)
52 : rscServiceProviderHandle(providerHandle)
53 , rscServiceHandle(serviceHandle)
54 , rscClient(rscClient)
55{
56}
57
61template<class T>
63{
64 return this->rscClient;
65}
66
69template<class T>
71{
72 return ServiceType::GetProxyFactory().GetServiceName();
73}
74
77template<class T>
79{
80 return ServiceType::GetProxyFactory().GetServiceProviderName();
81}
82
86template<class T>
88{
89 return this->rscServiceHandle;
90}
91
95template<class T>
97{
98 return this->rscServiceProviderHandle;
99}
100
102template<class T>
104{
105 this->rscClient.GetServiceHandles(
106 this->GetServiceProviderName(),
107 this->GetServiceName(),
108 this->rscServiceProviderHandle,
109 this->rscServiceHandle);
110}
111
112} // end of namespace Arp::Base::Rsc::Commons::Services
This class represents the Arp String. The implementation is based on std::string.
Definition: String.hpp:39
Interface of RSC service proxies used on client side to invoke a service remotely.
Definition: IRscServiceProxy.hpp:20
This class monitors a RSC client call using RAII idiom.
Definition: RscClient.TransactionGuard.hpp:18
Base class for RSC service proxies.
Definition: RscServiceProxyBase.hxx:21
RscHandle GetServiceProviderHandle(void) override
Gets the service provider handle.
Definition: RscServiceProxyBase.hxx:96
void ReadServiceHandles(void) override
Updates the service handle of the remote service instance.
Definition: RscServiceProxyBase.hxx:103
String GetServiceName(void) const override
Gets the service name of this proxy.
Definition: RscServiceProxyBase.hxx:70
RscHandle GetServiceHandle(void) override
Gets the service handle.
Definition: RscServiceProxyBase.hxx:87
RscClient & GetRscClient(void) const
Gets the RscClient to be used for remote or ipc communication.
Definition: RscServiceProxyBase.hxx:62
RscServiceProxyBase(RscHandle providerHandle, RscHandle serviceHandle, RscClient &rscClient)
Constructs a RscServiceProxyBase instance.
Definition: RscServiceProxyBase.hxx:51
String GetServiceProviderName(void) const override
Gets the service provider name of this proxy.
Definition: RscServiceProxyBase.hxx:78
T ServiceType
The service interface type (e.g. IDemoService)
Definition: RscServiceProxyBase.hxx:23