PhoenixSocket  4.0.1
Library which integrates socket unix use in Phoenix
Loading...
Searching...
No Matches
PMockBackend Class Reference

Backend to use Mock library with PAbtractSocket. More...

#include <PMockBackend.h>

Public Types

typedef DataStreamMsg Message
 Define the type of message used by the PAbstractSocketManager.
 
typedef PMockParam Param
 Define the type of extra parameters which can be used to create a Socket used by the PAbstractSocketManager.
 
typedef PMockSocket Socket
 Define the socket of the backend used by the PAbstractSocketManager.
 

Public Member Functions

bool createClientSocket (Socket &socket, const PSocketParam &socketParam, const PMockParam &param)
 Create a client socket.
 
bool createServerSocket (Socket &socket, const PSocketParam &socketParam, const PMockParam &param)
 Create a client socket.
 
 PMockBackend ()
 Default constructor of PMockBackend.
 

Static Public Member Functions

static Param client ()
 Create param for a client 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 Param server ()
 Create param for a server socket.
 

Detailed Description

Backend to use Mock library with PAbtractSocket.

Definition at line 53 of file PMockBackend.h.

Member Typedef Documentation

◆ Message

typedef DataStreamMsg PMockBackend::Message

Define the type of message used by the PAbstractSocketManager.

Definition at line 58 of file PMockBackend.h.

◆ Param

Define the type of extra parameters which can be used to create a Socket used by the PAbstractSocketManager.

Definition at line 60 of file PMockBackend.h.

◆ Socket

Define the socket of the backend used by the PAbstractSocketManager.

Definition at line 56 of file PMockBackend.h.

Constructor & Destructor Documentation

◆ PMockBackend()

PMockBackend::PMockBackend ( )

Default constructor of PMockBackend.

Definition at line 119 of file PMockBackend.cpp.

119 {
120
121}

Member Function Documentation

◆ client()

PMockBackend::Param PMockBackend::client ( )
static

Create param for a client socket.

Returns
corresponding parameters

Definition at line 126 of file PMockBackend.cpp.

126 {
128 return param;
129}
PMockParam Param
Define the type of extra parameters which can be used to create a Socket used by the PAbstractSocketM...

Referenced by server().

+ Here is the caller graph for this function:

◆ createClientSocket()

bool PMockBackend::createClientSocket ( PMockBackend::Socket & socket,
const PSocketParam & socketParam,
const PMockParam & param )

Create a client socket.

Parameters
[out]socket: socket to be created
socketParam: parameters of the socket (host, port, send/recv timeout)
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 144 of file PMockBackend.cpp.

144 {
145 return socket.createClientSocket(socketParam, param);
146}
bool createClientSocket(const PSocketParam &socketParam, const Param &extraParam)
Initialise a client socket.

References PMockSocket::createClientSocket().

Referenced by createServerSocket().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createServerSocket()

bool PMockBackend::createServerSocket ( PMockBackend::Socket & socket,
const PSocketParam & socketParam,
const PMockParam & param )

Create a client socket.

Parameters
[out]socket: socket to be created
socketParam: parameters of the socket (host, port, send/recv timeout)
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 154 of file PMockBackend.cpp.

154 {
155 return createClientSocket(socket, socketParam, param);
156}
bool createClientSocket(Socket &socket, const PSocketParam &socketParam, const PMockParam &param)
Create a client socket.

References createClientSocket().

+ Here is the call graph for this function:

◆ mockToMsg()

void PMockBackend::mockToMsg ( PMockBackend::Message & msg,
DataStreamMsg & mockMsg )
static

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 204 of file PMockBackend.cpp.

204 {
205 size_t dataSize(mockMsg.size());
206 PMockBackend::msgResize(msg, dataSize);
207 memcpy(PMockBackend::msgData(msg), mockMsg.data(), dataSize);
208}
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().

+ Here is the call graph for this function:

◆ msgData() [1/2]

const DataStreamIter PMockBackend::msgData ( const Message & msg)
static

Get the data of a message.

Parameters
msg: message to be used
Returns
data of the message in bytes

Definition at line 178 of file PMockBackend.cpp.

178 {
179 return (const DataStreamIter)msg.data();
180}

Referenced by mockToMsg(), and msgToMock().

+ Here is the caller graph for this function:

◆ msgData() [2/2]

DataStreamIter PMockBackend::msgData ( PMockBackend::Message & msg)
static

Get the data of a message.

Parameters
msg: message to be used
Returns
data of the message in bytes

Definition at line 186 of file PMockBackend.cpp.

186 {
187 return msg.data();
188}

◆ msgResize()

void PMockBackend::msgResize ( PMockBackend::Message & msg,
size_t sizeMsg )
static

Resize a message.

Parameters
[out]msg: message to be resized
sizeMsg: new size of the message

Definition at line 162 of file PMockBackend.cpp.

162 {
163 msg.resize(sizeMsg);
164}

Referenced by mockToMsg().

+ Here is the caller graph for this function:

◆ msgSize()

size_t PMockBackend::msgSize ( const Message & msg)
static

Get the size of a message.

Parameters
msg: message to be used
Returns
size of the message in bytes

Definition at line 170 of file PMockBackend.cpp.

170 {
171 return msg.size();
172}

Referenced by msgToMock().

+ Here is the caller graph for this function:

◆ msgToMock()

void PMockBackend::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 194 of file PMockBackend.cpp.

194 {
195 size_t dataSize(PMockBackend::msgSize(msg));
196 mockMsg.resize(dataSize);
197 memcpy(mockMsg.data(), PMockBackend::msgData(msg), dataSize);
198}
static size_t msgSize(const Message &msg)
Get the size of a message.

References msgData(), and msgSize().

+ Here is the call graph for this function:

◆ server()

PMockBackend::Param PMockBackend::server ( )
static

Create param for a server socket.

Returns
corresponding parameters

Definition at line 134 of file PMockBackend.cpp.

134 {
135 return PMockBackend::client();
136}
static Param client()
Create param for a client socket.

References client().

+ Here is the call graph for this function:

The documentation for this class was generated from the following files: