7#ifndef __PGENERIC_SOCKET_MANAGER_H__
8#define __PGENERIC_SOCKET_MANAGER_H__
16template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
20 typedef _TMockBackend
Mock;
26 bool addClientSocket(
const _TSocketKey & name,
const PSocketParam & socketParam,
const typename _TBackend::Param & param,
const std::string & mockPrefix,
const typename _TMockBackend::Param & mockParam);
27 bool addServerSocket(
const _TSocketKey & name,
const PSocketParam & socketParam,
const typename _TBackend::Param & param,
const std::string & mockPrefix,
const typename _TMockBackend::Param & mockParam);
79 std::map<_TSocketKey, PGenericSocket<_TBackend, _TMockBackend> *>
p_mapSocket;
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)
PSendStatus::PSendStatus sendData(const _TSocketKey &name, const U &data, PSendFlag::PSendFlag flag=PSendFlag::BLOCK)
Send data on the given socket.
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.
PRecvStatus::PRecvStatus recvData(const _TSocketKey &name, U &data, PRecvFlag::PRecvFlag flag=PRecvFlag::BLOCK)
Receive data 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.
PSendStatus::PSendStatus sendData(const U &data, PSendFlag::PSendFlag flag)
Send message on the given socket.
PRecvStatus::PRecvStatus recvData(U &data, PRecvFlag::PRecvFlag flag)
Receive message from the given 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.