7#ifndef ARP_USE_ARP_SYSTEM_RSC
8#include "Arp/Base/Rsc/ServiceManager.hpp"
15#include "Arp/Base/Rsc/Commons/Rsc.hpp"
16#include "Arp/Base/Rsc/Commons/IRscService.hpp"
17#include "Arp/Base/Rsc/Commons/Services/IRscServiceProxyFactory.hpp"
20namespace Arp::Base::Rsc::Commons::Services
27namespace CommonRemoting
31class IServiceProxyFactory;
32class CRemotingServiceProviderBase;
35namespace Arp {
namespace System {
namespace Rsc
38using namespace CommonRemoting;
42class ARP_EXPORT
ARP_DEPRECATED("Use
Arp::Base::Rsc::ServiceManager instead.") ServiceManager
51 ServiceManager(
void) =
delete;
53 ServiceManager(
const ServiceManager& arg) =
delete;
55 ServiceManager(ServiceManager&& arg)
noexcept =
delete;
57 ServiceManager& operator=(
const ServiceManager& arg) =
delete;
59 ServiceManager& operator=(ServiceManager&& arg)
noexcept =
delete;
61 ~ServiceManager(
void) =
delete;
68 template<
class TService,
class TServiceFactory>
69 static void PublishService(
void);
75 template<
class TService,
class TServiceFactory>
76 static void PublishService(
const char* serviceProviderName);
82 template<
class TService>
83 static typename TService::Ptr GetService(
void);
91 template<
class TService>
92 static typename TService::Ptr GetService(
const char* serviceProviderName);
98 template<
class TService>
99 static bool TryGetService(
typename TService::Ptr& result);
106 template<
class TService>
107 static bool TryGetService(
const char* serviceProviderName,
typename TService::Ptr& result);
114 static void PublishComponentService(
const char* componentName,
const char* serviceName,
IRscServiceFactory* pServiceFactory);
119 static void PublishRemotingServiceProvider(CRemotingServiceProviderBase* pServiceProvider);
126 template<
class TService,
class TServiceFactory>
127 static void PublishRemotingService(
const char* serviceProviderName);
134 template<
class TService>
135 static typename TService::Ptr GetRemotingService(
const char* serviceProviderName);
138 static void PublishService(
const char* serviceProviderName,
const char* serviceName,
IRscServiceFactory& serviceFactory);
139 static void PublishService(
const char* serviceProviderName,
const char* serviceName, IServiceFactory& serviceFactory);
141 static IService* GetService(
const char* serviceProviderName, IServiceProxyFactory& proxyFactory);
147ARP_DEPRECATED_IGNORE_BEGIN
149template<
class TService,
class TServiceFactory>
152 String serviceProviderName = TServiceFactory::GetInstance().GetServiceProviderName();
156template<
class TService,
class TServiceFactory>
162template<
class TService,
class TServiceFactory>
163inline void ServiceManager::PublishRemotingService(
const char* serviceProviderName)
168template<
class TService>
171 String serviceProviderName = TService::GetProxyFactory().GetServiceProviderName();
172 if (serviceProviderName.IsEmpty())
174 throw ArgumentException::Create(
"TService", TService::GetProxyFactory().GetServiceName(),
"Service does not specify a service provider");
176 typename TService::Ptr result;
177 if (!ServiceManager::TryGetService<TService>(serviceProviderName, result))
179 throw InvalidOperationException(
"Could not retrieve service '{0}' from service provider '{1}'.", TypeName<TService>(), serviceProviderName);
184template<
class TService>
187 typename TService::Ptr result;
188 if (!ServiceManager::TryGetService<TService>(serviceProviderName, result))
190 throw InvalidOperationException(
"Could not retrieve service '{0}' from service provider '{1}'.", TypeName<TService>(), serviceProviderName);
195template<
class TService>
198 const String& serviceProviderName = TService::GetProxyFactory().GetServiceProviderName();
199 if (serviceProviderName.IsEmpty())
201 throw ArgumentException::Create(
"TService", TService::GetProxyFactory().GetServiceName(),
"Service does not specify a service provider");
204 return ServiceManager::TryGetService<TService>(serviceProviderName, result);
207template<
class TService>
212 if (servicePtr ==
nullptr)
216 result = dynamic_pointer_cast<TService>(servicePtr);
217 if (result ==
nullptr)
220 throw InvalidCastException(
"The service does not implement service interface '{0}'.", TService::GetProxyFactory().GetServiceName());
226template<
class TService>
227inline typename TService::Ptr ServiceManager::GetRemotingService(
const char* serviceProviderName)
230 if (pService ==
nullptr)
232 return typename TService::Ptr();
234 TService* pResult =
dynamic_cast<TService*
>(pService);
235 if (pResult ==
nullptr)
238 throw InvalidCastException(
"The service does not implement service interface '{0}'.", TService::GetProxyFactory().GetServiceName());
241 return typename TService::Ptr(pResult);
244ARP_DEPRECATED_IGNORE_END
static ArgumentException Create(const char *paramName, const T ¶mValue)
Creates an ArgumentException using a default message.
Definition: ArgumentException.hpp:92
This is the base interface of all Rsc services.
Definition: IRscService.hpp:22
std::shared_ptr< IRscService > Ptr
The shared_ptr type of IRscService.
Definition: IRscService.hpp:25
Interface for service factory classes to create instances of the service implementation,...
Definition: IRscServiceFactory.hpp:26
Interface for service proxy factories to create service proxies used by RSC clients.
Definition: IRscServiceProxyFactory.hpp:22
This class is used to publish and retrieve RSC services.
Definition: ServiceManager.hpp:31
static void PublishService(void)
Registers a RSC service.
Definition: ServiceManager.hpp:139
static bool TryGetService(typename TService::Ptr &result)
Tries to get a service of the service provider Arp.
Definition: ServiceManager.hpp:101
static TService::Ptr GetService(void)
Gets a RSC service. The service provider is determined by the proxy factory.
Definition: ServiceManager.hpp:65
Namespace for the Remote Service Call implementation
Root namespace for the PLCnext API
class ARP_DEPRECATED("Use Arp::Enum<T> instead.") EnumStrings
Deprecated! The class implements an adapter for enums to define the string literals of the enum entri...
Definition: EnumStrings.hxx:38