PhoenixSocket  4.0.1
Library which integrates socket unix use in Phoenix
Loading...
Searching...
No Matches
PMockBackendFile_impl.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_IMPL_H__
8#define __PMOCKBACKENDFILE_IMPL_H__
9
10#include "PMockBackendFile.h"
11
13
17template<typename T>
19 if(p_mock.getIsRecord()){
20 size_t dataSize(data_size<T>(data));
23 msg.resize(dataSize);
24 DataStreamIter iter = (DataStreamIter)msg.data();
25 if(data_message_save<T>(iter, data)){ //Save the message
26 sendStatus = sendMsg(msg, flag);
27 }else{
29 }
30 return sendStatus;
31 }else{
32 T referenceData;
33 PMockSocketFile::Message referenceMsg;
34 p_mock.getCurrentValue(referenceMsg); //Let's get the reference message
35 if(referenceMsg.size() != 0lu){
36 DataStreamIter iter = (DataStreamIter)referenceMsg.data();
37 check_stream_assert(data_message_load<T>(iter, referenceData));
38 std::stringstream index;
39 index << p_mock.getCurrentIndex();
40 check_stream_assert(phoenix_check_stream("mock '"+p_mock.getFileName()+"', [mock index = "+index.str()+"]", data, referenceData));
41 }
42 return PSendStatus::OK;
43 }
44}
45
47
51template<typename T>
55 recvStatus = recvMsg(msg, flag);
56 //If the message is empty we cannot initialise the given data, so, this is an error
57 if(msg.size() != 0lu){
58 DataStreamIter iter = (DataStreamIter)msg.data();
59 if(!data_message_load<T>(iter, data)){
61 }
62 }else{
64 }
65 return recvStatus;
66}
67
68#endif
69
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.
PRecvStatus::PRecvStatus recvData(T &data, PRecvFlag::PRecvFlag flag)
Recieved data with the socket.
PSendStatus::PSendStatus sendMsg(const Message &msg, PSendFlag::PSendFlag flag)
Specialisation to send a Message with the socket.
PGenericFileMock< DataStreamMsg > p_mock
Mock handler.
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
@ CANNOT_DESERIALIZE_DATA
Definition PSocketFlag.h:60
@ NO_MESSAGE_RECEIVED
Definition PSocketFlag.h:54
PSendFlag
describe the sending flag of the Socket
Definition PSocketFlag.h:14
PSendStatus
describe the result of the send
Definition PSocketFlag.h:25
@ CANNOT_SERIALIZE_DATA
Definition PSocketFlag.h:32