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 
36  typedef boost::shared_ptr<ClientStub> ClientStubPtr;
37  typedef boost::shared_ptr<ServerBinding> ServerBindingPtr;
38 
39  RCF_EXPORT void setCurrentCallDesc(std::string& desc, RCF::MethodInvocationRequest& request, const char * szFunc, const char * szArity);
40 
41  // Base class of all RcfClient<> templates.
42  class I_RcfClient
43  {
44  public:
45 
46  virtual ~I_RcfClient()
47  {}
48 
49  // Returns a reference to the contained client stub, if one is available, i.e. if the RcfClient<> template is configured as a client stub.
50  virtual ClientStub &getClientStub() = 0;
51  virtual const ClientStub &getClientStub() const = 0;
52 
53  // Returns a reference to the contained server stub, if one is available, i.e. if the RcfClient<> template is configured as a server stub.
54  virtual ServerBinding &getServerStub() = 0;
55 
56  virtual ClientStubPtr getClientStubPtr() const = 0;
57  virtual ServerBindingPtr getServerStubPtr() const = 0;
58  };
59 
60  typedef boost::shared_ptr<I_RcfClient> RcfClientPtr;
61 
62  // some meta-programming functionality needed by the macros in IDL.hpp
63 
64  typedef char (&yes_type)[1];
65  typedef char (&no_type)[2];
66 
67  template<typename U> static yes_type RCF_hasRcfClientTypedef(typename U::RcfClientT *);
68  template<typename U> static no_type RCF_hasRcfClientTypedef(...);
69 
70  template<typename T>
71  struct GetRcfClient
72  {
73  typedef typename T::RcfClientT type;
74  };
75 
76  template<typename T>
77  struct Identity
78  {
79  typedef T type;
80  };
81 
82  template<typename T>
83  struct GetInterface
84  {
85  // tried eval_if here, but got some weird errors with vc71
86  typedef typename boost::mpl::if_c<
87  sizeof(yes_type) == sizeof(RCF_hasRcfClientTypedef<T>(0)),
88  GetRcfClient<T>,
89  Identity<T> >::type type0;
90 
91  typedef typename type0::type type;
92  };
93 
94  class default_ { char a[1]; };
95  class defined_ { char a[2]; };
96  template<typename T> class Dummy {};
97 
98 } // namespace RCF
99 
100 #endif // ! INCLUDE_RCF_RCFCLIENT_HPP