RCFProto
 All Classes Functions Typedefs
RemoteCallContext.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_REMOTECALLCONTEXT_HPP
20 #define INCLUDE_RCF_REMOTECALLCONTEXT_HPP
21 
22 //#include <RCF/AsioServerTransport.hpp>
23 #include <RCF/Export.hpp>
24 #include <RCF/RcfSession.hpp>
25 #include <RCF/ThreadLocalData.hpp>
26 
27 namespace RCF {
28 
29  class I_Parameters;
30  class RcfSession;
31  class AsioNetworkSession;
32 
33  typedef boost::shared_ptr<RcfSession> RcfSessionPtr;
34  typedef boost::shared_ptr<AsioNetworkSession> AsioNetworkSessionPtr;
35 
36  class RCF_EXPORT RemoteCallContextImpl
37  {
38  public:
39 
40  RemoteCallContextImpl(RCF::RcfSession & session);
41 
42  void commit();
43  void commit(const std::exception &e);
44  bool isCommitted() const;
45 
46  private:
47  RcfSessionPtr mRcfSessionPtr;
48  AsioNetworkSessionPtr mNetworkSessionPtr;
49  bool mCommitted;
50 
51  protected:
52  I_Parameters * mpParametersUntyped;
53 
54  };
55 
56  template<
57  typename R,
58  typename A1 = Void,
59  typename A2 = Void,
60  typename A3 = Void,
61  typename A4 = Void,
62  typename A5 = Void,
63  typename A6 = Void,
64  typename A7 = Void,
65  typename A8 = Void,
66  typename A9 = Void,
67  typename A10 = Void,
68  typename A11 = Void,
69  typename A12 = Void,
70  typename A13 = Void,
71  typename A14 = Void,
72  typename A15 = Void>
73  class RemoteCallContext : public RemoteCallContextImpl
74  {
75  public:
76 
77  // If return type is void, change it to RCF::Void.
78  typedef typename boost::mpl::if_<
79  boost::is_same<R, void>,
80  Void,
81  R>::type R_;
82 
83  typedef ServerParameters<
84  R_,
85  A1, A2, A3, A4, A5, A6, A7, A8,
86  A9, A10, A11, A12, A13, A14, A15> ParametersT;
87 
88  RemoteCallContext(RCF::RcfSession & session) : RemoteCallContextImpl(session)
89  {
90  RCF_ASSERT( dynamic_cast<ParametersT *>(mpParametersUntyped) );
91  }
92 
93  ParametersT &parameters()
94  {
95  return * static_cast<ParametersT *>(mpParametersUntyped);;
96  }
97  };
98 
99 } // namespace RCF
100 
101 #endif // ! INCLUDE_RCF_REMOTECALLCONTEXT_HPP