Remote Call Framework 3.1
RcfClient.hpp
Go to the documentation of this file.
1 
2 //******************************************************************************
3 // RCF - Remote Call Framework
4 //
5 // Copyright (c) 2005 - 2019, Delta V Software. All rights reserved.
6 // http://www.deltavsoft.com
7 //
8 // RCF is distributed under dual licenses - closed source or GPL.
9 // Consult your particular license for conditions of use.
10 //
11 // If you have not purchased a commercial license, you are using RCF
12 // under GPL terms.
13 //
14 // Version: 3.1
15 // Contact: support <at> deltavsoft.com
16 //
17 //******************************************************************************
18 
20 
21 #ifndef INCLUDE_RCF_RCFCLIENT_HPP
22 #define INCLUDE_RCF_RCFCLIENT_HPP
23 
24 #include <functional>
25 #include <map>
26 #include <memory>
27 
28 #include <RCF/Export.hpp>
29 #include <RCF/RcfFwd.hpp>
30 #include <RCF/Exception.hpp>
31 
32 namespace RCF {
33 
34 
35  RCF_EXPORT void setCurrentCallDesc(std::string& desc, RCF::MethodInvocationRequest& request, const char * szFunc, const char * szArity);
36 
37  // Returns the runtime name of the given RCF interface.
38  template<typename Interface>
39  inline std::string getInterfaceName(Interface * = 0)
40  {
41  return Interface::getInterfaceName();
42  }
43 
45  class RCF_EXPORT I_RcfClient
46  {
47  public:
48 
49  virtual ~I_RcfClient();
50 
51  I_RcfClient(const std::string & interfaceName);
52 
54  const std::string & interfaceName,
55  ServerBindingPtr serverStubPtr);
56 
58  const std::string & interfaceName,
59  const Endpoint & endpoint,
60  const std::string & serverBindingName = "");
61 
63  const std::string & interfaceName,
64  ClientTransportUniquePtr clientTransportUniquePtr,
65  const std::string & serverBindingName = "");
66 
68  const std::string & interfaceName,
69  const ClientStub & clientStub,
70  const std::string & serverBindingName = "");
71 
72  // Copy construction/assignment.
73 
75  const std::string & interfaceName,
76  const I_RcfClient & rhs);
77 
78  I_RcfClient & operator=(const I_RcfClient & rhs);
79 
80  // Move construction/assignment.
81 
83  const std::string & interfaceName,
84  I_RcfClient && rhs);
85 
86  I_RcfClient & operator=(I_RcfClient && rhs);
87 
88  void swap(I_RcfClient & rhs);
89 
90  void setClientStubPtr(ClientStubPtr clientStubPtr);
91 
93  ClientStub & getClientStub();
94 
96  const ClientStub & getClientStub() const;
97 
98  ClientStubPtr getClientStubPtr() const;
99  ServerBindingPtr getServerStubPtr() const;
100  ServerBinding & getServerStub();
101 
102  protected:
103 
104  void checkClientInitialized();
105 
106  ClientStubPtr mClientStubPtr;
107  ServerBindingPtr mServerStubPtr;
108 
109  // These are preserved even when swapping or moving.
110  std::string mInterfaceName;
111  mutable std::string mServerBindingName;
112 
113  typedef Void V;
114  };
115 
116  typedef std::shared_ptr<I_RcfClient> RcfClientPtr;
117 
118  // some meta-programming functionality needed by the macros in IDL.hpp
119 
120  typedef char (&yes_type)[1];
121  typedef char (&no_type)[2];
122 
123  template<typename U> static yes_type RCF_hasRcfClientTypedef(typename U::RcfClientT *);
124  template<typename U> static no_type RCF_hasRcfClientTypedef(...);
125 
126  template<typename T>
127  struct GetRcfClient
128  {
129  typedef typename T::RcfClientT type;
130  };
131 
132  template<typename T>
133  struct Identity
134  {
135  typedef T type;
136  };
137 
138  template<typename T>
139  struct GetInterface
140  {
141  // tried eval_if here, but got some weird errors with vc71
142  typedef typename If<
143  Bool< sizeof(yes_type) == sizeof(RCF_hasRcfClientTypedef<T>(0)) >,
144  GetRcfClient<T>,
145  Identity<T> >::type type0;
146 
147  typedef typename type0::type type;
148  };
149 
150  class default_ { char a[1]; };
151  class defined_ { char a[2]; };
152  template<typename T> class Dummy {};
153 
154 } // namespace RCF
155 
156 #endif // ! INCLUDE_RCF_RCFCLIENT_HPP
Base class of all RcfClient<> templates.
Definition: RcfClient.hpp:45
Represents the binding of a server-side servant object to a RCF interface.
Definition: ServerStub.hpp:326
Controls the client side of a RCF connection.
Definition: ClientStub.hpp:82
std::unique_ptr< ClientTransport > ClientTransportUniquePtr
Unique pointer wrapper for RCF::ClientTransport.
Definition: RcfFwd.hpp:43
std::shared_ptr< ServerBinding > ServerBindingPtr
Reference counted wrapper for RCF::ServerBinding.
Definition: RcfFwd.hpp:248
Base class for all network endpoint types.
Definition: Endpoint.hpp:41
Definition: AmiIoHandler.hpp:24