IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
SocketsPoolCB.h
1 // SocketsPoolCB.h:
3 // ----------------
4 //
15 
16 #ifndef __IPSDKCORE_SOCKETSPOOLCB_H__
17 #define __IPSDKCORE_SOCKETSPOOLCB_H__
18 
19 // suppression warnings
20 // warning C4275: non dll-interface class 'boost::noncopyable_::noncopyable' used as base for dll-interface class 'ipsdk::core::SocketsPoolCB'
21 #pragma warning (push)
22 #pragma warning (disable : 4275)
23 
26 #include <IPSDKCore/Config/Network/NetworkDescriptionTypes.h>
27 #include <IPSDKComm/TcpIp/CollPeersCB.h>
28 #include <IPSDKUtil/Tools/ProcessingResult.h>
29 #include <boost/thread/mutex.hpp>
30 #include <boost/thread/condition_variable.hpp>
31 #include <boost/chrono/duration.hpp>
32 #include <boost/noncopyable.hpp>
33 #include <vector>
34 
35 namespace ipsdk {
36 namespace core {
37 
38 class RegisterComputerInfo;
39 
42 
44  public boost::noncopyable
45 {
46  // friend class for protected member access
47  friend class RegisterComputerInfo;
48 
49 public:
52  SocketsPoolCB();
53  ~SocketsPoolCB();
55 
56 // methods
57 public:
59  bool isInit() const;
60 
62  void init(const LocalNetworkDescription& localNetworkDescription);
63 
66  const LocalNetworkDescription& getLocalNetworkDescription() const;
67 
70  BoolResult waitForEndOfInit(const boost::chrono::milliseconds& duration) const;
71 
72 protected:
77  void onConnected(const tcpip::SocketDesc& socketDesc);
78 
84  void onListenFailed(ipUInt16 acceptorId,
85  const boost::system::error_code& ec);
86 
92  void onConnectionFailed(const Guid& socketGuid,
93  const tcpip::EndPoint& remoteEndPoint,
94  const boost::system::error_code& ec);
95 
100  void onDeliveryFailed(const Guid& socketGuid,
101  ipUInt64 nDeliveryId);
102 
107  void onDelivered(const tcpip::SocketDesc& socketDesc,
108  ipUInt64 nDeliveryId);
109 
112  void simpleActionThread(const tcpip::SocketDesc& socketDesc,
113  const ActionPtr& pAction);
114 
120  void onRead(const tcpip::SocketDesc& socketDesc,
121  const SerializationObjectPtr pObj);
122 
129  void onConnectionLost(const tcpip::SocketDesc& socketDesc,
130  const boost::system::error_code& ec);
131 
138  void onConnectionClosed(const Guid& socketGuid, bool bOnUserRequest);
139 
143  void notifyConnection(const tcpip::Address& remoteAddress,
144  const AddressColl& slavesAddressColl);
145 
146 // attributes
147 protected:
150 
153 
156 
159 
161  mutable boost::mutex _mutex;
162 
165  mutable boost::condition_variable _condition;
166 
168  bool _bInit;
169 };
170 
173 
174 inline bool
176 {
177  return _bInit;
178 }
179 
182 
183 } // end of namespace core
184 } // end of namespace ipsdk
185 
186 #pragma warning (pop)
187 
188 #endif // __IPSDKCORE_SOCKETSPOOLCB_H__
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
bool isInit() const
retrieve object initialization flag
Definition: SocketsPoolCB.h:175
serializable overlay of boost::asio::endpoint
Definition: EndPoint.h:34
uint64_t ipUInt64
Base types definition.
Definition: BaseTypes.h:55
AddressColl _pendingAddressColl
collection of expected ip address connections still pending
Definition: SocketsPoolCB.h:155
Definition of import/export macro for library.
boost::shared_ptr< BaseAction > ActionPtr
shared pointer to BaseAction
Definition: ActionTypes.h:54
derived class of asio io address for ipsdk::tcpip namespace integration
Definition: Types.h:86
#define IPSDKCORE_API
Import/Export macro for library IPSDKCore.
Definition: IPSDKCoreExports.h:27
bool _bInit
object initialization flag
Definition: SocketsPoolCB.h:168
boost::mutex _mutex
mutex used for concurrent accesses protection
Definition: SocketsPoolCB.h:161
AddressColl _unexpectedAddressColl
collection of unexpected ip address connections
Definition: SocketsPoolCB.h:158
Class encapsulating an auto initialized uuid.
Definition: Guid.h:27
Definition: SocketDesc.h:35
boost::condition_variable _condition
Definition: SocketsPoolCB.h:165
AddressColl _globalAddressColl
collection of all known ip addresses
Definition: SocketsPoolCB.h:152
Class encapsulating network description for multi-machine processings has seen by local machine...
Definition: LocalNetworkDescription.h:38
callback class, whose methods are automatically called each time an event associated to the attached ...
Definition: SocketsPoolCB.h:43
boost::shared_ptr< BaseSerializationObject > SerializationObjectPtr
shared pointer to a base serialization object
Definition: SerializationTypes.h:23
LocalNetworkDescriptionPtr _pLocalNetworkDescription
network description associated to local computer
Definition: SocketsPoolCB.h:149
Action allowing to register a remote computer information on local machine.
Definition: RegisterComputerInfo.h:34
boost::shared_ptr< LocalNetworkDescription > LocalNetworkDescriptionPtr
shared pointer to local network description
Definition: NetworkDescriptionTypes.h:37
std::set< tcpip::Address > AddressColl
ordered collection of ip address
Definition: NetworkDescriptionTypes.h:25
Callback class, intended to be used by CollPeers class, and whose methods will be called each time an...
Definition: CollPeersCB.h:36
Predefined types for actions management.
uint16_t ipUInt16
Base types definition.
Definition: BaseTypes.h:51