Main MRPT website > C++ reference for MRPT 1.9.9
Namespaces | Functions
Serialization functions for ZMQ (v3

Detailed Description

or above) (in #include <mrpt/utils/serialization_zmq.h>)

Collaboration diagram for Serialization functions for ZMQ (v3:

Namespaces

 mrpt::utils::internal
 

Functions

template<typename ZMQ_SOCKET_TYPE >
void mrpt::utils::mrpt_send_to_zmq (ZMQ_SOCKET_TYPE zmq_socket, const mrpt::utils::CSerializable &obj, const size_t max_packet_len=0)
 Send an MRPT object to a ZMQ socket. More...
 
template<typename ZMQ_SOCKET_TYPE , typename VECTOR_MSG_T >
bool mrpt::utils::mrpt_recv_from_zmq_buf (ZMQ_SOCKET_TYPE zmq_socket, VECTOR_MSG_T &out_lst_msgs, mrpt::utils::CMemoryStream &target_buf, bool dont_wait, size_t *rx_obj_length_in_bytes)
 Users may normally call mrpt_recv_from_zmq() and mrpt_recv_from_zmq_into(). More...
 
template<typename ZMQ_SOCKET_TYPE >
mrpt::utils::CSerializable::Ptr mrpt::utils::mrpt_recv_from_zmq (ZMQ_SOCKET_TYPE zmq_socket, bool dont_wait=false, size_t *rx_obj_length_in_bytes=nullptr)
 Receives an MRPT object from a ZMQ socket, determining the type of the object on-the-fly. More...
 
template<typename ZMQ_SOCKET_TYPE >
bool mrpt::utils::mrpt_recv_from_zmq_into (ZMQ_SOCKET_TYPE zmq_socket, mrpt::utils::CSerializable &target_object, bool dont_wait=false, size_t *rx_obj_length_in_bytes=nullptr)
 Like mrpt_recv_from_zmq() but without dynamically allocating the received object, more efficient to use if the type of the received object is known in advance. More...
 

Function Documentation

◆ mrpt_recv_from_zmq()

template<typename ZMQ_SOCKET_TYPE >
mrpt::utils::CSerializable::Ptr mrpt::utils::mrpt_recv_from_zmq ( ZMQ_SOCKET_TYPE  zmq_socket,
bool  dont_wait = false,
size_t *  rx_obj_length_in_bytes = nullptr 
)

Receives an MRPT object from a ZMQ socket, determining the type of the object on-the-fly.

Parameters
[in]zmq_socketThe zmq socket object.
[in]dont_waitIf true, will fail if there is no data ready to be read. If false (default) this function will block until data arrives.
[out]rx_obj_length_in_bytesIf non-nullptr, the object length will be stored here.
Returns
An empty smart pointer if there was any error. The received object if all went OK.
Note
Including <mrpt/utils/serialization_zmq.h> requires libzmq to be available in your system and linked to your user code. This function can be used even if MRPT was built without ZMQ support, thanks to the use of templates.
Exceptions
std::exceptionIf the object finds any critical error during de-serialization.
See also
mrpt_recv_from_zmq_into
Note
See examples of usage in https://github.com/MRPT/mrpt/tree/master/doc/mrpt-zeromq-example

Definition at line 175 of file serialization_zmq.h.

References mrpt::utils::internal::free_zmq_msg_lst(), mrpt::utils::mrpt_recv_from_zmq_buf(), and mrpt::utils::CStream::ReadObject().

Here is the call graph for this function:

◆ mrpt_recv_from_zmq_buf()

template<typename ZMQ_SOCKET_TYPE , typename VECTOR_MSG_T >
bool mrpt::utils::mrpt_recv_from_zmq_buf ( ZMQ_SOCKET_TYPE  zmq_socket,
VECTOR_MSG_T &  out_lst_msgs,
mrpt::utils::CMemoryStream target_buf,
bool  dont_wait,
size_t *  rx_obj_length_in_bytes 
)

Users may normally call mrpt_recv_from_zmq() and mrpt_recv_from_zmq_into().

This function just stores the received data into a memory buffer without parsing it into an MRPT object.

Returns
false on any error

Definition at line 97 of file serialization_zmq.h.

References mrpt::utils::CMemoryStream::assignMemoryNotOwn(), mrpt::utils::CMemoryStream::Clear(), mrpt::utils::CMemoryStream::getTotalBytesCount(), mrpt::utils::CMemoryStream::Seek(), and mrpt::utils::CStream::WriteBuffer().

Referenced by mrpt::utils::mrpt_recv_from_zmq(), and mrpt::utils::mrpt_recv_from_zmq_into().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mrpt_recv_from_zmq_into()

template<typename ZMQ_SOCKET_TYPE >
bool mrpt::utils::mrpt_recv_from_zmq_into ( ZMQ_SOCKET_TYPE  zmq_socket,
mrpt::utils::CSerializable target_object,
bool  dont_wait = false,
size_t *  rx_obj_length_in_bytes = nullptr 
)

Like mrpt_recv_from_zmq() but without dynamically allocating the received object, more efficient to use if the type of the received object is known in advance.

Parameters
[in]target_objectThe received object will be stored here. An exception will be raised upon type mismatch.
Returns
true if all was OK, false on any ZMQ error.
See also
mrpt_recv_from_zmq() for details on the rest of parameters.
Note
See examples of usage in https://github.com/MRPT/mrpt/tree/master/doc/mrpt-zeromq-example

Definition at line 203 of file serialization_zmq.h.

References mrpt::utils::internal::free_zmq_msg_lst(), mrpt::utils::mrpt_recv_from_zmq_buf(), and mrpt::utils::CStream::ReadObject().

Here is the call graph for this function:

◆ mrpt_send_to_zmq()

template<typename ZMQ_SOCKET_TYPE >
void mrpt::utils::mrpt_send_to_zmq ( ZMQ_SOCKET_TYPE  zmq_socket,
const mrpt::utils::CSerializable obj,
const size_t  max_packet_len = 0 
)

Send an MRPT object to a ZMQ socket.

Parameters
[in]objThe object to be serialized and sent to the socket.
[in]zmq_socketThe zmq socket object.
[in]max_packet_lenThe object will be split into a series of ZMQ "message parts" of this maximum length (in bytes). Default=0, which means do not split in parts.
Note
Including <mrpt/utils/serialization_zmq.h> requires libzmq to be available in your system and linked to your user code. This function can be used even if MRPT was built without ZMQ support, thanks to the use of templates.
Exceptions
std::exceptionIf the object finds any critical error during serialization or on ZMQ errors.
Note
See examples of usage in https://github.com/MRPT/mrpt/tree/master/doc/mrpt-zeromq-example

Definition at line 41 of file serialization_zmq.h.

References mrpt::utils::internal::TFreeFnDataForZMQ::buf, mrpt::utils::internal::TFreeFnDataForZMQ::do_free, mrpt::utils::internal::free_fn_for_zmq(), mrpt::utils::CMemoryStream::getRawBufferData(), mrpt::utils::CMemoryStream::getTotalBytesCount(), and mrpt::utils::CStream::WriteObject().

Here is the call graph for this function:



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019