PhoenixSocket
6.4.0
Library which integrates socket use in Phoenix
Toggle main menu visibility
Loading...
Searching...
No Matches
PEmptyBackend_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 __PEMPTY_BACKEND_IMPL_H__
8
#define __PEMPTY_BACKEND_IMPL_H__
9
10
#include "phoenix_data_stream.h"
11
#include "
PEmptyBackend.h
"
12
14
18
template
<
typename
T>
19
PSendStatus::PSendStatus
PEmptySocket::sendData
(
const
T & data,
PSendFlag::PSendFlag
flag){
20
size_t
dataSize(data_size<T>(data));
21
PSendStatus::PSendStatus
sendStatus =
PSendStatus::OK
;
22
Message
msg;
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
{
28
sendStatus =
PSendStatus::CANNOT_SERIALIZE_DATA
;
29
}
30
return
sendStatus;
31
}
32
34
38
template
<
typename
T>
39
PRecvStatus::PRecvStatus
PEmptySocket::recvData
(T & data,
PRecvFlag::PRecvFlag
flag){
40
PRecvStatus::PRecvStatus
recvStatus =
PRecvStatus::OK
;
41
Message
msg;
42
recvStatus =
recvMsg
(msg, flag);
43
//If the message is empty we cannot initialise the given data, so, this is an error
44
if
(msg.size() != 0lu){
45
DataStreamIter iter = (DataStreamIter)msg.data();
46
if
(!data_message_load<T>(iter, data)){
47
recvStatus =
PRecvStatus::CANNOT_DESERIALIZE_DATA
;
48
}
49
}
else
{
50
recvStatus =
PRecvStatus::NO_MESSAGE_RECEIVED
;
51
}
52
return
recvStatus;
53
}
54
55
56
#endif
57
PEmptyBackend.h
PEmptySocket::recvData
PRecvStatus::PRecvStatus recvData(T &data, PRecvFlag::PRecvFlag flag)
Recieved data with the socket.
Definition
PEmptyBackend_impl.h:39
PEmptySocket::recvMsg
PRecvStatus::PRecvStatus recvMsg(Message &msg, PRecvFlag::PRecvFlag flag)
Recieved data with the socket.
Definition
PEmptyBackend.cpp:59
PEmptySocket::Message
DataStreamMsg Message
Define the type of message used by the PAbstractSocketManager.
Definition
PEmptyBackend.h:20
PEmptySocket::sendData
PSendStatus::PSendStatus sendData(const T &data, PSendFlag::PSendFlag flag)
Send data with the socket.
Definition
PEmptyBackend_impl.h:19
PEmptySocket::sendMsg
PSendStatus::PSendStatus sendMsg(const Message &msg, PSendFlag::PSendFlag flag)
Specialisation to send a Message with the PEmptySocket.
Definition
PEmptyBackend.cpp:50
PRecvFlag::PRecvFlag
PRecvFlag
describe the receiving flag of the Socket
Definition
PSocketFlag.h:35
PRecvStatus::PRecvStatus
PRecvStatus
describe the result of the recv
Definition
PSocketFlag.h:43
PRecvStatus::CANNOT_DESERIALIZE_DATA
@ CANNOT_DESERIALIZE_DATA
Definition
PSocketFlag.h:51
PRecvStatus::NO_MESSAGE_RECEIVED
@ NO_MESSAGE_RECEIVED
Definition
PSocketFlag.h:45
PRecvStatus::OK
@ OK
Definition
PSocketFlag.h:44
PSendFlag::PSendFlag
PSendFlag
describe the sending flag of the Socket
Definition
PSocketFlag.h:14
PSendStatus::PSendStatus
PSendStatus
describe the result of the send
Definition
PSocketFlag.h:22
PSendStatus::CANNOT_SERIALIZE_DATA
@ CANNOT_SERIALIZE_DATA
Definition
PSocketFlag.h:29
PSendStatus::OK
@ OK
Definition
PSocketFlag.h:23
src
PEmptyBackend_impl.h
Generated by
1.17.0