Goby3  3.1.4
2024.02.22
goby::acomms::DynamicBuffer< T, Clock > Class Template Reference

Represents a time-dependent priority queue for several groups of messages (multiple DynamicSubBuffers) More...

#include <goby/acomms/buffer/dynamic_buffer.h>

Classes

struct  Value
 

Public Types

using subbuffer_id_type = std::string
 
using size_type = typename DynamicSubBuffer< T, Clock >::size_type
 
using modem_id_type = int
 

Public Member Functions

 DynamicBuffer ()
 
 DynamicBuffer (int id)
 
 ~DynamicBuffer ()
 
void create (modem_id_type dest_id, const subbuffer_id_type &sub_id, const goby::acomms::protobuf::DynamicBufferConfig &cfg)
 Create a new subbuffer with the given configuration. More...
 
void create (modem_id_type dest_id, const subbuffer_id_type &sub_id, const std::vector< goby::acomms::protobuf::DynamicBufferConfig > &cfgs)
 Create a new subbuffer merging the given configuration (See DynamicSubBuffer() for details) More...
 
void replace (modem_id_type dest_id, const subbuffer_id_type &sub_id, const goby::acomms::protobuf::DynamicBufferConfig &cfg)
 Replace an existing subbuffer with the given configuration (any messages in the subbuffer will be erased) More...
 
void replace (modem_id_type dest_id, const subbuffer_id_type &sub_id, const std::vector< goby::acomms::protobuf::DynamicBufferConfig > &cfgs)
 Replace an existing subbuffer merging the given configuration (See DynamicSubBuffer() for details) More...
 
void update (modem_id_type dest_id, const subbuffer_id_type &sub_id, const goby::acomms::protobuf::DynamicBufferConfig &cfg)
 Update an existing subbuffer without removing the messsages. More...
 
