Backend to use Mock library with PAbtractSocket.
More...
#include <PEmptyBackend.h>
|
typedef DataStreamMsg | Message |
| Define the type of message used by the PAbstractSocketManager.
|
|
typedef PEmptyParam | Param |
| Define the type of extra parameters which can be used to create a Socket used by the PAbstractSocketManager.
|
|
typedef int | Socket |
| Define the socket of the backend used by the PAbstractSocketManager.
|
|
|
static Param | client () |
| Create param for a client socket.
|
|
static void | close (Socket &socket) |
| Close the given socket.
|
|
static bool | createClientSocket (Socket &socket, const std::string &address, size_t port, const PEmptyParam ¶m) |
| Create a client socket.
|
|
static bool | createServerSocket (Socket &socket, const std::string &address, size_t port, const PEmptyParam ¶m) |
| Create a Server socket.
|
|
static bool | isConnected (const Socket &socket) |
| Close the given socket.
|
|
static void | mockToMsg (Message &msg, DataStreamMsg &mockMsg) |
| Copy mock message data into current backend message.
|
|
static const DataStreamIter | msgData (const Message &msg) |
| Get the data of a message.
|
|
static DataStreamIter | msgData (Message &msg) |
| Get the data of a message.
|
|
static void | msgResize (Message &msg, size_t sizeMsg) |
| Resize a message.
|
|
static size_t | msgSize (const Message &msg) |
| Get the size of a message.
|
|
static void | msgToMock (DataStreamMsg &mockMsg, const Message &msg) |
| Copy current backend message data into mock message.
|
|
static bool | recv (Socket &socket, Message &msg, PRecvFlag::PRecvFlag flag) |
| Recieve message from the given socket.
|
|
static bool | send (Socket &socket, const Message &msg, PSendFlag::PSendFlag flag) |
| Send message on the given socket.
|
|
static Param | server () |
| Create param for a server socket.
|
|
Backend to use Mock library with PAbtractSocket.
Definition at line 17 of file PEmptyBackend.h.
◆ Message
Define the type of message used by the PAbstractSocketManager.
Definition at line 22 of file PEmptyBackend.h.
◆ Param
Define the type of extra parameters which can be used to create a Socket used by the PAbstractSocketManager.
Definition at line 24 of file PEmptyBackend.h.
◆ Socket
Define the socket of the backend used by the PAbstractSocketManager.
Definition at line 20 of file PEmptyBackend.h.
◆ PEmptyBackend()
PEmptyBackend::PEmptyBackend |
( |
| ) |
|
◆ client()
Create param for a client socket.
- Returns
- corresponding PEmptyParam
Definition at line 18 of file PEmptyBackend.cpp.
18 {
20 return param;
21}
PEmptyParam Param
Define the type of extra parameters which can be used to create a Socket used by the PAbstractSocketM...
Referenced by server().
◆ close()
Close the given socket.
- Parameters
-
[out] | socket | : socket to be closed |
Definition at line 108 of file PEmptyBackend.cpp.
◆ createClientSocket()
Create a client socket.
- Parameters
-
[out] | socket | : socket to be created |
| 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) |
- Returns
- true if the socket has been created, false otherwise
Definition at line 37 of file PEmptyBackend.cpp.
◆ createServerSocket()
Create a Server socket.
- Parameters
-
[out] | socket | : socket to be created |
| 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) |
- Returns
- true if the socket has been created, false otherwise
Definition at line 48 of file PEmptyBackend.cpp.
◆ isConnected()
bool PEmptyBackend::isConnected |
( |
const Socket & | socket | ) |
|
|
static |
Close the given socket.
- Parameters
-
socket | : socket to be checked |
- Returns
- true if the socket is connected, false otherwise
Definition at line 116 of file PEmptyBackend.cpp.
116 {
117 return true;
118}
◆ mockToMsg()
Copy mock message data into current backend message.
- Parameters
-
[out] | msg | : message of the current backend to be converted |
| mockMsg | : mock message |
Definition at line 134 of file PEmptyBackend.cpp.
134 {
135 size_t dataSize(mockMsg.size());
138}
static const DataStreamIter msgData(const Message &msg)
Get the data of a message.
static void msgResize(Message &msg, size_t sizeMsg)
Resize a message.
References msgData(), and msgResize().
◆ msgData() [1/2]
const DataStreamIter PEmptyBackend::msgData |
( |
const Message & | msg | ) |
|
|
static |
Get the data of a message.
- Parameters
-
- Returns
- data of the message in bytes
Definition at line 92 of file PEmptyBackend.cpp.
92 {
93 return (const DataStreamIter)msg.data();
94}
Referenced by mockToMsg(), and msgToMock().
◆ msgData() [2/2]
Get the data of a message.
- Parameters
-
- Returns
- data of the message in bytes
Definition at line 100 of file PEmptyBackend.cpp.
100 {
101 return msg.data();
102}
◆ msgResize()
Resize a message.
- Parameters
-
[out] | msg | : message to be resized |
| sizeMsg | : new size of the message |
Definition at line 76 of file PEmptyBackend.cpp.
76 {
77 msg.resize(sizeMsg);
78}
Referenced by mockToMsg().
◆ msgSize()
size_t PEmptyBackend::msgSize |
( |
const Message & | msg | ) |
|
|
static |
Get the size of a message.
- Parameters
-
- Returns
- size of the message in bytes
Definition at line 84 of file PEmptyBackend.cpp.
84 {
85 return msg.size();
86}
Referenced by msgToMock().
◆ msgToMock()
void PEmptyBackend::msgToMock |
( |
DataStreamMsg & | mockMsg, |
|
|
const Message & | msg ) |
|
static |
Copy current backend message data into mock message.
- Parameters
-
[out] | mockMsg | : mock message |
| msg | : message of the current backend to be converted |
Definition at line 124 of file PEmptyBackend.cpp.
124 {
126 mockMsg.resize(dataSize);
128}
static size_t msgSize(const Message &msg)
Get the size of a message.
References msgData(), and msgSize().
◆ recv()
Recieve message from the given socket.
- Parameters
-
socket | : socket to be used |
msg | : message to be recieved |
flag | : flags to be used to send the message (BLOCK, NON_BLOCK, etc) |
- Returns
- true on success, false otherwise
Definition at line 68 of file PEmptyBackend.cpp.
68 {
69 return false;
70}
◆ send()
Send message on the given socket.
- Parameters
-
socket | : socket to be used |
msg | : message to be sent |
flag | : flags to be used to send the message (BLOCK, NON_BLOCK, etc) |
- Returns
- true on success, false otherwise
Definition at line 58 of file PEmptyBackend.cpp.
◆ server()
Create param for a server socket.
- Returns
- corresponding PEmptyParam
Definition at line 26 of file PEmptyBackend.cpp.
26 {
28}
static Param client()
Create param for a client socket.
References client().
The documentation for this class was generated from the following files: