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>
53template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
57 bool b(socket != NULL);
74template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
78 bool b(socket != NULL);
90template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
92 typename std::map<_TSocketKey, PGenericSocket<_TBackend, _TMockBackend>* >::iterator it(
p_mapSocket.find(name));
100template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
115template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
119 return socket->
sendMsg(msg, flag);
131template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
135 return socket->
recvMsg(msg, flag);
145template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
148 typename std::map<_TSocketKey, PGenericSocket<_TBackend, _TMockBackend>* >::iterator it(
p_mapSocket.find(name));
160template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
162 typename std::map<_TSocketKey, PGenericSocket<_TBackend, _TMockBackend>* >::const_iterator it(
p_mapSocket.find(name));
170template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
172 typename std::map<_TSocketKey, PGenericSocket<_TBackend, _TMockBackend>* >::const_iterator it(
p_mapSocket.find(name));
174 return it->second->isConnected();
183template<
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.
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 addClientSocket(const _TSocketKey &name, const PSocketParam &socketParam, const typename _TBackend::Param ¶m, const std::string &mockPrefix, const typename _TMockBackend::Param &mockParam)
Create a client 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.
_TMockBackend p_mockBackend
Instance of the mock backend.
_TBackend p_backend
Instance of the backend.
virtual ~PGenericSocketManager()
Destructor of PGenericSocketManager.
PSendStatus::PSendStatus sendMsg(const _TSocketKey &name, typename _TBackend::Message &msg, PSendFlag::PSendFlag flag=PSendFlag::BLOCK)
Send message on the given socket.
PSocketMode::PSocketMode getMode() const
Get if the current PGenericSocketManager is a mock.
PRecvStatus::PRecvStatus recvMsg(const _TSocketKey &name, typename _TBackend::Message &msg, PRecvFlag::PRecvFlag flag=PRecvFlag::BLOCK)
Receive message from the given socket.
bool addServerSocket(const _TSocketKey &name, const PSocketParam &socketParam, const typename _TBackend::Param ¶m, const std::string &mockPrefix, const typename _TMockBackend::Param &mockParam)
Create a server socket.
void clear()
Clear the map of socket.
void initialisationPGenericSocketManager(PSocketMode::PSocketMode mode)
Initialisation function of the class PGenericSocketManager.
Abstract socket which has a mock mode to avoid heavy socket backend for unit tests.
PSendStatus::PSendStatus sendMsg(typename _TBackend::Message &msg, PSendFlag::PSendFlag flag)
Send message on the given socket.
PRecvStatus::PRecvStatus recvMsg(typename _TBackend::Message &msg, PRecvFlag::PRecvFlag flag)
Receive message from the given socket.
bool createClientSocket(_TBackend &backend, _TMockBackend &mockBackend, const PSocketParam &socketParam, const typename _TBackend::Param ¶m, const std::string &mockPrefix, const typename _TMockBackend::Param &mockParam)
Create a client socket.
bool createServerSocket(_TBackend &backend, _TMockBackend &mockBackend, const PSocketParam &socketParam, const typename _TBackend::Param ¶m, const std::string &mockPrefix, const typename _TMockBackend::Param &mockParam)
Create a server socket.
PRecvFlag
describe the receiving flag of the Socket
PRecvStatus
describe the result of the recv
PSendFlag
describe the sending flag of the Socket
PSendStatus
describe the result of the send
PSocketMode
describe the mode of the Socket
Parameters to create a socket.