IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
SocketsPool.h
1 // SocketsPool.h:
3 // --------------
4 //
14 
15 #ifndef __IPSDKCORE_SOCKETSPOOL_H__
16 #define __IPSDKCORE_SOCKETSPOOL_H__
17 
19 
20 // suppression warnings
21 // warning C4251: 'ipsdk::core::SocketsPool::_pCollPeers' : class
22 // 'boost::shared_ptr<T>' needs to have dll-interface to be used by clients of
23 // class 'ipsdk::core::SocketsPool'
24 // warning C4275: non dll-interface class 'boost::noncopyable_::noncopyable'
25 // used as base for dll-interface class 'ipsdk::core::SocketsPool'
26 #pragma warning (push)
27 #pragma warning (disable : 4251 4275)
28 
29 #include <IPSDKComm/TcpIp/SocketDesc.h>
30 #include <IPSDKComm/TcpIp/Types.h>
31 #include <IPSDKUtil/BaseTypes.h>
32 #include <IPSDKUtil/Tools/Guid.h>
33 
34 // --- Includes boost
35 #include <boost/noncopyable.hpp>
36 
37 namespace ipsdk {
38 namespace core {
39 
40 class LocalNetworkDescription;
41 class SocketsPoolCB;
42 
45 
46 class IPSDKCORE_API SocketsPool : boost::noncopyable
47 {
48 public:
50  static SocketsPool& getInstance();
51 
52 protected:
55  SocketsPool();
56  ~SocketsPool();
58 
59 // methods
60 public:
67  void init(const LocalNetworkDescription& localNetworkDescription);
68 
71  bool isInit() const;
72 
76  const SocketsPoolCB& getSocketsPoolCB() const;
77  SocketsPoolCB& getSocketsPoolCB();
79 
82  void asyncConnect(const tcpip::Address& remoteAddress);
83 
89  void asyncClose(const Guid& socketGuid);
90 
98  ipUInt64 asyncDeliver(const SerializationObjectPtr& pObj);
99 
110  ipUInt64 asyncDeliver(const Guid& socketGuid,
111  const SerializationObjectPtr& pObj,
112  const ipsdk::tcpip::DlvCbFun& f=0);
113 
123  Guid addCnxLossCB(const Guid& socketGuid, const tcpip::CnxLossCbFun& f);
124 
131  void clearCnxLossCB(const Guid& socketGuid);
132 
142  void removeCnxLossCB(const Guid& socketGuid, const Guid& cbId);
143 
146  void clear();
147 
152  boost::optional<tcpip::SocketDesc> getSocketDesc(const Guid& socketGuid) const;
153 
159  boost::optional<Guid> getGuid(const tcpip::Address& remoteAddress) const;
160 
163  const tcpip::Address& getLocalAddress() const;
164 
165 // attributes
166 protected:
169 
171  boost::shared_ptr<SocketsPoolCB> _pSocketsPoolCB;
172 
175 
178 };
179 
182 
183 } // end of namespace core
184 } // end of namespace ipsdk
185 
186 #pragma warning (pop)
187 
188 #endif // __IPSDKCORE_SOCKETSPOOL_H__
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
boost::shared_ptr< CollPeers > CollPeersPtr
typedefs for shared_ptr on main tcpip classes
Definition: Types.h:109
boost::shared_ptr< SocketsPoolCB > _pSocketsPoolCB
pointer to used call back object
Definition: SocketsPool.h:171
uint64_t ipUInt64
Base types definition.
Definition: BaseTypes.h:55
ipUInt16 _portNumber
used socket port number
Definition: SocketsPool.h:177
Definition of import/export macro for library.
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
Base types for multiplatform compatibility.
Class encapsulating an auto initialized uuid.
Definition: Guid.h:27
boost::function3< void, const Guid &, ipUInt64, bool > DlvCbFun
function prototype associated to socket delivery callback
Definition: Types.h:116
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
Predefined types for ip addresses management.
tcpip::Address _localAddress
tcpip address informations associated to local computer
Definition: SocketsPool.h:174
Singleton used for socket pool management.
Definition: SocketsPool.h:46
uint16_t ipUInt16
Base types definition.
Definition: BaseTypes.h:51
tcpip::CollPeersPtr _pCollPeers
pointer to implementation object
Definition: SocketsPool.h:168
boost::function2< void, const SocketDesc &, const boost::system::error_code & > CnxLossCbFun
function prototype associated to socket connection loss callback
Definition: Types.h:120