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

Public Member Functions

 PEmptyBackend ()
 Default constructor of PEmptyBackend.
 

Static Public Member Functions

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 &param)
 Create a client socket.
 
static bool createServerSocket (Socket &socket, const std::string &address, size_t port, const PEmptyParam &param)
 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.
 

Detailed Description

Backend to use Mock library with PAbtractSocket.

Definition at line 17 of file PEmptyBackend.h.

Member Typedef Documentation

◆ Message

typedef DataStreamMsg PEmptyBackend::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

typedef int PEmptyBackend::Socket

Define the socket of the backend used by the PAbstractSocketManager.

Definition at line 20 of file PEmptyBackend.h.

Constructor & Destructor Documentation

◆ PEmptyBackend()

PEmptyBackend::PEmptyBackend ( )

Default constructor of PEmptyBackend.

Definition at line 11 of file PEmptyBackend.cpp.

11 {
12
13}

Member Function Documentation

◆ client()

PEmptyBackend::Param PEmptyBackend::client ( )
static

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().

+ Here is the caller graph for this function:

◆ close()

void PEmptyBackend::close ( PEmptyBackend::Socket & socket)
static

Close the given socket.

Parameters
[out]socket: socket to be closed

Definition at line 108 of file PEmptyBackend.cpp.

108 {
109
110}

◆ createClientSocket()

bool PEmptyBackend::createClientSocket ( PEmptyBackend::Socket & socket,
const std::string & address,
size_t port,
const PEmptyParam & param )
static

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.

37 {
38 return true;
39}

◆ createServerSocket()

bool PEmptyBackend::createServerSocket ( PEmptyBackend::Socket & socket,
const std::string & address,
size_t port,
const PEmptyParam & param )
static

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.

48 {
49 return true;
50}

◆ 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()

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

134 {
135 size_t dataSize(mockMsg.size());
136 PEmptyBackend::msgResize(msg, dataSize);
137 memcpy(PEmptyBackend::msgData(msg), mockMsg.data(), dataSize);
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().

+ 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 92 of file PEmptyBackend.cpp.

92 {
93 return (const DataStreamIter)msg.data();
94}

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

100 {
101 return msg.data();
102}

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

76 {
77 msg.resize(sizeMsg);
78}

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

84 {
85 return msg.size();
86}

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

124 {
125 size_t dataSize(PEmptyBackend::msgSize(msg));
126 mockMsg.resize(dataSize);
127 memcpy(mockMsg.data(), PEmptyBackend::msgData(msg), dataSize);
128}
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:

◆ recv()

bool PEmptyBackend::recv ( PEmptyBackend::Socket & socket,
PEmptyBackend::Message & msg,
PRecvFlag::PRecvFlag flag )
static

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()

bool PEmptyBackend::send ( PEmptyBackend::Socket & socket,
const Message & msg,
PSendFlag::PSendFlag flag )
static

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.

58 {
59 return true;
60}

◆ server()

PEmptyBackend::Param PEmptyBackend::server ( )
static

Create param for a server socket.

Returns
corresponding PEmptyParam

Definition at line 26 of file PEmptyBackend.cpp.

26 {
27 return PEmptyBackend::client();
28}
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: