GCC Code Coverage Report


Directory: ./
File: src/PSocketFlag.h
Date: 2026-01-20 15:27:04
Exec Total Coverage
Lines: 0 0 -%
Functions: 0 0 -%
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 #ifndef __PSOCKET_FLAG_H__
8 #define __PSOCKET_FLAG_H__
9
10 #include <string>
11
12 namespace PSendFlag{
13 ///@brief describe the sending flag of the Socket
14 enum PSendFlag{
15 BLOCK, //Normal usage of the Socket. Blocking until a message is sent
16 NON_BLOCK //The Socket send does not stop the execution of the program
17 };
18 }
19
20 namespace PSendStatus{
21 ///@brief describe the result of the send
22 enum PSendStatus{
23 OK, //Everything is OK
24 SOCKET_NOT_AVAILABLE, //The socket is not available
25 NO_ROUTE_TO_RECEIVER, //The receiver cannot be reached, maybe caused by network problem
26 SIGNAL_INTERRUPTION, //The socket caught a signal
27 BROKEN_BACKEND, //The backend is broken
28 BROKEN_SOCKET, //The socket is broken and cannot longer be used
29 CANNOT_SERIALIZE_DATA //The data cannot be serialized in the message
30 };
31 }
32
33 namespace PRecvFlag{
34 ///@brief describe the receiving flag of the Socket
35 enum PRecvFlag{
36 BLOCK, //Normal usage of the Socket. Blocking until a message comes
37 NON_BLOCK //The Socket recv does not stop the execution of the program
38 };
39 }
40
41 namespace PRecvStatus{
42 ///@brief describe the result of the recv
43 enum PRecvStatus{
44 OK, //Everything is OK
45 NO_MESSAGE_RECEIVED, //No message was received
46 INVALID_MESSAGE, //The received message is invalid
47 SOCKET_NOT_AVAILABLE, //The socket is not available
48 SIGNAL_INTERRUPTION, //The socket caught a signal
49 BROKEN_BACKEND, //The backend is broken
50 BROKEN_SOCKET, //The socket is broken and cannot longer be used
51 CANNOT_DESERIALIZE_DATA //Cannot deserialize data
52 };
53 }
54
55 ///@brief Parameters to create a socket
56 struct PSocketParam{
57 ///Name of the host to be connected to
58 std::string hostname;
59 ///Port to be connected to
60 size_t port;
61 ///Timeout of the recv method
62 int recvTimeOut{-1};
63 ///Timeout of the send method
64 int sendTimeOut{-1};
65 };
66
67 //toString functions with overloading
68 std::string toString(PSendFlag::PSendFlag flag);
69 std::string toString(PSendStatus::PSendStatus status);
70 std::string toString(PRecvFlag::PRecvFlag flag);
71 std::string toString(PRecvStatus::PRecvStatus status);
72
73 //fromString template function with specializations
74 template<typename T>
75 T fromString(const std::string& str);
76
77 template<>
78 PSendFlag::PSendFlag fromString<PSendFlag::PSendFlag>(const std::string& str);
79
80 template<>
81 PSendStatus::PSendStatus fromString<PSendStatus::PSendStatus>(const std::string& str);
82
83 template<>
84 PRecvFlag::PRecvFlag fromString<PRecvFlag::PRecvFlag>(const std::string& str);
85
86 template<>
87 PRecvStatus::PRecvStatus fromString<PRecvStatus::PRecvStatus>(const std::string& str);
88
89
90 ///Assert especially designed to catch exception and abort if no exception is raised
91 #define PHOENIX_ASSERT_EXCEPTION(X) {\
92 bool isWrongSend = false;\
93 try{\
94 X;\
95 }catch(...){\
96 isWrongSend = true;\
97 }\
98 data_stream_assert(isWrongSend);\
99 }
100
101 #endif
102
103