PhoenixSocket  4.0.1
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 DataStreamMsg Message;
23
25 virtual ~PEmptySocket();
26
27 bool createClientSocket(const PSocketParam & socketParam, const Param & extraParam);
28 bool createServerSocket(const PSocketParam & socketParam, const Param & extraParam);
29
30 void setMockPrefix(const std::string & mockPrefix);
31 void setIsMockRecord(bool isMockRecord);
32
33 template<typename T>
36
37 template<typename T>
40
41 bool isConnected() const;
42 void close();
43};
44
47 public:
51 typedef DataStreamMsg Message;
54
56
57 static Param client();
58 static Param server();
59
60 bool createClientSocket(Socket & socket, const PSocketParam & socketParam, const Param & extraParam);
61 bool createServerSocket(Socket & socket, const PSocketParam & socketParam, const Param & extraParam);
62
63 static void msgResize(Message& msg, size_t sizeMsg);
64 static size_t msgSize(const Message& msg);
65 static const DataStreamIter msgData(const Message& msg);
66 static DataStreamIter msgData(Message& msg);
67
68 static void msgToMock(DataStreamMsg & mockMsg, const Message & msg);
69 static void mockToMsg(Message & msg, DataStreamMsg & mockMsg);
70};
71
72#include "PEmptyBackend_impl.h"
73
74
75#endif
76
PEmptySocket Socket
Define the socket of the backend used by the PAbstractSocketManager.
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.
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 Param client()
Create param for a client socket.
DataStreamMsg Message
Define the type of message used by the PAbstractSocketManager.
bool createServerSocket(Socket &socket, const PSocketParam &socketParam, const Param &extraParam)
Create a Server socket.
bool createClientSocket(Socket &socket, const PSocketParam &socketParam, const Param &extraParam)
Create a client socket.
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...
Example of an empty socket.
PRecvStatus::PRecvStatus recvData(T &data, PRecvFlag::PRecvFlag flag)
Recieved data with the socket.
PEmptyParam Param
Define the type of extra parameters which can be used to create a Socket used by the PAbstractSocketM...
void close()
Close the PEmptySocket.
PRecvStatus::PRecvStatus recvMsg(Message &msg, PRecvFlag::PRecvFlag flag)
Recieved data with the socket.
bool createClientSocket(const PSocketParam &socketParam, const Param &extraParam)
Initialise a client socket.
bool createServerSocket(const PSocketParam &socketParam, const Param &extraParam)
Initialise a server socket.
virtual ~PEmptySocket()
Default destructor of hte PEmptySocket.
bool isConnected() const
Say if the PEmptySocket is connected.
void setIsMockRecord(bool isMockRecord)
Set the mock prefix (where to find/save it)
DataStreamMsg Message
Define the type of message used by the PAbstractSocketManager.
PEmptySocket()
Default constructor of hte PEmptySocket.
void setMockPrefix(const std::string &mockPrefix)
Set the mock prefix (where to find/save it)
PSendStatus::PSendStatus sendData(const T &data, PSendFlag::PSendFlag flag)
Send data with the socket.
PSendStatus::PSendStatus sendMsg(const Message &msg, PSendFlag::PSendFlag flag)
Specialisation to send a Message with the PEmptySocket.
PRecvFlag
describe the receiving flag of the Socket
Definition PSocketFlag.h:41
PRecvStatus
describe the result of the recv
Definition PSocketFlag.h:52
PSendFlag
describe the sending flag of the Socket
Definition PSocketFlag.h:14
PSendStatus
describe the result of the send
Definition PSocketFlag.h:25
Set of parameters to be passed to create a socket with mock backend.
Parameters to create a socket.
Definition PSocketFlag.h:68