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

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

#include <PEmptyBackend.h>

Public Types

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 PEmptySocket Socket
 Define the socket of the backend used by the PAbstractSocketManager.
 

Public Member Functions

bool createClientSocket (Socket &socket, const PSocketParam &socketParam, const Param &extraParam)
 Create a client socket.
 
bool createServerSocket (Socket &socket, const PSocketParam &socketParam, const Param &extraParam)
 Create a Server socket.
 
 PEmptyBackend ()
 Default constructor of PEmptyBackend.
 

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 46 of file PEmptyBackend.h.

Member Typedef Documentation

◆ Message

typedef DataStreamMsg PEmptyBackend::Message

Define the type of message used by the PAbstractSocketManager.

Definition at line 51 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 53 of file PEmptyBackend.h.

◆ Socket

Define the socket of the backend used by the PAbstractSocketManager.

Definition at line 49 of file PEmptyBackend.h.

Constructor & Destructor Documentation

◆ PEmptyBackend()

PEmptyBackend::PEmptyBackend ( )

Default constructor of PEmptyBackend.

Definition at line 81 of file PEmptyBackend.cpp.

81 {
82
83}

Member Function Documentation

◆ client()

PEmptyBackend::Param PEmptyBackend::client ( )
static

Create param for a client socket.

Returns
corresponding PEmptyParam

Definition at line 88 of file PEmptyBackend.cpp.

88 {
90 return param;
91}
PEmptyParam 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 PEmptyBackend::createClientSocket ( PEmptyBackend::Socket & socket,
const PSocketParam & socketParam,
const Param & extraParam )

Create a client socket.

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

106 {
107 return socket.createClientSocket(socketParam, extraParam);
108}
bool createClientSocket(const PSocketParam &socketParam, const Param &extraParam)
Initialise a client socket.

References PEmptySocket::createClientSocket().

+ Here is the call graph for this function:

◆ createServerSocket()

bool PEmptyBackend::createServerSocket ( PEmptyBackend::Socket & socket,
const PSocketParam & socketParam,
const Param & extraParam )

Create a Server socket.

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

116 {
117 return socket.createServerSocket(socketParam, extraParam);
118}
bool createServerSocket(const PSocketParam &socketParam, const Param &extraParam)
Initialise a server socket.

References PEmptySocket::createServerSocket().

+ Here is the call graph for this function:

◆ mockToMsg()

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

166 {
167 size_t dataSize(mockMsg.size());
168 PEmptyBackend::msgResize(msg, dataSize);
169 memcpy(PEmptyBackend::msgData(msg), mockMsg.data(), dataSize);
170}
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 PEmptyBackend::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 140 of file PEmptyBackend.cpp.

140 {
141 return (const DataStreamIter)msg.data();
142}

Referenced by mockToMsg(), and msgToMock().

+ Here is the caller graph for this function:

◆ msgData() [2/2]

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

148 {
149 return msg.data();
150}

◆ msgResize()

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

124 {
125 msg.resize(sizeMsg);
126}

Referenced by mockToMsg().

+ Here is the caller graph for this function:

◆ msgSize()

size_t PEmptyBackend::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 132 of file PEmptyBackend.cpp.

132 {
133 return msg.size();
134}

Referenced by msgToMock().

+ Here is the caller graph for this function:

◆ 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 156 of file PEmptyBackend.cpp.

156 {
157 size_t dataSize(PEmptyBackend::msgSize(msg));
158 mockMsg.resize(dataSize);
159 memcpy(mockMsg.data(), PEmptyBackend::msgData(msg), dataSize);
160}
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()

PEmptyBackend::Param PEmptyBackend::server ( )
static

Create param for a server socket.

Returns
corresponding PEmptyParam

Definition at line 96 of file PEmptyBackend.cpp.

96 {
97 return PEmptyBackend::client();
98}
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: