Class astutedds::rtps::WriterHistoryCache

ClassList > astutedds > rtps > WriterHistoryCache

History cache for a DataWriter. More...

  • #include <writer_history_cache.hpp>

Public Types

Type Name
enum HistoryKind

Public Functions

Type Name
WriterHistoryCache (const GUID_t & writer_guid, HistoryKind history_kind=HistoryKind::KEEP_LAST, size_t history_depth=10)
Constructor.
SequenceNumber_t add_sample (const std::vector< uint8_t > & data, const std::vector< uint8_t > & instance_key={})
Add a new sample to the cache.
void clear ()
Clear all samples from the cache.
bool empty () const
Check if the cache has any samples.
SequenceNumber_t get_first_seq_num () const
Get the first available sequence number.
SequenceNumber_t get_last_seq_num () const
Get the last (highest) sequence number.
std::optional< CacheChange > get_sample (const SequenceNumber_t & seq_num) const
Get a sample by sequence number.
std::vector< CacheChange > get_samples_in_range (const SequenceNumber_t & first, const SequenceNumber_t & last) const
Get all samples in a sequence number range.
std::vector< CacheChange > get_unacknowledged () const
Get unacknowledged samples.
void mark_acknowledged (const SequenceNumber_t & seq_num)
Mark a sample as acknowledged.
void mark_acknowledged_up_to (const SequenceNumber_t & up_to_seq_num)
Mark all samples up to a sequence number as acknowledged.
void remove_older_than (std::chrono::milliseconds max_age)
Remove samples older than a certain age.
size_t size () const
Get number of samples in cache.

Detailed Description

Stores samples for reliable delivery and retransmission. Implements KEEP_LAST and KEEP_ALL history policies.

Public Types Documentation

enum HistoryKind

enum astutedds::rtps::WriterHistoryCache::HistoryKind {
    KEEP_LAST,
    KEEP_ALL
};

Public Functions Documentation

function WriterHistoryCache

Constructor.

explicit astutedds::rtps::WriterHistoryCache::WriterHistoryCache (
    const GUID_t & writer_guid,
    HistoryKind history_kind=HistoryKind::KEEP_LAST,
    size_t history_depth=10
) 

Parameters:

  • writer_guid GUID of the owning writer
  • history_kind KEEP_LAST or KEEP_ALL policy
  • history_depth Maximum samples to keep (for KEEP_LAST)

function add_sample

Add a new sample to the cache.

SequenceNumber_t astutedds::rtps::WriterHistoryCache::add_sample (
    const std::vector< uint8_t > & data,
    const std::vector< uint8_t > & instance_key={}
) 

Parameters:

  • data Serialized sample data
  • instance_key Instance key (for keyed topics)

Returns:

Sequence number assigned to this sample


function clear

Clear all samples from the cache.

void astutedds::rtps::WriterHistoryCache::clear () 


function empty

Check if the cache has any samples.

bool astutedds::rtps::WriterHistoryCache::empty () const

Returns:

True if cache is empty


function get_first_seq_num

Get the first available sequence number.

SequenceNumber_t astutedds::rtps::WriterHistoryCache::get_first_seq_num () const

Returns:

First sequence number in the cache


function get_last_seq_num

Get the last (highest) sequence number.

SequenceNumber_t astutedds::rtps::WriterHistoryCache::get_last_seq_num () const

Returns:

Last sequence number in the cache


function get_sample

Get a sample by sequence number.

std::optional< CacheChange > astutedds::rtps::WriterHistoryCache::get_sample (
    const SequenceNumber_t & seq_num
) const

Parameters:

  • seq_num Sequence number to retrieve

Returns:

The sample if found, nullopt otherwise


function get_samples_in_range

Get all samples in a sequence number range.

std::vector< CacheChange > astutedds::rtps::WriterHistoryCache::get_samples_in_range (
    const SequenceNumber_t & first,
    const SequenceNumber_t & last
) const

Parameters:

  • first First sequence number (inclusive)
  • last Last sequence number (inclusive)

Returns:

Vector of samples in the range


function get_unacknowledged

Get unacknowledged samples.

std::vector< CacheChange > astutedds::rtps::WriterHistoryCache::get_unacknowledged () const

Returns:

Vector of unacknowledged samples


function mark_acknowledged

Mark a sample as acknowledged.

void astutedds::rtps::WriterHistoryCache::mark_acknowledged (
    const SequenceNumber_t & seq_num
) 

Parameters:

  • seq_num Sequence number to mark

function mark_acknowledged_up_to

Mark all samples up to a sequence number as acknowledged.

void astutedds::rtps::WriterHistoryCache::mark_acknowledged_up_to (
    const SequenceNumber_t & up_to_seq_num
) 

Parameters:

  • up_to_seq_num Acknowledge all samples up to and including this

function remove_older_than

Remove samples older than a certain age.

void astutedds::rtps::WriterHistoryCache::remove_older_than (
    std::chrono::milliseconds max_age
) 

Parameters:

  • max_age Maximum age to keep

function size

Get number of samples in cache.

size_t astutedds::rtps::WriterHistoryCache::size () const

Returns:

Sample count



The documentation for this class was generated from the following file include/astutedds/rtps/writer_history_cache.hpp