8 #include "Arp/System/Rsc/Services/Rsc.h"
9 #include "Arp/System/Rsc/Services/IRscService.hpp"
10 #include "Arp/System/Rsc/Services/IRscServiceProxy.hpp"
11 #include "Arp/System/Rsc/Services/IRscServiceFactory.hpp"
12 #include "Arp/System/Rsc/Services/IRscServiceProxyFactory.hpp"
15 namespace CommonRemoting
18 class IServiceFactory;
19 class IServiceProxyFactory;
20 class CRemotingServiceProviderBase;
23 namespace Arp {
namespace System {
namespace Rsc
26 using namespace CommonRemoting;
48 template<
class TService,
class TServiceFactory>
49 static void PublishService(
void);
55 template<
class TService,
class TServiceFactory>
56 static void PublishService(
const char* serviceProviderName);
62 template<
class TService>
63 static typename TService::Ptr GetService(
void);
71 template<
class TService>
72 static typename TService::Ptr GetService(
const char* serviceProviderName);
78 template<
class TService>
79 static bool TryGetService(
typename TService::Ptr& result);
86 template<
class TService>
87 static bool TryGetService(
const char* serviceProviderName,
typename TService::Ptr& result);
94 static void PublishComponentService(
const char* componentName,
const char* serviceName, IRscServiceFactory* pServiceFactory);
106 template<
class TService,
class TServiceFactory>
107 static void PublishRemotingService(
const char* serviceProviderName);
114 template<
class TService>
115 static typename TService::Ptr GetRemotingService(
const char* serviceProviderName);
118 static void PublishService(
const char* serviceProviderName,
const char* serviceName, IRscServiceFactory& serviceFactory);
119 static void PublishService(
const char* serviceProviderName,
const char* serviceName, IServiceFactory& serviceFactory);
120 static IRscService* GetService(
const char* serviceProviderName, IRscServiceProxyFactory& proxyFactory);
121 static IService* GetService(
const char* serviceProviderName, IServiceProxyFactory& proxyFactory);
127 template<
class TService,
class TServiceFactory>
130 String serviceProviderName = TServiceFactory::GetInstance().GetServiceProviderName();
134 template<
class TService,
class TServiceFactory>
140 template<
class TService,
class TServiceFactory>
146 template<
class TService>
149 String serviceProviderName = TService::GetProxyFactory().GetServiceProviderName();
150 if (serviceProviderName.
IsEmpty())
152 throw ArgumentException::Create(
"TService", TService::GetProxyFactory().GetServiceName(),
"Service does not specify a service provider");
154 typename TService::Ptr result;
155 if (!ServiceManager::TryGetService<TService>(serviceProviderName, result))
162 template<
class TService>
165 typename TService::Ptr result;
166 if (!ServiceManager::TryGetService<TService>(serviceProviderName, result))
173 template<
class TService>
176 const String& serviceProviderName = TService::GetProxyFactory().GetServiceProviderName();
177 if (serviceProviderName.
IsEmpty())
179 throw ArgumentException::Create(
"TService", TService::GetProxyFactory().GetServiceName(),
"Service does not specify a service provider");
182 return ServiceManager::TryGetService<TService>(serviceProviderName, result);
185 template<
class TService>
190 if (pService ==
nullptr)
194 TService* pResult =
dynamic_cast<TService*
>(pService);
195 if (pResult ==
nullptr)
198 throw InvalidCastException(
"The service does not implement service interface '{0}'.", TService::GetProxyFactory().GetServiceName());
201 result =
typename TService::Ptr(pResult);
205 template<
class TService>
209 if (pService ==
nullptr)
211 return typename TService::Ptr();
213 TService* pResult =
dynamic_cast<TService*
>(pService);
214 if (pResult ==
nullptr)
217 throw InvalidCastException(
"The service does not implement service interface '{0}'.", TService::GetProxyFactory().GetServiceName());
220 return typename TService::Ptr(pResult);
static ArgumentException Create(const char *paramName, const T ¶mValue)
Creates an ArgumentException instance using a default message text.
Definition: ArgumentException.hpp:112
This exception is used when an invalid cast occurs.
Definition: InvalidCastException.hpp:15
This exception is used when a method call is invalid for object's current state.
Definition: InvalidOperationException.hpp:15
Use this class to publish and retrieve Rsc and Remoting services.
Definition: ServiceManager.hpp:32
static TService::Ptr GetService(void)
Gets a Rsc service of the service provider Arp.
Definition: ServiceManager.hpp:147
static bool TryGetService(typename TService::Ptr &result)
Tries to get a service of the service provider Arp.
Definition: ServiceManager.hpp:174
static TService::Ptr GetRemotingService(const char *serviceProviderName)
Gets a Remoting service of the specified service provider.
Definition: ServiceManager.hpp:206
static void PublishComponentService(const char *componentName, const char *serviceName, IRscServiceFactory *pServiceFactory)
Publishes a service of the specified service or type of the specified component, which serves as serv...
static void PublishRemotingService(const char *serviceProviderName)
Publishes a remoting service of the specified service provider.
Definition: ServiceManager.hpp:141
static void PublishService(void)
Registers a Rsc service.
Definition: ServiceManager.hpp:128
static void PublishRemotingServiceProvider(CRemotingServiceProviderBase *pServiceProvider)
Publishes a remoting service provider and all of its services.
Base interface for all Rsc service interface.
Definition: IRscService.hpp:19
This (meta programming) class provides the C++ typename of the as template argument passed type.
Definition: TypeName.hxx:56
bool IsEmpty() const
Determines if this string is empty.
Definition: BasicString.hxx:1076
@ System
System components used by the System, Device, Plc or Io domains.
Namespace for classes and interfaces for the Remote Service Call implementation
Definition: IRscReadEnumerator.hxx:10
Root namespace for the PLCnext API