RCFProto
 All Classes Functions Typedefs
MulticastClientTransport.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_MULTICASTCLIENTTRANSPORT_HPP
20 #define INCLUDE_RCF_MULTICASTCLIENTTRANSPORT_HPP
21 
22 #include <memory>
23 #include <string>
24 #include <vector>
25 
26 #include <boost/shared_ptr.hpp>
27 
28 #include <RCF/ClientTransport.hpp>
29 #include <RCF/Export.hpp>
30 #include <RCF/ThreadLibrary.hpp>
31 
32 namespace RCF {
33 
34  typedef boost::shared_ptr< ClientTransportAutoPtr > ClientTransportAutoPtrPtr;
35  typedef std::vector< ClientTransportAutoPtrPtr > ClientTransportList;
36 
37  // Special purpose client transport for sending messages in parallel on multiple sub-transports.
38  class RCF_EXPORT MulticastClientTransport : public ClientTransport
39  {
40  public:
41 
42  TransportType getTransportType();
43 
44  std::auto_ptr<ClientTransport> clone() const;
45 
46  EndpointPtr getEndpointPtr() const;
47 
48  void doSendOnTransports(
49  Lock& lock,
50  ClientTransportList& transportList,
51  const std::vector<ByteBuffer> & data,
52  unsigned int timeoutMs);
53 
54  int send(
55  ClientTransportCallback & clientStub,
56  const std::vector<ByteBuffer> & data,
57  unsigned int timeoutMs);
58 
59  int receive(
60  ClientTransportCallback & clientStub,
61  ByteBuffer & byteBuffer,
62  unsigned int timeoutMs);
63 
64  bool isConnected();
65 
66  void connect(
67  ClientTransportCallback & clientStub,
68  unsigned int timeoutMs);
69 
70  void disconnect(
71  unsigned int timeoutMs);
72 
73  void addTransport(
74  ClientTransportAutoPtr clientTransportAutoPtr);
75 
76  void setTransportFilters(
77  const std::vector<FilterPtr> & filters);
78 
79  void getTransportFilters(
80  std::vector<FilterPtr> & filters);
81 
82  void setTimer(boost::uint32_t timeoutMs, ClientTransportCallback *pClientStub);
83 
84  void dropIdleTransports();
85  void pingAllTransports();
86 
87  void close();
88 
89  std::size_t getTransportCount();
90 
91  private:
92 
93  void bringInNewTransports();
94 
95  Mutex mClientTransportsMutex;
96  ClientTransportList mClientTransports;
97  ClientTransportList mClientTransportsTemp;
98  ClientTransportList mClientTransportsSending;
99 
100  Mutex mAddedClientTransportsMutex;
101  ClientTransportList mAddedClientTransports;
102 
103  ClientTransportAutoPtr mMulticastTemp;
104  };
105 
106 } // namespace RCF
107 
108 #endif // ! INCLUDE_RCF_MULTICASTCLIENTTRANSPORT_HPP