7 #ifndef __PGENERIC_SOCKET_MANAGER_H__
8 #define __PGENERIC_SOCKET_MANAGER_H__
16 template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
20 typedef _TMockBackend
Mock;
26 bool addClientSocket(
const _TSocketKey & name,
const typename _TBackend::Param & param,
const typename _TMockBackend::Param & mockParam);
27 bool addServerSocket(
const _TSocketKey & name,
const typename _TBackend::Param & param,
const typename _TMockBackend::Param & mockParam);
79 std::map<_TSocketKey, PGenericSocket<_TBackend, _TMockBackend> *>
p_mapSocket;
Socket manager for PGenericSocket.
bool recvData(const _TSocketKey &name, U &data, PRecvFlag::PRecvFlag flag=PRecvFlag::BLOCK)
Recieve data from the given socket.
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 addServerSocket(const _TSocketKey &name, const typename _TBackend::Param ¶m, const typename _TMockBackend::Param &mockParam)
Create a server socket.
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 addClientSocket(const _TSocketKey &name, const typename _TBackend::Param ¶m, const typename _TMockBackend::Param &mockParam)
Create a client socket.
bool sendData(const _TSocketKey &name, const U &data, PSendFlag::PSendFlag flag=PSendFlag::BLOCK)
Send data on the given 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.
Abstract socket which has a mock mode to avoid heavy socket backend for unit tests.
bool recvData(U &data, PRecvFlag::PRecvFlag flag)
Recieve message from the given socket.
bool sendData(const U &data, PSendFlag::PSendFlag flag)
Send message on the given socket.
PRecvFlag
describe the recieving flag of the Socket
PSendFlag
describe the sending flag of the Socket
PSocketMode
describe the mode of the Socket