PhoenixZMQ  2.0.0
Library which integrates zeromq use in Phoenix
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. More...
 
typedef PEmptyParam Param
 Define the type of extra parameters which can be used to create a Socket used by the PAbstractSocketManager. More...
 
typedef int Socket
 Define the socket of the backend used by the PAbstractSocketManager. More...
 

Public Member Functions

 PEmptyBackend ()
 Default constructor of PEmptyBackend. More...
 

Static Public Member Functions

static Param client (const std::string &address, size_t port)
 Create param for a client socket. More...
 
static void close (Socket &socket)
 Close the given socket. More...
 
static bool createClientSocket (Socket &socket, const PEmptyParam &param)
 Create a client socket. More...
 
static bool createClientSocket (Socket &socket, const std::string &address, size_t port, const PEmptyParam &param)
 Create a client socket. More...
 
static bool createServerSocket (Socket &socket, const PEmptyParam &param)
 Create a client socket. More...
 
static bool createServerSocket (Socket &socket, const std::string &address, size_t port, const PEmptyParam &param)
 Create a client socket. More...
 
static bool isConnected (const Socket &socket)
 Close the given socket. More...
 
static void mockToMsg (Message &msg, DataStreamMsg &mockMsg)
 Copy mock message data into current backend message. More...
 
static const DataStreamIter msgData (const Message &msg)
 Get the data of a message. More...
 
static DataStreamIter msgData (Message &msg)
 Get the data of a message. More...
 
static void msgResize (Message &msg, size_t sizeMsg)
 Resize a message. More...
 
static size_t msgSize (const Message &msg)
 Get the size of a message. More...
 
static void msgToMock (DataStreamMsg &mockMsg, const Message &msg)
 Copy current backend message data into mock message. More...
 
static bool recv (Socket &socket, Message &msg, PRecvFlag::PRecvFlag flag)
 Recieve message from the given socket. More...
 
static bool send (Socket &socket, const Message &msg, PSendFlag::PSendFlag flag)
 Send message on the given socket. More...
 
static Param server (const std::string &address, size_t port)
 Create param for a server socket. More...
 

Detailed Description

Backend to use Mock library with PAbtractSocket.

Definition at line 22 of file PEmptyBackend.h.

Member Typedef Documentation

◆ Message

Define the type of message used by the PAbstractSocketManager.

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

◆ Socket

typedef int PEmptyBackend::Socket

Define the socket of the backend used by the PAbstractSocketManager.

Definition at line 25 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 ( const std::string &  address,
size_t  port 
)
static

Create param for a client socket.

Parameters
address: address of the server to be connected to
port: port to be used
Returns
corresponding PZmqParam

Definition at line 20 of file PEmptyBackend.cpp.

20  {
22  param.address = address;
23  param.port = port;
24  return param;
25 }
Set of parameters to be passed to create a socket with mock backend.
Definition: PEmptyBackend.h:14
size_t port
Connection port.
Definition: PEmptyBackend.h:18
std::string address
Host address.
Definition: PEmptyBackend.h:16

References PEmptyParam::address, and PEmptyParam::port.

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

132  {
133 
134 }

◆ createClientSocket() [1/2]

bool PEmptyBackend::createClientSocket ( PEmptyBackend::Socket socket,
const PEmptyParam param 
)
static

Create a client socket.

Parameters
[out]socket: socket to be created
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 63 of file PEmptyBackend.cpp.

63  {
64  return true;
65 }

◆ createClientSocket() [2/2]

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

43  {
44  return true;
45 }

◆ createServerSocket() [1/2]

bool PEmptyBackend::createServerSocket ( PEmptyBackend::Socket socket,
const PEmptyParam param 
)
static

Create a client socket.

Parameters
[out]socket: socket to be created
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 72 of file PEmptyBackend.cpp.

72  {
73  return true;
74 }

◆ createServerSocket() [2/2]

bool PEmptyBackend::createServerSocket ( 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 54 of file PEmptyBackend.cpp.

54  {
55  return true;
56 }

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

140  {
141  return true;
142 }

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

158  {
159  size_t dataSize(mockMsg.size());
160  PEmptyBackend::msgResize(msg, dataSize);
161  memcpy(PEmptyBackend::msgData(msg), mockMsg.data(), dataSize);
162 }
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 116 of file PEmptyBackend.cpp.

116  {
117  return (const DataStreamIter)msg.data();
118 }
DataStreamType * DataStreamIter

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

124  {
125  return msg.data();
126 }

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

100  {
101  msg.resize(sizeMsg);
102 }

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

108  {
109  return msg.size();
110 }

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

148  {
149  size_t dataSize(PEmptyBackend::msgSize(msg));
150  mockMsg.resize(dataSize);
151  memcpy(mockMsg.data(), PEmptyBackend::msgData(msg), dataSize);
152 }
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 92 of file PEmptyBackend.cpp.

92  {
93  return false;
94 }

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

82  {
83  return true;
84 }

◆ server()

PEmptyBackend::Param PEmptyBackend::server ( const std::string &  address,
size_t  port 
)
static

Create param for a server socket.

Parameters
address: address of the server to be connected to
port: port to be used
Returns
corresponding PZmqParam

Definition at line 32 of file PEmptyBackend.cpp.

32  {
33  return PEmptyBackend::client(address, port);
34 }
static Param client(const std::string &address, size_t port)
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: