PhoenixZMQ  2.0.0
Library which integrates zeromq use in Phoenix
PEmptyBackend.h
Go to the documentation of this file.
1 /***************************************
2  Auteur : Pierre Aubert
3  Mail : pierre.aubert@lapp.in2p3.fr
4  Licence : CeCILL-C
5 ****************************************/
6 
7 #ifndef __PEMPTY_BACKEND_H__
8 #define __PEMPTY_BACKEND_H__
9 
10 #include "PSocketFlag.h"
11 #include "phoenix_mock_socket.h"
12 
14 struct PEmptyParam{
16  std::string address;
18  size_t port;
19 };
20 
23  public:
25  typedef int Socket;
29  typedef PEmptyParam Param;
30 
31  PEmptyBackend();
32 
33  static Param client(const std::string & address, size_t port);
34  static Param server(const std::string & address, size_t port);
35 
36  static bool createClientSocket(Socket & socket, const std::string & address, size_t port, const PEmptyParam & param);
37  static bool createServerSocket(Socket & socket, const std::string & address, size_t port, const PEmptyParam & param);
38 
39  static bool createClientSocket(Socket & socket, const PEmptyParam & param);
40  static bool createServerSocket(Socket & socket, const PEmptyParam & param);
41 
42  static bool send(Socket & socket, const Message& msg, PSendFlag::PSendFlag flag);
43 
44  static bool recv(Socket & socket, Message& msg, PRecvFlag::PRecvFlag flag);
45 
46  static void msgResize(Message& msg, size_t sizeMsg);
47  static size_t msgSize(const Message& msg);
48  static const DataStreamIter msgData(const Message& msg);
49  static DataStreamIter msgData(Message& msg);
50 
51  static void close(Socket & socket);
52  static bool isConnected(const Socket & socket);
53 
54  static void msgToMock(DataStreamMsg & mockMsg, const Message & msg);
55  static void mockToMsg(Message & msg, DataStreamMsg & mockMsg);
56 };
57 
58 
59 
60 #endif
61 
Backend to use Mock library with PAbtractSocket.
Definition: PEmptyBackend.h:22
static bool createServerSocket(Socket &socket, const std::string &address, size_t port, const PEmptyParam &param)
Create a client socket.
static bool isConnected(const 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 const DataStreamIter msgData(const Message &msg)
Get the data of 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.
int Socket
Define the socket of the backend used by the PAbstractSocketManager.
Definition: PEmptyBackend.h:25
static Param server(const std::string &address, size_t port)
Create param for a server socket.
static bool recv(Socket &socket, Message &msg, PRecvFlag::PRecvFlag flag)
Recieve message from the given socket.
static void mockToMsg(Message &msg, DataStreamMsg &mockMsg)
Copy mock message data into current backend message.
static void msgResize(Message &msg, size_t sizeMsg)
Resize a message.
static Param client(const std::string &address, size_t port)
Create param for a client socket.
static bool send(Socket &socket, const Message &msg, PSendFlag::PSendFlag flag)
Send message on the given socket.
DataStreamMsg Message
Define the type of message used by the PAbstractSocketManager.
Definition: PEmptyBackend.h:27
PEmptyBackend()
Default constructor of PEmptyBackend.
PEmptyParam Param
Define the type of extra parameters which can be used to create a Socket used by the PAbstractSocketM...
Definition: PEmptyBackend.h:29
static void close(Socket &socket)
Close the given socket.
std::vector< DataStreamType > DataStreamMsg
DataStreamType * DataStreamIter
PRecvFlag
describe the recieving flag of the Socket
Definition: PSocketFlag.h:20
PSendFlag
describe the sending flag of the Socket
Definition: PSocketFlag.h:12
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