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