GCC Code Coverage Report


Directory: ./
File: src/PZmqBackend.h
Date: 2026-01-23 17:10:06
Exec Total Coverage
Lines: 0 0 -%
Functions: 0 0 -%
Branches: 0 0 -%

Line Branch Exec Source
1 /***************************************
2 Auteur : Thibaut Oprinsen
3 Mail : thibaut.oprinsen@lapp.in2p3.fr
4 Licence : CeCILL-C
5 ****************************************/
6
7 #ifndef __PZMQBACKEND_H__
8 #define __PZMQBACKEND_H__
9
10 #include <string>
11 #include "PSocketFlag.h"
12 #include "phoenix_generic_mock.h"
13 #include "phoenix_data_stream.h"
14 #include "phoenix_zmq.h"
15
16 ///@brief Set of parameters to be passed to create a socket with zmq backend
17 struct PZmqParam{
18 ///Socket type
19 int type;
20 ///Number of messages in the buffer
21 int nbBufferMessage;
22 ///Size of the message buffer in bytes
23 int bufferSizeByte;
24 ///Mask of threads which deal with reconnection
25 size_t threadAffinity;
26 ///Data rate
27 ssize_t dataRate;
28 };
29
30 PZmqParam pzmq_createParamClient(int type, int nbBufferMessage = 10000, int bufferSizeByte = 1000000, size_t threadAffinity = 0lu, ssize_t dataRate = 200000l);
31 PZmqParam pzmq_createParamServer(int type, int nbBufferMessage = 10000, int bufferSizeByte = 1000000, size_t threadAffinity = 0lu, ssize_t dataRate = 200000l);
32 template <typename T>
33 std::string statusToStr(T status);
34 PSendStatus::PSendStatus checkSendStatus(zmq::send_result_t res);
35 PRecvStatus::PRecvStatus checkRecvStatus(zmq::recv_result_t res);
36
37 ///@brief PhoenixSocket API bridge to ZMQ socket
38 class PZmqSocket{
39 public:
40 ///Define the type of message used by the PAbstractSocketManager
41 typedef zmq::message_t Message;
42 ///Define the type of extra parameters which can be used to create a Socket used by the PAbstractSocketManager
43 typedef PZmqParam Param;
44
45 PZmqSocket();
46 virtual ~PZmqSocket();
47
48 bool createClientSocket(zmq::context_t & context, const PSocketParam & socketParam, const Param & extraParam);
49 bool createServerSocket(zmq::context_t & context, const PSocketParam & socketParam, const Param & extraParam);
50
51 template<typename T>
52 PSendStatus::PSendStatus sendData(const T & data, PSendFlag::PSendFlag flag = PSendFlag::BLOCK);
53 PSendStatus::PSendStatus sendMsg(Message & msg, PSendFlag::PSendFlag flag = PSendFlag::BLOCK);
54
55 template<typename T>
56 PRecvStatus::PRecvStatus recvData(T & data, PRecvFlag::PRecvFlag flag = PRecvFlag::BLOCK);
57 PRecvStatus::PRecvStatus recvMsg(Message & msg, PRecvFlag::PRecvFlag flag = PRecvFlag::BLOCK);
58
59 bool isConnected() const;
60 void close();
61 private:
62 ///ZMQ Socket
63 zmq::socket_t* p_socket;
64 };
65
66 ///@brief Backend to use Mock library with PAbtractSocket
67 class PZmqBackend{
68 public:
69 ///Define the socket of the backend used by the PAbstractSocketManager
70 typedef PZmqSocket Socket;
71 ///Define the type of message used by the PAbstractSocketManager
72 typedef zmq::message_t Message;
73 ///Define the type of extra parameters which can be used to create a Socket used by the PAbstractSocketManager
74 typedef PZmqParam Param;
75
76 PZmqBackend();
77
78 static Param client();
79 static Param server();
80
81 bool createClientSocket(Socket & socket, const PSocketParam & socketParam, const PZmqParam & param);
82 bool createServerSocket(Socket & socket, const PSocketParam & socketParam, const PZmqParam & param);
83
84 void msgToMock(DataStreamMsg & mockMsg, const Message & msg);
85 void mockToMsg(Message & msg, DataStreamMsg & mockMsg);
86
87 private:
88 ///Context ZMQ
89 zmq::context_t p_context;
90 };
91
92 #include "PZmqBackend_impl.h"
93
94 #endif
95
96