![]() |
PhoenixSocket
1.0.0
Library which integrates socket unix use in Phoenix
|
Abstract socket which has a mock mode to avoid heavy socket backend for unit tests. More...
#include <PGenericSocket.h>
Public Member Functions | |
void | close () |
Close the socket. | |
bool | createClientSocket (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 | createClientSocket (const typename _TBackend::Param ¶m, const typename _TMockBackend::Param &mockParam) |
Create a client socket. | |
bool | createServerSocket (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. | |
bool | createServerSocket (const typename _TBackend::Param ¶m, const typename _TMockBackend::Param &mockParam) |
Create a server socket. | |
bool | isConnected () const |
Say if the Socket is connected. | |
PGenericSocket (PSocketMode::PSocketMode mode) | |
Default constructor of PGenericSocket. | |
template<typename U> | |
bool | recvData (U &data, PRecvFlag::PRecvFlag flag) |
Recieve message from the given socket. | |
bool | recvMsg (typename _TBackend::Message &msg, PRecvFlag::PRecvFlag flag) |
Recieve message from the given socket. | |
template<typename U> | |
bool | sendData (const U &data, PSendFlag::PSendFlag flag) |
Send message on the given socket. | |
bool | sendMsg (typename _TBackend::Message &msg, PSendFlag::PSendFlag flag) |
Send message on the given socket. | |
void | setMode (PSocketMode::PSocketMode mode) |
Set the mode of the generic socket. | |
virtual | ~PGenericSocket () |
Destructor of PGenericSocket. | |
Private Member Functions | |
void | initialisationPGenericSocket (PSocketMode::PSocketMode mode) |
Initialisation function of the class PGenericSocket. | |
Private Attributes | |
_TMockBackend::Socket | p_mockSocket |
Socket to be used with the mock backend. | |
PSocketMode::PSocketMode | p_mode |
Mode of the Socket (no mock, mock, mock_record) | |
_TBackend::Socket | p_socket |
Socket to be used with the classical backend. | |
Abstract socket which has a mock mode to avoid heavy socket backend for unit tests.
Definition at line 16 of file PGenericSocket.h.
PGenericSocket< _TBackend, _TMockBackend >::PGenericSocket | ( | PSocketMode::PSocketMode | mode | ) |
Default constructor of PGenericSocket.
mode | : Mode of the Socket (no mock, mock, mock_record) |
Definition at line 16 of file PGenericSocket_impl.h.
References initialisationPGenericSocket().
|
virtual |
Destructor of PGenericSocket.
Definition at line 22 of file PGenericSocket_impl.h.
References close().
void PGenericSocket< _TBackend, _TMockBackend >::close | ( | ) |
Close the socket.
Definition at line 165 of file PGenericSocket_impl.h.
References p_mockSocket, and p_socket.
Referenced by ~PGenericSocket().
bool PGenericSocket< _TBackend, _TMockBackend >::createClientSocket | ( | 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.
host | : connection host |
port | : connection port |
param | : extra parameters of the backend |
mockPrefix | : prefix where to find/save the mock |
mockParam | : extra parameters of the mock |
Definition at line 68 of file PGenericSocket_impl.h.
References PSocketMode::MOCK_RECORD, p_mockSocket, p_mode, and p_socket.
bool PGenericSocket< _TBackend, _TMockBackend >::createClientSocket | ( | const typename _TBackend::Param & | param, |
const typename _TMockBackend::Param & | mockParam ) |
Create a client socket.
param | : extra customisable parameters for the creation of the socket (depends on the backend) |
mockParam | : parameters of mock backend |
Definition at line 32 of file PGenericSocket_impl.h.
References PSocketMode::MOCK, PSocketMode::NO_MOCK, p_mockSocket, p_mode, and p_socket.
Referenced by PGenericSocketManager< _TSocketKey, _TBackend, _TMockBackend >::addClientSocket().
bool PGenericSocket< _TBackend, _TMockBackend >::createServerSocket | ( | 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.
host | : connection host |
port | : connection port |
param | : extra parameters of the backend |
mockPrefix | : prefix where to find/save the mock |
mockParam | : extra parameters of the mock |
Definition at line 86 of file PGenericSocket_impl.h.
References PSocketMode::MOCK_RECORD, p_mockSocket, p_mode, and p_socket.
bool PGenericSocket< _TBackend, _TMockBackend >::createServerSocket | ( | const typename _TBackend::Param & | param, |
const typename _TMockBackend::Param & | mockParam ) |
Create a server socket.
param | : extra customisable parameters for the creation of the socket (depends on the backend) |
mockParam | : parameters of mock backend |
Definition at line 49 of file PGenericSocket_impl.h.
References PSocketMode::MOCK, PSocketMode::NO_MOCK, p_mockSocket, p_mode, and p_socket.
Referenced by PGenericSocketManager< _TSocketKey, _TBackend, _TMockBackend >::addServerSocket().
|
private |
Initialisation function of the class PGenericSocket.
mode | : Mode of the Socket (no mock, mock, mock_record) |
Definition at line 189 of file PGenericSocket_impl.h.
References p_mode.
Referenced by PGenericSocket().
bool PGenericSocket< _TBackend, _TMockBackend >::isConnected | ( | ) | const |
Say if the Socket is connected.
Definition at line 174 of file PGenericSocket_impl.h.
References PSocketMode::MOCK, PSocketMode::NO_MOCK, p_mockSocket, p_mode, and p_socket.
|
inline |
Recieve message from the given socket.
data | : data to be recieved |
flag | : flag to be used to send the message (BLOCK, NON_BLOCK, etc) |
Definition at line 77 of file PGenericSocket.h.
References PSocketMode::MOCK, PSocketMode::NO_MOCK, p_mockSocket, p_mode, and p_socket.
Referenced by PGenericSocketManager< _TSocketKey, _TBackend, _TMockBackend >::recvData().
bool PGenericSocket< _TBackend, _TMockBackend >::recvMsg | ( | typename _TBackend::Message & | msg, |
PRecvFlag::PRecvFlag | flag ) |
Recieve message from the given socket.
msg | : message to be recieved |
flag | : flags to be used to send the message (BLOCK, NON_BLOCK, etc) |
Definition at line 138 of file PGenericSocket_impl.h.
References PSocketMode::MOCK, PSocketMode::NO_MOCK, p_mockSocket, p_mode, and p_socket.
Referenced by PGenericSocketManager< _TSocketKey, _TBackend, _TMockBackend >::recvMsg().
|
inline |
Send message on the given socket.
data | : data to be sent |
flag | : flag to be used to send the message (BLOCK, NON_BLOCK, etc) |
Definition at line 36 of file PGenericSocket.h.
References PSocketMode::MOCK, PSocketMode::NO_MOCK, p_mockSocket, p_mode, and p_socket.
Referenced by PGenericSocketManager< _TSocketKey, _TBackend, _TMockBackend >::sendData().
bool PGenericSocket< _TBackend, _TMockBackend >::sendMsg | ( | typename _TBackend::Message & | msg, |
PSendFlag::PSendFlag | flag ) |
Send message on the given socket.
msg | : message to be sent |
flag | : flags to be used to send the message (BLOCK, NON_BLOCK, etc) |
Definition at line 111 of file PGenericSocket_impl.h.
References PSocketMode::MOCK, PSocketMode::NO_MOCK, p_mockSocket, p_mode, and p_socket.
Referenced by PGenericSocketManager< _TSocketKey, _TBackend, _TMockBackend >::sendMsg().
void PGenericSocket< _TBackend, _TMockBackend >::setMode | ( | PSocketMode::PSocketMode | mode | ) |
Set the mode of the generic socket.
mode | : mode of the PGenericSocket (NO_MOCK, MOCK, MOCK_RECORD) |
Definition at line 100 of file PGenericSocket_impl.h.
References PSocketMode::MOCK_RECORD, p_mockSocket, and p_mode.
|
private |
Socket to be used with the mock backend.
Definition at line 132 of file PGenericSocket.h.
Referenced by close(), createClientSocket(), createClientSocket(), createServerSocket(), createServerSocket(), isConnected(), recvData(), recvMsg(), sendData(), sendMsg(), and setMode().
|
private |
Mode of the Socket (no mock, mock, mock_record)
Definition at line 127 of file PGenericSocket.h.
Referenced by createClientSocket(), createClientSocket(), createServerSocket(), createServerSocket(), initialisationPGenericSocket(), isConnected(), recvData(), recvMsg(), sendData(), sendMsg(), and setMode().
|
private |
Socket to be used with the classical backend.
Definition at line 130 of file PGenericSocket.h.
Referenced by close(), createClientSocket(), createClientSocket(), createServerSocket(), createServerSocket(), isConnected(), recvData(), recvMsg(), sendData(), and sendMsg().