| Line | Branch | Exec | Source |
|---|---|---|---|
| 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 | |||
| 13 | ///Send data with the socket | ||
| 14 | /** @param data : data to be sent with the socket | ||
| 15 | * @param flag : sending flag (BLOCK, NON_BLOCK) | ||
| 16 | * @return status of the send | ||
| 17 | */ | ||
| 18 | template<typename T> | ||
| 19 | 10 | PSendStatus::PSendStatus PEmptySocket::sendData(const T & data, PSendFlag::PSendFlag flag){ | |
| 20 |
1/1✓ Branch 0 (2→3) taken 10 times.
|
10 | size_t dataSize(data_size<T>(data)); |
| 21 | 10 | PSendStatus::PSendStatus sendStatus = PSendStatus::OK; | |
| 22 | 10 | Message msg; | |
| 23 |
1/1✓ Branch 0 (4→5) taken 10 times.
|
10 | msg.resize(dataSize); |
| 24 | 10 | DataStreamIter iter = (DataStreamIter)msg.data(); | |
| 25 |
2/3✓ Branch 0 (6→7) taken 10 times.
✓ Branch 2 (7→8) taken 10 times.
✗ Branch 3 (7→10) not taken.
|
10 | if(data_message_save<T>(iter, data)){ //Save the message |
| 26 |
1/1✓ Branch 0 (8→9) taken 10 times.
|
10 | sendStatus = sendMsg(msg, flag); |
| 27 | }else{ | ||
| 28 | ✗ | sendStatus = PSendStatus::CANNOT_SERIALIZE_DATA; | |
| 29 | } | ||
| 30 | 10 | return sendStatus; | |
| 31 | 10 | } | |
| 32 | |||
| 33 | ///Recieved data with the socket | ||
| 34 | /** @param[out] data : data to be recieved with the socket | ||
| 35 | * @param flag : recieving flag (BLOCK, NON_BLOCK) | ||
| 36 | * @return status of the recv | ||
| 37 | */ | ||
| 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 | |||
| 58 |