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"    18 class IServiceFactory;
    19 class IServiceProxyFactory;
    20 class CRemotingServiceProviderBase;
    23 namespace Arp { 
namespace System { 
namespace Rsc
    48     template<
class TService, 
class TServiceFactory>
    49     static void PublishService(
void);
    55     template<
class TService, 
class TServiceFactory>
    56     static void PublishService(
const char* serviceProviderName);
    63     template<
class TService>
    64     static typename TService::Ptr GetService(
void);
    72     template<
class TService>
    73     static typename TService::Ptr GetService(
const char* serviceProviderName);
    79     template<
class TService>
    80     static bool TryGetService(
typename TService::Ptr& result);
    87     template<
class TService>
    88     static bool TryGetService(
const char* serviceProviderName, 
typename TService::Ptr& result);
    95     static void PublishComponentService(
const char* componentName, 
const char* serviceName, IRscServiceFactory* pServiceFactory);
   100     static void PublishRemotingServiceProvider(CRemotingServiceProviderBase* pServiceProvider);
   107     template<
class TService, 
class TServiceFactory>
   108     static void PublishRemotingService(
const char* serviceProviderName);
   115     template<
class TService>
   116     static typename TService::Ptr GetRemotingService(
const char* serviceProviderName);
   119     static void             PublishService(
const char* serviceProviderName, 
const char* serviceName, IRscServiceFactory& serviceFactory);
   120     static void             PublishService(
const char* serviceProviderName, 
const char* serviceName, IServiceFactory& serviceFactory);
   121     static IRscService*     GetService(
const char* serviceProviderName, IRscServiceProxyFactory& proxyFactory);
   122     static IService*        GetService(
const char* serviceProviderName, IServiceProxyFactory& proxyFactory);
   128 template<
class TService, 
class TServiceFactory>
   129 inline void ServiceManager::PublishService(
void)
   131     String serviceProviderName = TServiceFactory::GetInstance().GetServiceProviderName();
   132     ServiceManager::PublishService(serviceProviderName, TService::GetProxyFactory().GetServiceName(), TServiceFactory::GetInstance());
   135 template<
class TService, 
class TServiceFactory>
   136 inline void ServiceManager::PublishService(
const char* serviceProviderName)
   138     if (serviceProviderName == 
nullptr || strlen(serviceProviderName) == 0)
   140         throw ArgumentNullException::Create(
"serviceProviderName");
   142     ServiceManager::PublishService(serviceProviderName, TService::GetProxyFactory().GetServiceName(), TServiceFactory::GetInstance());
   145 template<
class TService, 
class TServiceFactory>
   146 inline void ServiceManager::PublishRemotingService(
const char* serviceProviderName)
   148     if (serviceProviderName == 
nullptr || strlen(serviceProviderName) == 0)
   150         throw ArgumentNullException::Create(
"serviceProviderName");
   152     ServiceManager::PublishService(serviceProviderName, TService::GetProxyFactory().GetServiceName(), TServiceFactory::GetInstance());
   155 template<
class TService>
   156 inline typename TService::Ptr ServiceManager::GetService()
   158     String serviceProviderName = TService::GetProxyFactory().GetServiceProviderName();
   159     if (serviceProviderName.IsEmpty())
   161         throw ArgumentException::Create(
"TService", TService::GetProxyFactory().GetServiceName(), 
"Service does not specify a service provider");
   163     typename TService::Ptr result;
   164     if (!ServiceManager::TryGetService<TService>(serviceProviderName, result))
   171 template<
class TService>
   172 inline typename TService::Ptr ServiceManager::GetService(
const char* serviceProviderName)
   174     if (serviceProviderName == 
nullptr || strlen(serviceProviderName) == 0)
   176         throw ArgumentNullException::Create(
"serviceProviderName");
   178     typename TService::Ptr result;
   179     if (!ServiceManager::TryGetService<TService>(serviceProviderName, result))
   186 template<
class TService>
   187 inline bool ServiceManager::TryGetService(
typename TService::Ptr& result)
   189     const String& serviceProviderName = TService::GetProxyFactory().GetServiceProviderName();
   190     if (serviceProviderName.IsEmpty())
   192         throw ArgumentException::Create(
"TService", TService::GetProxyFactory().GetServiceName(), 
"Service does not specify a service provider");
   195     return ServiceManager::TryGetService<TService>(serviceProviderName, result);
   198 template<
class TService>
   199 inline bool ServiceManager::TryGetService(
const char* serviceProviderName, 
typename TService::Ptr& result)
   201     if (serviceProviderName == 
nullptr || strlen(serviceProviderName) == 0)
   203         throw ArgumentNullException::Create(
"serviceProviderName");
   206     IRscService* pService = ServiceManager::GetService(serviceProviderName, TService::GetProxyFactory());
   208     if (pService == 
nullptr)
   212     TService* pResult = 
dynamic_cast<TService*
>(pService);
   213     if (pResult == 
nullptr)
   216         throw InvalidCastException(
"The service does not implement service interface '{0}'.", TService::GetProxyFactory().GetServiceName());
   219     result = 
typename TService::Ptr(pResult);
   223 template<
class TService>
   224 inline typename TService::Ptr ServiceManager::GetRemotingService(
const char* serviceProviderName)
   226     if (serviceProviderName == 
nullptr || strlen(serviceProviderName) == 0)
   228         throw ArgumentNullException::Create(
"serviceProviderName");
   230     IService* pService = ServiceManager::GetService(serviceProviderName, TService::GetProxyFactory());
   231     if (pService == 
nullptr)
   233         return typename TService::Ptr(); 
   235     TService* pResult = 
dynamic_cast<TService*
>(pService);
   236     if (pResult == 
nullptr)
   239         throw InvalidCastException(
"The service does not implement service interface '{0}'.", TService::GetProxyFactory().GetServiceName());
   242     return typename TService::Ptr(pResult);
 This (meta programming) class provides the C++ typename of the as template argument passed type...
Definition: TypeName.hxx:55
 
Namespace for classes and interfaces for the Remote Service Call implementation
 
This exception is used when an invalid cast occurs.
Definition: InvalidCastException.hpp:14
 
Definition: RemotingReader.hpp:10
 
This exception is used when a method call is invalid for object's current state.
Definition: InvalidOperationException.hpp:14
 
Use this class to publish and retrieve Rsc and Remoting services.
Definition: ServiceManager.hpp:31
 
Root namespace for the PLCnext API
 
Base interface for all Rsc service interface. 
Definition: IRscService.hpp:18
 
System components used by the System, Device, Plc or Io domains.