void update (modem_id_type dest_id, const subbuffer_id_type &sub_id, const std::vector< goby::acomms::protobuf::DynamicBufferConfig > &cfgs)
 Update an existing subbuffer without removing the messsages (or creates the buffer if it doesn't already exist) More...
 
void remove (modem_id_type dest_id, const subbuffer_id_type &sub_id)
 Remove an existing subbuffer. More...
 
std::vector< Valuepush (const Value &fvt)
 Push a new message to the buffer. More...
 
bool empty () const
 Is this buffer empty (that is, are all subbuffers empty)? More...
 
size_type size () const
 Size of the buffer (that is, sum of the subbuffer sizes) More...
 
Value top (modem_id_type dest_id=goby::acomms::QUERY_DESTINATION_ID, size_type max_bytes=std::numeric_limits< size_type >::max(), typename Clock::duration ack_timeout=std::chrono::microseconds(0))
 Returns the top value in a priority contest between all subbuffers. More...
 
bool erase (const Value &value)
 Erase a value. More...
 
std::vector< Valueexpire ()
 Erase any values that have exceeded their time-to-live. More...
 
DynamicSubBuffer< T, Clock > & sub (modem_id_type dest_id, const subbuffer_id_type &sub_id)
 Reference a given subbuffer. More...
 

Detailed Description

template<typename T, typename Clock = goby::time::SteadyClock>
class goby::acomms::DynamicBuffer< T, Clock >

Represents a time-dependent priority queue for several groups of messages (multiple DynamicSubBuffers)

Definition at line 346 of file dynamic_buffer.h.

Member Typedef Documentation

◆ modem_id_type

template<typename T , typename Clock = goby::time::SteadyClock>
using goby::acomms::DynamicBuffer< T, Clock >::modem_id_type = int

Definition at line 359 of file dynamic_buffer.h.

◆ size_type

template<typename T , typename Clock = goby::time::SteadyClock>
using goby::acomms::DynamicBuffer< T, Clock >::size_type = typename DynamicSubBuffer<T, Clock>::size_type

Definition at line 358 of file dynamic_buffer.h.

◆ subbuffer_id_type

template<typename T , typename Clock = goby::time::SteadyClock>
using goby::acomms::DynamicBuffer< T, Clock >::subbuffer_id_type = std::string

Definition at line 357 of file dynamic_buffer.h.

Constructor & Destructor Documentation

◆ DynamicBuffer() [1/2]

template<typename T , typename Clock = goby::time::SteadyClock>
goby::acomms::DynamicBuffer< T, Clock >::DynamicBuffer ( )
inline

Definition at line 349 of file dynamic_buffer.h.

◆ DynamicBuffer() [2/2]

template<typename T , typename Clock = goby::time::SteadyClock>
goby::acomms::DynamicBuffer< T, Clock >::DynamicBuffer ( int  id)
inline

Definition at line 350 of file dynamic_buffer.h.

◆ ~DynamicBuffer()

template<typename T , typename Clock = goby::time::SteadyClock>
goby::acomms::DynamicBuffer< T, Clock >::~DynamicBuffer ( )
inline

Definition at line 355 of file dynamic_buffer.h.

Member Function Documentation

◆ create() [1/2]

template<typename T , typename Clock = goby::time::SteadyClock>
void goby::acomms::DynamicBuffer< T, Clock >::create ( modem_id_type  dest_id,
const subbuffer_id_type sub_id,
const goby::acomms::protobuf::DynamicBufferConfig cfg 
)
inline

Create a new subbuffer with the given configuration.

This must be called before using functions that reference this subbuffer ID (e.g. push(...), erase(...))

Parameters
dest_idThe modem id destination for these messages
sub_idAn identifier for this subbuffer
cfgThe configuration for this new subbuffer

Definition at line 375 of file dynamic_buffer.h.

◆ create() [2/2]

template<typename T , typename Clock = goby::time::SteadyClock>
void goby::acomms::DynamicBuffer< T, Clock >::create ( modem_id_type  dest_id,
const subbuffer_id_type sub_id,
const std::vector< goby::acomms::protobuf::DynamicBufferConfig > &  cfgs 
)
inline

Create a new subbuffer merging the given configuration (See DynamicSubBuffer() for details)

This must be called before using functions that reference this subbuffer ID (e.g. push(...), erase(...))

Parameters
dest_idThe modem id destination for these messages
sub_idAn identifier for this subbuffer
cfgsThe configuration for this new subbuffer

Definition at line 387 of file dynamic_buffer.h.

◆ empty()

template<typename T , typename Clock = goby::time::SteadyClock>
bool goby::acomms::DynamicBuffer< T, Clock >::empty ( ) const
inline

Is this buffer empty (that is, are all subbuffers empty)?

Definition at line 469 of file dynamic_buffer.h.

◆ erase()

template<typename T , typename Clock = goby::time::SteadyClock>
bool goby::acomms::DynamicBuffer< T, Clock >::erase ( const Value value)
inline

Erase a value.

Parameters
valueValue to erase (if it exists)
Returns
true if the value was found and erase, false if the value was not found
Exceptions
goby::ExceptionIf subbuffer doesn't exist

Definition at line 589 of file dynamic_buffer.h.

◆ expire()

template<typename T , typename Clock = goby::time::SteadyClock>
std::vector<Value> goby::acomms::DynamicBuffer< T, Clock >::expire ( )
inline

Erase any values that have exceeded their time-to-live.

Returns
Vector of values that have expired and have been erased

Definition at line 597 of file dynamic_buffer.h.

◆ push()

template<typename T , typename Clock = goby::time::SteadyClock>
std::vector<Value> goby::acomms::DynamicBuffer< T, Clock >::push ( const Value fvt)
inline

Push a new message to the buffer.

Parameters
fvtFull tuple giving subbuffer id, time, and value
Returns
vector of values removed due to max_queue being exceeded
Exceptions
goby::ExceptionIf subbuffer doesn't exist

Definition at line 459 of file dynamic_buffer.h.

◆ remove()

template<typename T , typename Clock = goby::time::SteadyClock>
void goby::acomms::DynamicBuffer< T, Clock >::remove ( modem_id_type  dest_id,
const subbuffer_id_type sub_id 
)
inline

Remove an existing subbuffer.

Parameters
dest_idThe modem id destination for these messages
sub_idAn identifier for this subbuffer

Definition at line 449 of file dynamic_buffer.h.

◆ replace() [1/2]

template<typename T , typename Clock = goby::time::SteadyClock>
void goby::acomms::DynamicBuffer< T, Clock >::replace ( modem_id_type  dest_id,
const subbuffer_id_type sub_id,
const goby::acomms::protobuf::DynamicBufferConfig cfg 
)
inline

Replace an existing subbuffer with the given configuration (any messages in the subbuffer will be erased)

Parameters
dest_idThe modem id destination for these messages
sub_idAn identifier for this subbuffer
cfgThe configuration for this replacement subbuffer

Definition at line 401 of file dynamic_buffer.h.

◆ replace() [2/2]

template<typename T , typename Clock = goby::time::SteadyClock>
void goby::acomms::DynamicBuffer< T, Clock >::replace ( modem_id_type  dest_id,
const subbuffer_id_type sub_id,
const std::vector< goby::acomms::protobuf::DynamicBufferConfig > &  cfgs 
)
inline

Replace an existing subbuffer merging the given configuration (See DynamicSubBuffer() for details)

Parameters
dest_idThe modem id destination for these messages
sub_idAn identifier for this subbuffer
cfgsThe configuration for this replacement subbuffer

Definition at line 412 of file dynamic_buffer.h.

◆ size()

template<typename T , typename Clock = goby::time::SteadyClock>
size_type goby::acomms::DynamicBuffer< T, Clock >::size ( ) const
inline

Size of the buffer (that is, sum of the subbuffer sizes)

Definition at line 484 of file dynamic_buffer.h.

◆ sub()

template<typename T , typename Clock = goby::time::SteadyClock>
DynamicSubBuffer<T, Clock>& goby::acomms::DynamicBuffer< T, Clock >::sub ( modem_id_type  dest_id,
const subbuffer_id_type sub_id 
)
inline

Reference a given subbuffer.

Exceptions
goby::ExceptionIf subbuffer doesn't exist

Definition at line 616 of file dynamic_buffer.h.

◆ top()

template<typename T , typename Clock = goby::time::SteadyClock>
Value goby::acomms::DynamicBuffer< T, Clock >::top ( modem_id_type  dest_id = goby::acomms::QUERY_DESTINATION_ID,
size_type  max_bytes = std::numeric_limits<size_type>::max(),
typename Clock::duration  ack_timeout = std::chrono::microseconds(0) 
)
inline

Returns the top value in a priority contest between all subbuffers.

Parameters
dest_idModem id for this packet (can be QUERY_DESTINATION_ID to query all possible destinations)
max_bytesMaximum number of bytes in the returned message
ack_timeoutDuration to wait before resending a value
Returns
Value with the highest priority (DynamicSubBuffer::top_value()) of all the subbuffers

Definition at line 500 of file dynamic_buffer.h.

◆ update() [1/2]

template<typename T , typename Clock = goby::time::SteadyClock>
void goby::acomms::DynamicBuffer< T, Clock >::update ( modem_id_type  dest_id,
const subbuffer_id_type sub_id,
const goby::acomms::protobuf::DynamicBufferConfig cfg 
)
inline

Update an existing subbuffer without removing the messsages.

Parameters
dest_idThe modem id destination for these messages
sub_idAn identifier for this subbuffer
cfgThe configuration for this updated subbuffer

Definition at line 424 of file dynamic_buffer.h.

◆ update() [2/2]

template<typename T , typename Clock = goby::time::SteadyClock>
void goby::acomms::DynamicBuffer< T, Clock >::update ( modem_id_type  dest_id,
const subbuffer_id_type sub_id,
const std::vector< goby::acomms::protobuf::DynamicBufferConfig > &  cfgs 
)
inline

Update an existing subbuffer without removing the messsages (or creates the buffer if it doesn't already exist)

Parameters
dest_idThe modem id destination for these messages
sub_idAn identifier for this subbuffer
cfgsThe configuration for this updated subbuffer

Definition at line 435 of file dynamic_buffer.h.


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