RCFProto
 All Classes Functions Typedefs
RcfClient.hpp
1 
2 //******************************************************************************
3 // RCF - Remote Call Framework
4 //
5 // Copyright (c) 2005 - 2013, 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: 2.0
15 // Contact: support <at> deltavsoft.com
16 //
17 //******************************************************************************
18 
19 #ifndef INCLUDE_RCF_RCFCLIENT_HPP
20 #define INCLUDE_RCF_RCFCLIENT_HPP
21 
22 #include <boost/mpl/eval_if.hpp>
23 #include <boost/mpl/bool_fwd.hpp>
24 #include <boost/shared_ptr.hpp>
25 #include <boost/utility/enable_if.hpp>
26 
27 #include <RCF/CheckRtti.hpp>
28 #include <RCF/ClientStub.hpp>
29 #include <RCF/Export.hpp>
30 
31 namespace RCF {
32 
33  class ClientStub;
34  class ServerBinding;
35  class RcfSession;
36 
37  typedef boost::shared_ptr<ClientStub> ClientStubPtr;
38  typedef boost::shared_ptr<ServerBinding> ServerBindingPtr;
39 
40  typedef boost::function2<
41  void,
42  int,
43  RcfSession &> InvokeFunctor;
44 
45  typedef std::map<std::string, InvokeFunctor> InvokeFunctorMap;
46 
47  RCF_EXPORT void setCurrentCallDesc(std::string& desc, RCF::MethodInvocationRequest& request, const char * szFunc, const char * szArity);
48 
49  // Base class of all RcfClient<> templates.
50  class RCF_EXPORT I_RcfClient
51  {
52  public:
53 
54  virtual ~I_RcfClient();
55 
56  I_RcfClient(const std::string & interfaceName);
57 
58  I_RcfClient(
59  const std::string & interfaceName,
60  ServerBindingPtr serverStubPtr);
61 
62  I_RcfClient(
63  const std::string & interfaceName,
64  const Endpoint & endpoint,
65  const std::string & targetName_ = "");
66 
67  I_RcfClient(
68  const std::string & interfaceName,
69  ClientTransportAutoPtr clientTransportAutoPtr,
70  const std::string & targetName_ = "");
71 
72  I_RcfClient(
73  const std::string & interfaceName,
74  const ClientStub & clientStub,
75  const std::string & targetName_ = "");
76 
77  I_RcfClient(
78  const std::string & interfaceName,
79  const I_RcfClient & rhs);
80 
81  I_RcfClient & operator=(const I_RcfClient & rhs);
82 
83  void swap(I_RcfClient & rhs);
84 
85  void setClientStubPtr(ClientStubPtr clientStubPtr);
86 
87  ClientStub & getClientStub();
88  const ClientStub & getClientStub() const;
89  ClientStubPtr getClientStubPtr() const;
90  ServerBindingPtr getServerStubPtr() const;
91  ServerBinding & getServerStub();
92 
93  protected:
94 
95  ClientStubPtr mClientStubPtr;
96  ServerBindingPtr mServerStubPtr;
97  std::string mInterfaceName;
98 
99  typedef Void V;
100  };
101 
102  typedef boost::shared_ptr<I_RcfClient> RcfClientPtr;
103 
104  // some meta-programming functionality needed by the macros in IDL.hpp
105 
106  typedef char (&yes_type)[1];
107  typedef char (&no_type)[2];
108 
109  template<typename U> static yes_type RCF_hasRcfClientTypedef(typename U::RcfClientT *);
110  template<typename U> static no_type RCF_hasRcfClientTypedef(...);
111 
112  template<typename T>
113  struct GetRcfClient
114  {
115  typedef typename T::RcfClientT type;
116  };
117 
118  template<typename T>
119  struct Identity
120  {
121  typedef T type;
122  };
123 
124  template<typename T>
125  struct GetInterface
126  {
127  // tried eval_if here, but got some weird errors with vc71
128  typedef typename boost::mpl::if_c<
129  sizeof(yes_type) == sizeof(RCF_hasRcfClientTypedef<T>(0)),
130  GetRcfClient<T>,
131  Identity<T> >::type type0;
132 
133  typedef typename type0::type type;
134  };
135 
136  class default_ { char a[1]; };
137  class defined_ { char a[2]; };
138  template<typename T> class Dummy {};
139 
140 } // namespace RCF
141 
142 #endif // ! INCLUDE_RCF_RCFCLIENT_HPP