8#include "Arp/Base/Core/CommonTypeName.hxx"
9#include "Arp/Base/Rsc/Commons/Rsc.hpp"
10#include "Arp/Base/Rsc/Commons/IRscService.hpp"
11#include "Arp/Base/Commons/Exceptions/InvalidCastException.hpp"
12#include "Arp/Base/Commons/Exceptions/InvalidOperationException.hpp"
15namespace Arp::Base::Rsc::Commons::Services
21namespace Arp::Base::Rsc
40 template<
class TService>
static typename TService::Ptr GetService(
void);
41 template<
class TService>
static typename TService::Ptr GetService(
const char* serviceProviderName);
42 template<
class TService>
static bool TryGetService(
typename TService::Ptr& result);
43 template<
class TService>
static bool TryGetService(
const char* serviceProviderName,
typename TService::Ptr& result);
45 template<
class TService,
class TServiceFactory>
static void PublishService(
void);
46 template<
class TService,
class TServiceFactory>
static void PublishService(
const char* serviceProviderName);
48 static void PublishComponentService(
const char* componentName,
const char* serviceName,
IRscServiceFactory* pServiceFactory);
51 static Impl& GetImpl(
void);
55 static void PublishServiceInternal(
const char* serviceProviderName,
const char* serviceName,
IRscServiceFactory& serviceFactory);
65template<
class TService>
68 typename TService::Ptr result;
69 if (!ServiceManager::TryGetService<TService>(result))
86template<
class TService>
89 typename TService::Ptr result;
90 if (!ServiceManager::TryGetService<TService>(serviceProviderName, result))
101template<
class TService>
104 return ServiceManager::TryGetService<TService>(
"", result);
116template<
class TService>
119 IRscService::Ptr servicePtr = ServiceManager::GetServiceInternal(TService::GetProxyFactory(), serviceProviderName);
121 if (servicePtr ==
nullptr)
125 result = dynamic_pointer_cast<TService>(servicePtr);
126 if (result ==
nullptr)
139template<
class TService,
class TServiceFactory>
142 String serviceProviderName = TServiceFactory::GetInstance().GetServiceProviderName();
143 ServiceManager::PublishServiceInternal(serviceProviderName,
CommonTypeName<TService>().GetFullName(), TServiceFactory::GetInstance());
154template<
class TService,
class TServiceFactory>
157 ServiceManager::PublishServiceInternal(serviceProviderName,
CommonTypeName<TService>().GetFullName(), TServiceFactory::GetInstance());
This exception is thrown when an invalid cast occurs.
Definition: InvalidCastException.hpp:17
This exception is thrown when an operation cannot be executed because the related state is invalid.
Definition: InvalidOperationException.hpp:16
This (meta programming) class provides the type-name according the CLS (common language specification...
Definition: CommonTypeName.hxx:33
This class represents the Arp String. The implementation is based on std::string.
Definition: String.hpp:39
This (meta programming) class provides the C++ type-name of the as template argument passed type.
Definition: TypeName.hxx:20
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:32
static void PublishService(void)
Registers a RSC service.
Definition: ServiceManager.hpp:140
static bool TryGetService(typename TService::Ptr &result)
Tries to get a service of the service provider Arp.
Definition: ServiceManager.hpp:102
static TService::Ptr GetService(void)
Gets a RSC service. The service provider is determined by the proxy factory.
Definition: ServiceManager.hpp:66
ServiceManager(void)=delete
makes this class pure static