7#ifndef __PZMQBACKEND_H__
8#define __PZMQBACKEND_H__
11#include "PSocketFlag.h"
12#include "phoenix_generic_mock.h"
13#include "phoenix_data_stream.h"
30PZmqParam pzmq_createParamClient(
int type,
int nbBufferMessage = 10000,
int bufferSizeByte = 1000000,
size_t threadAffinity = 0lu, ssize_t dataRate = 200000l);
31PZmqParam pzmq_createParamServer(
int type,
int nbBufferMessage = 10000,
int bufferSizeByte = 1000000,
size_t threadAffinity = 0lu, ssize_t dataRate = 200000l);
52 PSendStatus::PSendStatus
sendData(
const T & data, PSendFlag::PSendFlag flag = PSendFlag::BLOCK);
53 PSendStatus::PSendStatus
sendMsg(
Message & msg, PSendFlag::PSendFlag flag = PSendFlag::BLOCK);
56 PRecvStatus::PRecvStatus
recvData(T & data, PRecvFlag::PRecvFlag flag = PRecvFlag::BLOCK);
57 PRecvStatus::PRecvStatus
recvMsg(
Message & msg, PRecvFlag::PRecvFlag flag = PRecvFlag::BLOCK);
std::string statusToStr(T status)
Convert PSendStatus into string.
PRecvStatus::PRecvStatus checkRecvStatus(zmq::recv_result_t res)
Check the recv result and convert it into PRecvStatus.
PZmqParam pzmq_createParamServer(int type, int nbBufferMessage=10000, int bufferSizeByte=1000000, size_t threadAffinity=0lu, ssize_t dataRate=200000l)
Create param for a client socket.
PZmqParam pzmq_createParamClient(int type, int nbBufferMessage=10000, int bufferSizeByte=1000000, size_t threadAffinity=0lu, ssize_t dataRate=200000l)
Create param for a client socket.
PSendStatus::PSendStatus checkSendStatus(zmq::send_result_t res)
Check the send result and convert it into PSendStatus.
zmq::context_t p_context
Context ZMQ.
PZmqParam Param
Define the type of extra parameters which can be used to create a Socket used by the PAbstractSocketM...
PZmqBackend()
Default constructor of PZmqBackend setting the number of threads for zmq I/O to 1.
void msgToMock(DataStreamMsg &mockMsg, const Message &msg)
Copy current backend message data into mock message.
bool createClientSocket(Socket &socket, const PSocketParam &socketParam, const PZmqParam ¶m)
Create a client socket.
static Param client()
Create a client parameter.
bool createServerSocket(Socket &socket, const PSocketParam &socketParam, const PZmqParam ¶m)
Create a server socket.
PZmqSocket Socket
Define the socket of the backend used by the PAbstractSocketManager.
void mockToMsg(Message &msg, DataStreamMsg &mockMsg)
Copy mock message data into current backend message.
static Param server()
Create a server parameter.
zmq::message_t Message
Define the type of message used by the PAbstractSocketManager.
PhoenixSocket API bridge to ZMQ socket.
zmq::socket_t * p_socket
ZMQ Socket.
PZmqSocket()
Default constructor of PZmqSocket.
bool isConnected() const
Check if the socket is connected.
bool createClientSocket(zmq::context_t &context, const PSocketParam &socketParam, const Param &extraParam)
Create a client socket.
PSendStatus::PSendStatus sendData(const T &data, PSendFlag::PSendFlag flag=PSendFlag::BLOCK)
Send data with the socket.
PSendStatus::PSendStatus sendMsg(Message &msg, PSendFlag::PSendFlag flag=PSendFlag::BLOCK)
Send data with the socket.
void close()
Close the socket.
bool createServerSocket(zmq::context_t &context, const PSocketParam &socketParam, const Param &extraParam)
Create a server socket.
PZmqParam Param
Define the type of extra parameters which can be used to create a Socket used by the PAbstractSocketM...
virtual ~PZmqSocket()
Destructor of PZmqSocket.
PRecvStatus::PRecvStatus recvData(T &data, PRecvFlag::PRecvFlag flag=PRecvFlag::BLOCK)
Recieved data with the socket.
PRecvStatus::PRecvStatus recvMsg(Message &msg, PRecvFlag::PRecvFlag flag=PRecvFlag::BLOCK)
Receive data with the socket.
zmq::message_t Message
Define the type of message used by the PAbstractSocketManager.
Set of parameters to be passed to create a socket with zmq backend.
ssize_t dataRate
Data rate.
int nbBufferMessage
Number of messages in the buffer.
int bufferSizeByte
Size of the message buffer in bytes.
size_t threadAffinity
Mask of threads which deal with reconnection.