YAMI4 C++ Library 2.0.0
Messaging Solution for Distributed Systems
Loading...
Searching...
No Matches
Public Member Functions | List of all members
yami::raw_buffer_data_source Class Reference

Serializable wrapper for the raw binary data. More...

#include <raw_buffer_data_source.h>

Inheritance diagram for yami::raw_buffer_data_source:
yami::serializable

Public Member Functions

 raw_buffer_data_source (const char **buffers, const std::size_t *buffer_sizes, std::size_t num_of_buffers)
 Constructor. More...
 
 raw_buffer_data_source (const char *buffer, std::size_t buffer_size)
 Constructor. More...
 
 raw_buffer_data_source (const std::vector< char > &buffer)
 Constructor. More...
 
virtual std::size_t serialize_buffer_size () const
 Returns the total size of serialization buffer. More...
 
virtual void serialize (char **buffers, std::size_t *buffer_sizes, std::size_t num_of_buffers) const
 Serializes current content into given buffer(s). More...
 
virtual const core::serializable & get_core_object () const
 Provides access to the underlying core object. More...
 
virtual std::size_t serialize_buffer_size () const =0
 Returns the total size of serialization buffer. More...
 
virtual void serialize (char **buffers, std::size_t *buffer_sizes, std::size_t num_of_buffers) const =0
 Serializes current content into given buffer(s). More...
 
virtual const core::serializable & get_core_object () const =0
 Provides access to the underlying core object. More...
 

Detailed Description

Serializable wrapper for the raw binary data.

Serializable wrapper for the raw binary data allows to use already serialized content for message sending. The two major use cases for this class are efficient message forwarding (when the message is received and its content is used for another message) and support for custom data models and serializers.

Constructor & Destructor Documentation

◆ raw_buffer_data_source() [1/3]

yami::raw_buffer_data_source::raw_buffer_data_source ( const char **  buffers,
const std::size_t *  buffer_sizes,
std::size_t  num_of_buffers 
)

Constructor.

Constructs the buffer wrapper for the given set of buffers. The data buffer does not have to be contiguous and any number of buffer segments is allowed, provided that the size of each buffer segment is a multiple of 4 (32 bits).
The wrapper gathers the binary data from subsequent buffers as they are serialized - serialization of the wrapper copies the data from source set of buffers to the target set, which is possibly structured in a different way.
The buffers are provided as array of buffer pointers and their sizes.

Parameters
buffersPointer to the array of buffer pointers (each of type const char *).
buffer_sizesPointer to the array of buffer sizes.
num_of_buffersNumber of buffers described by the array.

◆ raw_buffer_data_source() [2/3]

yami::raw_buffer_data_source::raw_buffer_data_source ( const char *  buffer,
std::size_t  buffer_size 
)

Constructor.

Constructs the buffer wrapper for the single contiguous source buffer.

Parameters
bufferPointer to the source buffer.
buffer_sizeSource buffer size.

◆ raw_buffer_data_source() [3/3]

yami::raw_buffer_data_source::raw_buffer_data_source ( const std::vector< char > &  buffer)

Constructor.

Constructs the buffer wrapper for the single contiguous source buffer, which is given as a vector<char>.

Parameters
bufferSource buffer.

Member Function Documentation

◆ get_core_object()

virtual const core::serializable & yami::raw_buffer_data_source::get_core_object ( ) const
virtual

Provides access to the underlying core object.

Implements yami::serializable.

◆ serialize()

virtual void yami::raw_buffer_data_source::serialize ( char **  buffers,
std::size_t *  buffer_sizes,
std::size_t  num_of_buffers 
) const
virtual

Serializes current content into given buffer(s).

Serializes the current content of this object into the given buffer(s). The serialization buffer does not have to be contiguous and any number of buffer segments is allowed, provided that the size of each buffer segment is a multiple of 4 (32 bits).
The function scatters the serialized data into subsequent buffers as they become filled.
The buffers are provided as array of buffer pointers and their sizes.

Parameters
buffersPointer to the array of buffer pointers (each of type char *).
buffer_sizesPointer to the array of buffer sizes.
num_of_buffersNumber of buffers described by the array.

Implements yami::serializable.

◆ serialize_buffer_size()

virtual std::size_t yami::raw_buffer_data_source::serialize_buffer_size ( ) const
virtual

Returns the total size of serialization buffer.

Computes the total size of serialization buffer(s) for the current content of this object.

Implements yami::serializable.


The documentation for this class was generated from the following file: