PhoenixSocket  4.0.1
Library which integrates socket unix use in Phoenix
Loading...
Searching...
No Matches
PEmptyBackend.cpp
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#include "PEmptyBackend.h"
8
13
18
20
23bool PEmptySocket::createClientSocket(const PSocketParam & socketParam, const PEmptyBackend::Param & extraParam){
24 return true;
25}
26
28
31bool PEmptySocket::createServerSocket(const PSocketParam & socketParam, const PEmptyBackend::Param & extraParam){
32 return true;
33}
34
36
38void PEmptySocket::setMockPrefix(const std::string & mockPrefix){}
39
41
43void PEmptySocket::setIsMockRecord(bool isMockRecord){}
44
46
53
55
62
64
67 return true;
68}
69
72
73}
74
75
76
77
78
79
84
86
92
94
99
101
106bool PEmptyBackend::createClientSocket(PEmptyBackend::Socket & socket, const PSocketParam & socketParam, const PEmptyBackend::Param & extraParam){
107 return socket.createClientSocket(socketParam, extraParam);
108}
109
111
116bool PEmptyBackend::createServerSocket(PEmptyBackend::Socket & socket, const PSocketParam & socketParam, const PEmptyBackend::Param & extraParam){
117 return socket.createServerSocket(socketParam, extraParam);
118}
119
121
125 msg.resize(sizeMsg);
126}
127
129
133 return msg.size();
134}
135
137
140const DataStreamIter PEmptyBackend::msgData(const PEmptyBackend::Message& msg){
141 return (const DataStreamIter)msg.data();
142}
143
145
149 return msg.data();
150}
151
153
156void PEmptyBackend::msgToMock(DataStreamMsg & mockMsg, const PEmptyBackend::Message & msg){
157 size_t dataSize(PEmptyBackend::msgSize(msg));
158 mockMsg.resize(dataSize);
159 memcpy(mockMsg.data(), PEmptyBackend::msgData(msg), dataSize);
160}
161
163
166void PEmptyBackend::mockToMsg(PEmptyBackend::Message & msg, DataStreamMsg & mockMsg){
167 size_t dataSize(mockMsg.size());
168 PEmptyBackend::msgResize(msg, dataSize);
169 memcpy(PEmptyBackend::msgData(msg), mockMsg.data(), dataSize);
170}
171
172
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...
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 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
Parameters to create a socket.
Definition PSocketFlag.h:68