PhoenixSocket  1.0.0
Library which integrates socket unix use in Phoenix
Loading...
Searching...
No Matches
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
14struct PEmptyParam{};
15
18 public:
20 typedef int Socket;
22 typedef DataStreamMsg Message;
25
27
28 static Param client();
29 static Param server();
30
31 static bool createClientSocket(Socket & socket, const std::string & address, size_t port, const PEmptyParam & param);
32 static bool createServerSocket(Socket & socket, const std::string & address, size_t port, const PEmptyParam & param);
33
34 static bool send(Socket & socket, const Message& msg, PSendFlag::PSendFlag flag);
35
36 static bool recv(Socket & socket, Message& msg, PRecvFlag::PRecvFlag flag);
37
38 static void msgResize(Message& msg, size_t sizeMsg);
39 static size_t msgSize(const Message& msg);
40 static const DataStreamIter msgData(const Message& msg);
41 static DataStreamIter msgData(Message& msg);
42
43 static void close(Socket & socket);
44 static bool isConnected(const Socket & socket);
45
46 static void msgToMock(DataStreamMsg & mockMsg, const Message & msg);
47 static void mockToMsg(Message & msg, DataStreamMsg & mockMsg);
48};
49
50
51
52#endif
53
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 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.
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 server()
Create param for a server socket.
static bool send(Socket &socket, const Message &msg, PSendFlag::PSendFlag flag)
Send message on the given socket.
static Param client()
Create param for a client socket.
DataStreamMsg Message
Define the type of message used by the PAbstractSocketManager.
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...
static void close(Socket &socket)
Close the given socket.
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.