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

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

#include <PMockBackendFile.h>

Public Types

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

Public Member Functions

bool createClientSocket (Socket &socket, const PSocketParam &socketParam, const Param &param)
 Create a client socket.
 
bool createServerSocket (Socket &socket, const PSocketParam &socketParam, const Param &param)
 Create a client socket.
 
 PMockBackendFile ()
 Default constructor of PMockBackendFile.
 
virtual ~PMockBackendFile ()
 Destructor of PMockBackendFile.
 

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 PMockBackendFile.h.

Member Typedef Documentation

◆ Message

typedef DataStreamMsg PMockBackendFile::Message

Define the type of message used by the PAbstractSocketManager.

Definition at line 58 of file PMockBackendFile.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 PMockBackendFile.h.

◆ Socket

Define the socket of the backend used by the PAbstractSocketManager.

Definition at line 56 of file PMockBackendFile.h.

Constructor & Destructor Documentation

◆ PMockBackendFile()

PMockBackendFile::PMockBackendFile ( )

Default constructor of PMockBackendFile.

Definition at line 116 of file PMockBackendFile.cpp.

116{}

◆ ~PMockBackendFile()

PMockBackendFile::~PMockBackendFile ( )
virtual

Destructor of PMockBackendFile.

Definition at line 119 of file PMockBackendFile.cpp.

119{}

Member Function Documentation

◆ client()

PMockBackendFile::Param PMockBackendFile::client ( )
static

Create param for a client socket.

Returns
corresponding parameters

Definition at line 124 of file PMockBackendFile.cpp.

124 {
126 return param;
127}
PMockParamFile 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 PMockBackendFile::createClientSocket ( PMockBackendFile::Socket & socket,
const PSocketParam & socketParam,
const Param & 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 142 of file PMockBackendFile.cpp.

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

References PMockSocketFile::createClientSocket().

Referenced by createServerSocket().

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

◆ createServerSocket()

bool PMockBackendFile::createServerSocket ( PMockBackendFile::Socket & socket,
const PSocketParam & socketParam,
const Param & 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 152 of file PMockBackendFile.cpp.

152 {
153 return createClientSocket(socket, socketParam, param);
154}
bool createClientSocket(Socket &socket, const PSocketParam &socketParam, const Param &param)
Create a client socket.

References createClientSocket().

+ Here is the call graph for this function:

◆ mockToMsg()

void PMockBackendFile::mockToMsg ( PMockBackendFile::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 202 of file PMockBackendFile.cpp.

202 {
203 size_t dataSize(mockMsg.size());
204 PMockBackendFile::msgResize(msg, dataSize);
205 memcpy(PMockBackendFile::msgData(msg), mockMsg.data(), dataSize);
206}
static void msgResize(Message &msg, size_t sizeMsg)
Resize a message.
static const DataStreamIter msgData(const Message &msg)
Get the data of a message.

References msgData(), and msgResize().

+ Here is the call graph for this function:

◆ msgData() [1/2]

const DataStreamIter PMockBackendFile::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 176 of file PMockBackendFile.cpp.

176 {
177 return (const DataStreamIter)msg.data();
178}

Referenced by mockToMsg(), and msgToMock().

+ Here is the caller graph for this function:

◆ msgData() [2/2]

DataStreamIter PMockBackendFile::msgData ( PMockBackendFile::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 184 of file PMockBackendFile.cpp.

184 {
185 return msg.data();
186}

◆ msgResize()

void PMockBackendFile::msgResize ( PMockBackendFile::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 160 of file PMockBackendFile.cpp.

160 {
161 msg.resize(sizeMsg);
162}

Referenced by mockToMsg().

+ Here is the caller graph for this function:

◆ msgSize()

size_t PMockBackendFile::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 168 of file PMockBackendFile.cpp.

168 {
169 return msg.size();
170}

Referenced by msgToMock().

+ Here is the caller graph for this function:

◆ msgToMock()

void PMockBackendFile::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 192 of file PMockBackendFile.cpp.

192 {
193 size_t dataSize(PMockBackendFile::msgSize(msg));
194 mockMsg.resize(dataSize);
195 memcpy(mockMsg.data(), PMockBackendFile::msgData(msg), dataSize);
196}
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()

PMockBackendFile::Param PMockBackendFile::server ( )
static

Create param for a server socket.

Returns
corresponding parameters

Definition at line 132 of file PMockBackendFile.cpp.

132 {
134}
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: