7 #ifndef __PGENERIC_SOCKET_MANAGER_H_IMPL__
8 #define __PGENERIC_SOCKET_MANAGER_H_IMPL__
15 template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
17 initialisationPGenericSocketManager(mode);
21 template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
29 template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
37 template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
48 template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
52 bool b(socket != NULL);
56 p_mapSocket[name] = socket;
68 template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
72 bool b(socket != NULL);
76 p_mapSocket[name] = socket;
85 template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
87 typename std::map<_TSocketKey, PGenericSocket<_TBackend, _TMockBackend>* >::iterator it(p_mapSocket.find(name));
88 if(it != p_mapSocket.end()){
90 p_mapSocket.erase(it);
95 template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
109 template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
113 return socket->
sendMsg(msg, flag);
125 template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
129 return socket->
recvMsg(msg, flag);
139 template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
142 typename std::map<_TSocketKey, PGenericSocket<_TBackend, _TMockBackend>* >::iterator it(p_mapSocket.find(name));
143 if(it != p_mapSocket.end()){
154 template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
156 typename std::map<_TSocketKey, PGenericSocket<_TBackend, _TMockBackend>* >::const_iterator it(p_mapSocket.find(name));
157 return it != p_mapSocket.end();
164 template<
typename _TSocketKey,
typename _TBackend,
typename _TMockBackend>
166 typename std::map<_TSocketKey, PGenericSocket<_TBackend, _TMockBackend>* >::const_iterator it(p_mapSocket.find(name));
167 if(it != p_mapSocket.end()){
168 return it->second->isConnected();
177 template<
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.
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)
bool addClientSocket(const _TSocketKey &name, const typename _TBackend::Param ¶m, 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.
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 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