![]() |
PhoenixSocket
1.0.0
Library which integrates socket unix use in Phoenix
|
Socket manager for PGenericSocket. More...
#include <PGenericSocketManager.h>
Public Types | |
typedef _TBackend | Backend |
typedef _TMockBackend | Mock |
Public Member Functions | |
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. | |
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 | clear () |
Clear the map of socket. | |
PSocketMode::PSocketMode | getMode () const |
Get if the current PGenericSocketManager is a mock. | |
PGenericSocket< _TBackend, _TMockBackend > * | getSocket (const _TSocketKey &name) |
Get a socket by name (or key) | |
bool | isConnected (const _TSocketKey &name) const |
Say if the given socket is connected. | |
bool | isSocketExist (const _TSocketKey &name) const |
Say if the socket exist with the given name. | |
PGenericSocketManager (PSocketMode::PSocketMode mode=PSocketMode::NO_MOCK) | |
Default constructor of PGenericSocketManager. | |
template<typename U> | |
bool | recvData (const _TSocketKey &name, U &data, PRecvFlag::PRecvFlag flag=PRecvFlag::BLOCK) |
Recieve data from the given socket. | |
bool | recvMsg (const _TSocketKey &name, typename _TBackend::Message &msg, PRecvFlag::PRecvFlag flag=PRecvFlag::BLOCK) |
Recieve message from the given socket. | |
void | removeSocket (const _TSocketKey &name) |
Remove the given socket. | |
template<typename U> | |
bool | sendData (const _TSocketKey &name, const U &data, PSendFlag::PSendFlag flag=PSendFlag::BLOCK) |
Send data on the given socket. | |
bool | sendMsg (const _TSocketKey &name, typename _TBackend::Message &msg, PSendFlag::PSendFlag flag=PSendFlag::BLOCK) |
Send message on the given socket. | |
void | setMode (PSocketMode::PSocketMode mode) |
Set if the current PGenericSocketManager is a mock. | |
virtual | ~PGenericSocketManager () |
Destructor of PGenericSocketManager. | |
Private Member Functions | |
void | initialisationPGenericSocketManager (PSocketMode::PSocketMode mode) |
Initialisation function of the class PGenericSocketManager. | |
Private Attributes | |
std::map< _TSocketKey, PGenericSocket< _TBackend, _TMockBackend > * > | p_mapSocket |
Map of the zmq sockets to be used by the manager. | |
PSocketMode::PSocketMode | p_mode |
Mode of the Socket (no mock, mock, mock_record) | |
Socket manager for PGenericSocket.
Definition at line 17 of file PGenericSocketManager.h.
typedef _TBackend PGenericSocketManager< _TSocketKey, _TBackend, _TMockBackend >::Backend |
Definition at line 19 of file PGenericSocketManager.h.
typedef _TMockBackend PGenericSocketManager< _TSocketKey, _TBackend, _TMockBackend >::Mock |
Definition at line 20 of file PGenericSocketManager.h.
PGenericSocketManager< _TSocketKey, _TBackend, _TMockBackend >::PGenericSocketManager | ( | PSocketMode::PSocketMode | mode = PSocketMode::NO_MOCK | ) |
Default constructor of PGenericSocketManager.
mode | : Mode of the Socket (no mock, mock, mock_record) |
Definition at line 16 of file PGenericSocketManager_impl.h.
References initialisationPGenericSocketManager().
|
virtual |
Destructor of PGenericSocketManager.
Definition at line 22 of file PGenericSocketManager_impl.h.
References clear().
bool PGenericSocketManager< _TSocketKey, _TBackend, _TMockBackend >::addClientSocket | ( | const _TSocketKey & | name, |
const std::string & | host, | ||
size_t | port, | ||
const typename _TBackend::Param & | param, | ||
const std::string & | mockPrefix, | ||
const typename _TMockBackend::Param & | mockParam ) |
Create a client socket.
name | : name (key) to get the socket |
address | : address of the server, the client has to connect to |
port | : port to be used for the connection |
param | : extra customisable parameters for the creation of the socket (depends on the backend) |
mockPrefix | : prefix to find and szve the mock |
mockParam | : parameters to initialise the mock |
Definition at line 55 of file PGenericSocketManager_impl.h.
References PGenericSocket< _TBackend, _TMockBackend >::createClientSocket(), p_mapSocket, and p_mode.
bool PGenericSocketManager< _TSocketKey, _TBackend, _TMockBackend >::addServerSocket | ( | const _TSocketKey & | name, |
const std::string & | host, | ||
size_t | port, | ||
const typename _TBackend::Param & | param, | ||
const std::string & | mockPrefix, | ||
const typename _TMockBackend::Param & | mockParam ) |
Create a server socket.
name | : name (key) to get the socket |
address | : address of the server, the client has to connect to |
port | : port to be used for the connection |
param | : extra customisable parameters for the creation of the socket (depends on the backend) |
mockPrefix | : prefix to find and szve the mock |
mockParam | : parameters to initialise the mock |
Definition at line 78 of file PGenericSocketManager_impl.h.
References PGenericSocket< _TBackend, _TMockBackend >::createServerSocket(), p_mapSocket, and p_mode.
void PGenericSocketManager< _TSocketKey, _TBackend, _TMockBackend >::clear | ( | ) |
Clear the map of socket.
Definition at line 105 of file PGenericSocketManager_impl.h.
References p_mapSocket.
Referenced by ~PGenericSocketManager().
PSocketMode::PSocketMode PGenericSocketManager< _TSocketKey, _TBackend, _TMockBackend >::getMode | ( | ) | const |
Get if the current PGenericSocketManager is a mock.
Definition at line 41 of file PGenericSocketManager_impl.h.
References p_mode.
PGenericSocket< _TBackend, _TMockBackend > * PGenericSocketManager< _TSocketKey, _TBackend, _TMockBackend >::getSocket | ( | const _TSocketKey & | name | ) |
Get a socket by name (or key)
name | : of the socket to be used |
Definition at line 150 of file PGenericSocketManager_impl.h.
References p_mapSocket.
Referenced by recvData(), recvMsg(), sendData(), and sendMsg().
|
private |
Initialisation function of the class PGenericSocketManager.
mode | : Mode of the Socket (no mock, mock, mock_record) |
Definition at line 188 of file PGenericSocketManager_impl.h.
References p_mode.
Referenced by PGenericSocketManager().
bool PGenericSocketManager< _TSocketKey, _TBackend, _TMockBackend >::isConnected | ( | const _TSocketKey & | name | ) | const |
Say if the given socket is connected.
name | : name of the socket to be checked |
Definition at line 175 of file PGenericSocketManager_impl.h.
References p_mapSocket.
bool PGenericSocketManager< _TSocketKey, _TBackend, _TMockBackend >::isSocketExist | ( | const _TSocketKey & | name | ) | const |
Say if the socket exist with the given name.
name | : of the socket to be used |
Definition at line 165 of file PGenericSocketManager_impl.h.
References p_mapSocket.
|
inline |
Recieve data from the given socket.
name | : name of the socket to be used |
data | : data to be recieved |
flag | : flags to be used to send the message (BLOCK, NON_BLOCK, etc) |
Definition at line 57 of file PGenericSocketManager.h.
References PRecvFlag::BLOCK, getSocket(), and PGenericSocket< _TBackend, _TMockBackend >::recvData().
bool PGenericSocketManager< _TSocketKey, _TBackend, _TMockBackend >::recvMsg | ( | const _TSocketKey & | name, |
typename _TBackend::Message & | msg, | ||
PRecvFlag::PRecvFlag | flag = PRecvFlag::BLOCK ) |
Recieve message from the given socket.
name | : name of the socket to be used |
msg | : message to be recieved |
flag | : flags to be used to send the message (BLOCK, NON_BLOCK, etc) |
Definition at line 136 of file PGenericSocketManager_impl.h.
References getSocket(), and PGenericSocket< _TBackend, _TMockBackend >::recvMsg().
void PGenericSocketManager< _TSocketKey, _TBackend, _TMockBackend >::removeSocket | ( | const _TSocketKey & | name | ) |
Remove the given socket.
name | : name (key) of the socket to be removed |
Definition at line 95 of file PGenericSocketManager_impl.h.
References p_mapSocket.
|
inline |
Send data on the given socket.
name | : name of the socket to be used |
data | : data to be sent |
flag | : flag to be used to send the message (BLOCK, NON_BLOCK, etc) |
Definition at line 39 of file PGenericSocketManager.h.
References PSendFlag::BLOCK, getSocket(), and PGenericSocket< _TBackend, _TMockBackend >::sendData().
bool PGenericSocketManager< _TSocketKey, _TBackend, _TMockBackend >::sendMsg | ( | const _TSocketKey & | name, |
typename _TBackend::Message & | msg, | ||
PSendFlag::PSendFlag | flag = PSendFlag::BLOCK ) |
Send message on the given socket.
name | : name of the socket to be used |
msg | : message to be sent |
flag | : flags to be used to send the message (BLOCK, NON_BLOCK, etc) |
Definition at line 120 of file PGenericSocketManager_impl.h.
References getSocket(), and PGenericSocket< _TBackend, _TMockBackend >::sendMsg().
void PGenericSocketManager< _TSocketKey, _TBackend, _TMockBackend >::setMode | ( | PSocketMode::PSocketMode | mode | ) |
Set if the current PGenericSocketManager is a mock.
mode | : Mode of the Socket (no mock, mock, mock_record) |
Definition at line 30 of file PGenericSocketManager_impl.h.
References p_mapSocket, and p_mode.
|
private |
Map of the zmq sockets to be used by the manager.
Definition at line 79 of file PGenericSocketManager.h.
Referenced by addClientSocket(), addServerSocket(), clear(), getSocket(), isConnected(), isSocketExist(), removeSocket(), and setMode().
|
private |
Mode of the Socket (no mock, mock, mock_record)
Definition at line 76 of file PGenericSocketManager.h.
Referenced by addClientSocket(), addServerSocket(), getMode(), initialisationPGenericSocketManager(), and setMode().