GCC Code Coverage Report


Directory: ./
File: src/PEmptyBackend.cpp
Date: 2025-12-02 14:33:23
Exec Total Coverage
Lines: 45 47 95.7%
Functions: 20 22 90.9%
Branches: 0 0 -%

Line Branch Exec Source
1 /***************************************
2 Auteur : Pierre Aubert
3 Mail : pierre.aubert@lapp.in2p3.fr
4 Licence : CeCILL-C
5 ****************************************/
6
7 #include "PEmptyBackend.h"
8
9 ///Default constructor of hte PEmptySocket
10 5 PEmptySocket::PEmptySocket(){
11
12 5 }
13
14 ///Default destructor of hte PEmptySocket
15 5 PEmptySocket::~PEmptySocket(){
16
17 5 }
18
19 ///Initialise a client socket
20 /** @param socketParam : parameters to be use to initialise the socket (hostname, port, etc)
21 * @param extraParam : extra customisable parameters for the creation of the socket (depends on the backend)
22 */
23 2 bool PEmptySocket::createClientSocket(const PSocketParam & socketParam, const PEmptyBackend::Param & extraParam){
24 2 return true;
25 }
26
27 ///Initialise a server socket
28 /** @param socketParam : parameters to be use to initialise the socket (hostname, port, etc)
29 * @param extraParam : extra customisable parameters for the creation of the socket (depends on the backend)
30 */
31 2 bool PEmptySocket::createServerSocket(const PSocketParam & socketParam, const PEmptyBackend::Param & extraParam){
32 2 return true;
33 }
34
35 ///Set the mock prefix (where to find/save it)
36 /** @param mockPrefix : prefix of the mock to find or write it
37 */
38 1 void PEmptySocket::setMockPrefix(const std::string & mockPrefix){}
39
40 ///Set the mock prefix (where to find/save it)
41 /** @param isMockRecord : true if the mock has to be recorded
42 */
43 1 void PEmptySocket::setIsMockRecord(bool isMockRecord){}
44
45 ///Specialisation to send a Message with the PEmptySocket
46 /** @param msg : Message to be sent
47 * @param flag : sending flag (BLOCK, NON_BLOCK)
48 * @return status of the send
49 */
50 20 PSendStatus::PSendStatus PEmptySocket::sendMsg(const PEmptySocket::Message & msg, PSendFlag::PSendFlag flag){
51 20 return PSendStatus::OK;
52 }
53
54 ///Recieved data with the socket
55 /** @param[out] msg : Message to be recieved with the socket
56 * @param flag : recieving flag (BLOCK, NON_BLOCK)
57 * @return status of the recv
58 */
59 PRecvStatus::PRecvStatus PEmptySocket::recvMsg(PEmptySocket::Message & msg, PRecvFlag::PRecvFlag flag){
60 return PRecvStatus::OK;
61 }
62
63 ///Say if the PEmptySocket is connected
64 /** @return true if the PEmptySocket is connected, false otherwise
65 */
66 3 bool PEmptySocket::isConnected() const{
67 3 return true;
68 }
69
70 ///Close the PEmptySocket
71 8 void PEmptySocket::close(){
72
73 8 }
74
75
76
77
78
79
80 ///Default constructor of PEmptyBackend
81 4 PEmptyBackend::PEmptyBackend(){
82
83 4 }
84
85 ///Create param for a client socket
86 /** @return corresponding PEmptyParam
87 */
88 4 PEmptyBackend::Param PEmptyBackend::client(){
89 PEmptyBackend::Param param;
90 4 return param;
91 }
92
93 ///Create param for a server socket
94 /** @return corresponding PEmptyParam
95 */
96 2 PEmptyBackend::Param PEmptyBackend::server(){
97 2 return PEmptyBackend::client();
98 }
99
100 ///Create a client socket
101 /** @param[out] socket : socket to be created
102 * @param socketParam : parameters of the socket (host, port, send/recv timeout)
103 * @param extraParam : extra customisable parameters for the creation of the socket (depends on the backend)
104 * @return true if the socket has been created, false otherwise
105 */
106 2 bool PEmptyBackend::createClientSocket(PEmptyBackend::Socket & socket, const PSocketParam & socketParam, const PEmptyBackend::Param & extraParam){
107 2 return socket.createClientSocket(socketParam, extraParam);
108 }
109
110 ///Create a Server socket
111 /** @param[out] socket : socket to be created
112 * @param socketParam : parameters of the socket (host, port, send/recv timeout)
113 * @param extraParam : extra customisable parameters for the creation of the socket (depends on the backend)
114 * @return true if the socket has been created, false otherwise
115 */
116 2 bool PEmptyBackend::createServerSocket(PEmptyBackend::Socket & socket, const PSocketParam & socketParam, const PEmptyBackend::Param & extraParam){
117 2 return socket.createServerSocket(socketParam, extraParam);
118 }
119
120 ///Resize a message
121 /** @param[out] msg : message to be resized
122 * @param sizeMsg : new size of the message
123 */
124 10 void PEmptyBackend::msgResize(PEmptyBackend::Message& msg, size_t sizeMsg){
125 10 msg.resize(sizeMsg);
126 10 }
127
128 ///Get the size of a message
129 /** @param msg : message to be used
130 * @return size of the message in bytes
131 */
132 20 size_t PEmptyBackend::msgSize(const PEmptyBackend::Message& msg){
133 20 return msg.size();
134 }
135
136 ///Get the data of a message
137 /** @param msg : message to be used
138 * @return data of the message in bytes
139 */
140 10 const DataStreamIter PEmptyBackend::msgData(const PEmptyBackend::Message& msg){
141 10 return (const DataStreamIter)msg.data();
142 }
143
144 ///Get the data of a message
145 /** @param msg : message to be used
146 * @return data of the message in bytes
147 */
148 20 DataStreamIter PEmptyBackend::msgData(PEmptyBackend::Message& msg){
149 20 return msg.data();
150 }
151
152 ///Copy current backend message data into mock message
153 /** @param[out] mockMsg : mock message
154 * @param msg : message of the current backend to be converted
155 */
156 10 void PEmptyBackend::msgToMock(DataStreamMsg & mockMsg, const PEmptyBackend::Message & msg){
157 10 size_t dataSize(PEmptyBackend::msgSize(msg));
158 10 mockMsg.resize(dataSize);
159 10 memcpy(mockMsg.data(), PEmptyBackend::msgData(msg), dataSize);
160 10 }
161
162 ///Copy mock message data into current backend message
163 /** @param[out] msg : message of the current backend to be converted
164 * @param mockMsg : mock message
165 */
166 10 void PEmptyBackend::mockToMsg(PEmptyBackend::Message & msg, DataStreamMsg & mockMsg){
167 10 size_t dataSize(mockMsg.size());
168 10 PEmptyBackend::msgResize(msg, dataSize);
169 10 memcpy(PEmptyBackend::msgData(msg), mockMsg.data(), dataSize);
170 10 }
171
172
173