Class CPayloadWriter

Inheritance Relationships

Derived Types

Class Documentation

class CPayloadWriter

Base payload writer class to allow zero copy memory operations.

This class serves as the base class for payload writers, allowing zero-copy memory operations. The WriteFull and WriteModified calls may operate on the target memory file directly in zero-copy mode.

A partial writing / modification of the memory file is only possible when zero-copy mode is activated. If zero-copy is not enabled, the WriteModified method is ignored and the WriteFull method is always executed (see CPublisher::ShmEnableZeroCopy)

Subclassed by CBinaryPayload, CBinaryPayload, CBinaryPayload, eCAL::CBufferPayloadWriter

Public Functions

CPayloadWriter() = default

Default constructor for CPayloadWriter.

virtual ~CPayloadWriter() = default

Virtual destructor for CPayloadWriter.

CPayloadWriter(const CPayloadWriter&) = default

Copy constructor (deleted).

CPayloadWriter(CPayloadWriter&&) = default

Move constructor (deleted).

CPayloadWriter &operator=(const CPayloadWriter&) = default

Copy assignment operator (deleted).

CPayloadWriter &operator=(CPayloadWriter&&) = default

Move assignment operator (deleted).

virtual bool WriteFull(void *buffer_, size_t size_) = 0

Perform a full write operation on uninitialized memory.

This virtual function allows derived classes to perform a full write operation when the provisioned memory is uninitialized. Typically, this is the case when a memory file had to be recreated or its size had to be changed.

Parameters:
  • buffer_ – Pointer to the buffer containing the data to be written.

  • size_ – Size of the data to be written.

Returns:

True if the write operation is successful, false otherwise.

inline virtual bool WriteModified(void *buffer_, size_t size_)

Perform a partial write operation to modify existing data.

This virtual function allows derived classes to modify existing data when the provisioned memory is already initialized by a WriteFull call (i.e. contains the data from that full write operation).

The memory can be partially modified and does not have to be completely rewritten, which leads to significantly higher performance (lower latency).

If not implemented (by default), this operation will just call the WriteFull function.

Parameters:
  • buffer_ – Pointer to the buffer containing the data to be modified.

  • size_ – Size of the data to be modified.

Returns:

True if the write/update operation is successful, false otherwise.

virtual size_t GetSize() = 0

Get the size of the required memory.

This virtual function allows derived classes to provide the size of the memory that eCAL needs to allocate.

Returns:

The size of the required memory.