RCFProto
 All Classes Functions Typedefs
InProcessTransport.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_INPROCESSTRANSPORT_HPP
20 #define INCLUDE_RCF_INPROCESSTRANSPORT_HPP
21 
22 #include <RCF/ClientTransport.hpp>
23 #include <RCF/Export.hpp>
24 #include <RCF/RcfSession.hpp>
25 
26 namespace RCF {
27 
28  class InProcessRemoteAddress : public RemoteAddress
29  {
30  public:
31  InProcessRemoteAddress(InProcessTransport & transport) : mTransport(transport)
32  {
33  }
34 
35  private:
36 
37  std::string string() const
38  {
39  return "In process endpoint.";
40  }
41 
42  InProcessTransport & mTransport;
43  };
44 
45  class RCF_EXPORT InProcessTransport :
46  public ClientTransport,
47  public SessionState,
48  public ServerTransport,
49  public ServerTransportEx
50  {
51  public:
52  InProcessTransport(RcfServer & server, RcfServer * pCallbackServer = NULL);
53  ~InProcessTransport();
54 
55  TransportType getTransportType();
56 
57  private:
58 
59  RcfServer & mServer;
60  RcfServer * mpCallbackServer;
61  RcfSessionPtr mSessionPtr;
62  RcfSessionPtr mOppositeSessionPtr;
63 
64  InProcessRemoteAddress mRemoteAddress;
65 
66  bool isInProcess();
67 
68  void doInProcessCall(ClientStub & clientStub);
69 
70  // I_ClientTransport
71  std::auto_ptr<ClientTransport> clone() const;
72 
73  EndpointPtr getEndpointPtr() const;
74 
75  int send(
76  ClientTransportCallback & clientStub,
77  const std::vector<ByteBuffer> & data,
78  unsigned int timeoutMs);
79 
80  int receive(
81  ClientTransportCallback & clientStub,
82  ByteBuffer & byteBuffer,
83  unsigned int timeoutMs);
84 
85  bool isConnected();
86 
87  void connect(
88  ClientTransportCallback & clientStub,
89  unsigned int timeoutMs);
90 
91  void disconnect(
92  unsigned int timeoutMs);
93 
94  void setTransportFilters(
95  const std::vector<FilterPtr> & filters);
96 
97  void getTransportFilters(
98  std::vector<FilterPtr> & filters);
99 
100  void setTimer(
101  boost::uint32_t timeoutMs,
102  ClientTransportCallback * pClientStub);
103 
104  // I_SessionState
105  void postRead();
106  ByteBuffer getReadByteBuffer();
107  void postWrite(std::vector<ByteBuffer> &byteBuffers);
108  void postClose();
109  ServerTransport & getServerTransport();
110  const RemoteAddress & getRemoteAddress();
111  //void setTransportFilters(const std::vector<FilterPtr> &filters);
112  //void getTransportFilters(std::vector<FilterPtr> &filters);;
113 
114  // I_ServerTransport
115  ServerTransportPtr clone();
116 
117  // I_ServerTransportEx
118  ClientTransportAutoPtr
119  createClientTransport(
120  const Endpoint &endpoint);
121 
122  SessionPtr
123  createServerSession(
124  ClientTransportAutoPtr & clientTransportAutoPtr,
125  StubEntryPtr stubEntryPtr,
126  bool keepClientConnection);
127 
128  ClientTransportAutoPtr
129  createClientTransport(
130  SessionPtr sessionPtr);
131 
132  bool
133  reflect(
134  const SessionPtr &sessionPtr1,
135  const SessionPtr &sessionPtr2);
136 
137  bool
138  isConnected(
139  const SessionPtr &sessionPtr);
140  };
141 
142 } // namespace RCF
143 
144 #endif // ! INCLUDE_RCF_INPROCESSTRANSPORT_HPP