PhoenixSocket  4.0.1
Library which integrates socket unix use in Phoenix
Loading...
Searching...
No Matches
PMockBackendFile.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 __PMOCKBACKENDFILE_H__
8#define __PMOCKBACKENDFILE_H__
9
10#include "PSocketFlag.h"
11#include "phoenix_generic_mock.h"
12
15
18 public:
20 typedef DataStreamMsg Message;
23
25 virtual ~PMockSocketFile();
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 private:
45 PGenericFileMock<DataStreamMsg> p_mock;
50};
51
54 public:
58 typedef DataStreamMsg Message;
61
63 virtual ~PMockBackendFile();
64
65 static Param client();
66 static Param server();
67
68 bool createClientSocket(Socket & socket, const PSocketParam & socketParam, const Param & param);
69 bool createServerSocket(Socket & socket, const PSocketParam & socketParam, const Param & param);
70
71 static void msgResize(Message& msg, size_t sizeMsg);
72 static size_t msgSize(const Message& msg);
73 static const DataStreamIter msgData(const Message& msg);
74 static DataStreamIter msgData(Message& msg);
75
76 static void msgToMock(DataStreamMsg & mockMsg, const Message & msg);
77 static void mockToMsg(Message & msg, DataStreamMsg & mockMsg);
78};
79
80bool phoenix_createMockBackend(PMockSocketFile & mock, const PSocketParam & socketParam, const std::string & prefix = "", const PMockParamFile & extraParam = PMockParamFile());
81
83
84#endif
85
bool phoenix_createMockBackend(PMockSocketFile &mock, const PSocketParam &socketParam, const std::string &prefix="", const PMockParamFile &extraParam=PMockParamFile())
Create a mock backend file.
PMockParamFile Param
Define the type of extra parameters which can be used to create a Socket used by the PAbstractSocketM...
static void msgToMock(DataStreamMsg &mockMsg, const Message &msg)
Copy current backend message data into mock message.
static void msgResize(Message &msg, size_t sizeMsg)
Resize a message.
DataStreamMsg Message
Define the type of message used by the PAbstractSocketManager.
bool createServerSocket(Socket &socket, const PSocketParam &socketParam, const Param &param)
Create a client socket.
static const DataStreamIter msgData(const Message &msg)
Get the data of a message.
virtual ~PMockBackendFile()
Destructor of PMockBackendFile.
static Param client()
Create param for a client socket.
PMockSocketFile Socket
Define the socket of the backend used by the PAbstractSocketManager.
bool createClientSocket(Socket &socket, const PSocketParam &socketParam, const Param &param)
Create a client socket.
static size_t msgSize(const Message &msg)
Get the size of a message.
static void mockToMsg(Message &msg, DataStreamMsg &mockMsg)
Copy mock message data into current backend message.
PMockBackendFile()
Default constructor of PMockBackendFile.
static Param server()
Create param for a server socket.
Example of a mock socket with vector of messages.
PSendStatus::PSendStatus sendData(const T &data, PSendFlag::PSendFlag flag)
Send data with the socket.
PRecvStatus::PRecvStatus recvMsg(Message &msg, PRecvFlag::PRecvFlag flag)
Recieved data with the socket.
void setMockPrefix(const std::string &mockPrefix)
Set the mock prefix (where to find/save it)
PRecvStatus::PRecvStatus recvData(T &data, PRecvFlag::PRecvFlag flag)
Recieved data with the socket.
Param p_extraParam
Extra parameters of the socket.
bool createClientSocket(const PSocketParam &socketParam, const Param &extraParam)
Initialise a client socket.
PMockParamFile Param
Define the type of extra parameters which can be used to create a Socket used by the PAbstractSocketM...
void setIsMockRecord(bool isMockRecord)
Set the mock prefix (where to find/save it)
PSocketParam p_socketParam
Parameters of the socket.
bool isConnected() const
Say if the PMockSocketFile is connected.
PMockSocketFile()
Default constructor of hte PMockSocketFile.
bool createServerSocket(const PSocketParam &socketParam, const Param &extraParam)
Initialise a server socket.
void close()
Close the PMockSocketFile.
PSendStatus::PSendStatus sendMsg(const Message &msg, PSendFlag::PSendFlag flag)
Specialisation to send a Message with the socket.
PGenericFileMock< DataStreamMsg > p_mock
Mock handler.
virtual ~PMockSocketFile()
Default destructor of hte PMockSocketFile.
DataStreamMsg Message
Define the type of message used by the PAbstractSocketManager.
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