7#ifndef __PGENERIC_SOCKET_MANAGER_H_IMPL__
8#define __PGENERIC_SOCKET_MANAGER_H_IMPL__
15template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
21template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
29template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
33 it->second->setMode(mode);
40template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
54template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
58 bool b(socket != NULL);
77template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
81 bool b(socket != NULL);
94template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
96 typename std::map<_TSocketKey, PGenericSocket<_TBackend, _TMockBackend>* >::iterator it(
p_mapSocket.find(name));
104template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
119template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
123 return socket->
sendMsg(msg, flag);
135template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
139 return socket->
recvMsg(msg, flag);
149template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
152 typename std::map<_TSocketKey, PGenericSocket<_TBackend, _TMockBackend>* >::iterator it(
p_mapSocket.find(name));
164template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
166 typename std::map<_TSocketKey, PGenericSocket<_TBackend, _TMockBackend>* >::const_iterator it(
p_mapSocket.find(name));
174template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
176 typename std::map<_TSocketKey, PGenericSocket<_TBackend, _TMockBackend>* >::const_iterator it(
p_mapSocket.find(name));
178 return it->second->isConnected();
187template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
bool isSocketExist(const _TSocketKey &name) const
Say if the socket exist with the given name.
bool isConnected(const _TSocketKey &name) const
Say if the given socket is connected.
std::map< _TSocketKey, PGenericSocket< _TBackend, _TMockBackend > * > p_mapSocket
Map of the zmq sockets to be used by the manager.
bool sendMsg(const _TSocketKey &name, typename _TBackend::Message &msg, PSendFlag::PSendFlag flag=PSendFlag::BLOCK)
Send message on the given socket.
PGenericSocket< _TBackend, _TMockBackend > * getSocket(const _TSocketKey &name)
Get a socket by name (or key)
PSocketMode::PSocketMode p_mode
Mode of the Socket (no mock, mock, mock_record)
bool addServerSocket(const _TSocketKey &name, const std::string &host, size_t port, const typename _TBackend::Param ¶m, const std::string &mockPrefix, const typename _TMockBackend::Param &mockParam)
Create a server socket.
void removeSocket(const _TSocketKey &name)
Remove the given socket.
PGenericSocketManager(PSocketMode::PSocketMode mode=PSocketMode::NO_MOCK)
Default constructor of PGenericSocketManager.
void setMode(PSocketMode::PSocketMode mode)
Set if the current PGenericSocketManager is a mock.
virtual ~PGenericSocketManager()
Destructor of PGenericSocketManager.
PSocketMode::PSocketMode getMode() const
Get if the current PGenericSocketManager is a mock.
bool recvMsg(const _TSocketKey &name, typename _TBackend::Message &msg, PRecvFlag::PRecvFlag flag=PRecvFlag::BLOCK)
Recieve message from the given socket.
void clear()
Clear the map of socket.
void initialisationPGenericSocketManager(PSocketMode::PSocketMode mode)
Initialisation function of the class PGenericSocketManager.
bool addClientSocket(const _TSocketKey &name, const std::string &host, size_t port, const typename _TBackend::Param ¶m, const std::string &mockPrefix, const typename _TMockBackend::Param &mockParam)
Create a client socket.
Abstract socket which has a mock mode to avoid heavy socket backend for unit tests.
bool recvMsg(typename _TBackend::Message &msg, PRecvFlag::PRecvFlag flag)
Recieve message from the given socket.
bool sendMsg(typename _TBackend::Message &msg, PSendFlag::PSendFlag flag)
Send message on the given socket.
bool createClientSocket(const typename _TBackend::Param ¶m, const typename _TMockBackend::Param &mockParam)
Create a client socket.
bool createServerSocket(const typename _TBackend::Param ¶m, const typename _TMockBackend::Param &mockParam)
Create a server socket.
PRecvFlag
describe the recieving flag of the Socket
PSendFlag
describe the sending flag of the Socket
PSocketMode
describe the mode of the Socket