RTC Toolkit  2.0.0
Public Member Functions | List of all members
rtctk::telRepub::RepubBuf< T > Class Template Reference

Implementation of buffer (ring) that allows to have preallocated slots of type T. More...

#include <repubBuf.hpp>

Public Member Functions

 RepubBuf (const std::string &id, uint16_t size)
 Create buffer with: More...
 
 RepubBuf (const char *id, uint16_t size)
 Create buffer with: More...
 
 RepubBuf (uint16_t size)
 Create buffer without identifier, but with. More...
 
 ~RepubBuf () noexcept
 
 RepubBuf (RepubBuf &&rhs)=delete
 
RepubBufoperator= (RepubBuf &&rhs)=delete
 
T * GetNextFree ()
 Returns next free slot of the buffer. More...
 
void MakeAvailable ()
 Returns back (filled/set) slot that has been retrieved by GetNextFree. More...
 
void ReleaseFree ()
 Release slot (not filled/set) that has been retrieved by GetNextFree. More...
 
T * GetNextAvail ()
 Returns next available (filled/set) slot. More...
 
T * WaitNextAvail ()
 The call blocks (waits) for next available (filled/set) slot. More...
 
void MakeFree ()
 Returns back slot that has been retrived/given by call WaitNextAvail or GetNextAvail. More...
 
void ReleaseWait ()
 Release WaitNextAvail. More...
 
uint16_t GetFreeCapacity ()
 Number of free slots in buffer that can be retrieved by calling GetNextFree. More...
 
uint16_t GetAvail ()
 Number of availabel (occupied) (filled/set) slots in buffer that can be retrieved by calling WaitNextAvail or GetNextAvail. More...
 
void DumpStatistic ()
 Dumps statistic(s): maximum occupancy of the buffer. More...
 
uint16_t GetMaxOccupancy ()
 Returns maximal occupancy of the buffer. More...
 
uint16_t GetSize ()
 Returns (maximal) queue/buffer. More...
 

Detailed Description

template<typename T = rtctk::componentFramework::AgnosticTopic>
class rtctk::telRepub::RepubBuf< T >

Implementation of buffer (ring) that allows to have preallocated slots of type T.

Buffer allows that a producer takes (gets) a free slot i.e. slot that is already allocated, but the value is not set. Producer can set value of the slot and retrun it back, and make it available for consumption. It is implemented with assumption that it is taken just one free slot at the time i.e. the next free slot is requested after the previos one is returned i.e makdae available for consumption. A consumer can in similar way request next available slot i.e. slot that has already set value. Again here the next avilabel slot can be requested after the previos one is returned. It can use it and after return it back to be available as free slot. The buffer is implemented for one producer and one consumer use case.

Constructor & Destructor Documentation

◆ RepubBuf() [1/4]

template<typename T = rtctk::componentFramework::AgnosticTopic>
rtctk::telRepub::RepubBuf< T >::RepubBuf ( const std::string &  id,
uint16_t  size 
)
inline

Create buffer with:

Parameters
ididentifier
sizesize

◆ RepubBuf() [2/4]

template<typename T = rtctk::componentFramework::AgnosticTopic>
rtctk::telRepub::RepubBuf< T >::RepubBuf ( const char *  id,
uint16_t  size 
)
inline

Create buffer with:

Parameters
ididentifier
sizesize

◆ RepubBuf() [3/4]

template<typename T = rtctk::componentFramework::AgnosticTopic>
rtctk::telRepub::RepubBuf< T >::RepubBuf ( uint16_t  size)
inline

Create buffer without identifier, but with.

Parameters
sizesize

◆ ~RepubBuf()

template<typename T = rtctk::componentFramework::AgnosticTopic>
rtctk::telRepub::RepubBuf< T >::~RepubBuf ( )
inlinenoexcept

◆ RepubBuf() [4/4]

template<typename T = rtctk::componentFramework::AgnosticTopic>
rtctk::telRepub::RepubBuf< T >::RepubBuf ( RepubBuf< T > &&  rhs)
delete

Member Function Documentation

◆ DumpStatistic()

template<typename T = rtctk::componentFramework::AgnosticTopic>
void rtctk::telRepub::RepubBuf< T >::DumpStatistic ( )
inline

Dumps statistic(s): maximum occupancy of the buffer.

It is not thread safe as it is forseen to be used just at the end of usage of the buffer.

◆ GetAvail()

template<typename T = rtctk::componentFramework::AgnosticTopic>
uint16_t rtctk::telRepub::RepubBuf< T >::GetAvail ( )
inline

Number of availabel (occupied) (filled/set) slots in buffer that can be retrieved by calling WaitNextAvail or GetNextAvail.

Returns
: number of available slots.

◆ GetFreeCapacity()

template<typename T = rtctk::componentFramework::AgnosticTopic>
uint16_t rtctk::telRepub::RepubBuf< T >::GetFreeCapacity ( )
inline

Number of free slots in buffer that can be retrieved by calling GetNextFree.

Returns
: number of free slots.

◆ GetMaxOccupancy()

template<typename T = rtctk::componentFramework::AgnosticTopic>
uint16_t rtctk::telRepub::RepubBuf< T >::GetMaxOccupancy ( )
inline

Returns maximal occupancy of the buffer.

◆ GetNextAvail()

template<typename T = rtctk::componentFramework::AgnosticTopic>
T* rtctk::telRepub::RepubBuf< T >::GetNextAvail ( )
inline

Returns next available (filled/set) slot.

Call does not block i.e. wait.

Returns
: pointer to next filled/set slot, if not available nullptr

◆ GetNextFree()

template<typename T = rtctk::componentFramework::AgnosticTopic>
T* rtctk::telRepub::RepubBuf< T >::GetNextFree ( )
inline

Returns next free slot of the buffer.

Which can be filled, and returned back by callling MakeAvailable

Returns
: pointer to next free slot in buffer.

◆ GetSize()

template<typename T = rtctk::componentFramework::AgnosticTopic>
uint16_t rtctk::telRepub::RepubBuf< T >::GetSize ( )
inline

Returns (maximal) queue/buffer.

◆ MakeAvailable()

template<typename T = rtctk::componentFramework::AgnosticTopic>
void rtctk::telRepub::RepubBuf< T >::MakeAvailable ( )
inline

Returns back (filled/set) slot that has been retrieved by GetNextFree.

Buffer slot is available to be retrieved by calling GetNextAvail e.g. for publishing.

◆ MakeFree()

template<typename T = rtctk::componentFramework::AgnosticTopic>
void rtctk::telRepub::RepubBuf< T >::MakeFree ( )
inline

Returns back slot that has been retrived/given by call WaitNextAvail or GetNextAvail.

The slot is after available as free slot and can be returned by GetNextFree

◆ operator=()

template<typename T = rtctk::componentFramework::AgnosticTopic>
RepubBuf& rtctk::telRepub::RepubBuf< T >::operator= ( RepubBuf< T > &&  rhs)
delete

◆ ReleaseFree()

template<typename T = rtctk::componentFramework::AgnosticTopic>
void rtctk::telRepub::RepubBuf< T >::ReleaseFree ( )
inline

Release slot (not filled/set) that has been retrieved by GetNextFree.

It can be used in case when we retrieved a slot by GetNextFree, but we do not want to return the slot filled. This can be the case at stop. The released slot is available for next GetNextFree, and no buffer slot is available to GetNextAvail, but it is avail

◆ ReleaseWait()

template<typename T = rtctk::componentFramework::AgnosticTopic>
void rtctk::telRepub::RepubBuf< T >::ReleaseWait ( )
inline

Release WaitNextAvail.

◆ WaitNextAvail()

template<typename T = rtctk::componentFramework::AgnosticTopic>
T* rtctk::telRepub::RepubBuf< T >::WaitNextAvail ( )
inline

The call blocks (waits) for next available (filled/set) slot.

It returns when next availabe (filled/set) slot is there. Alternatively can be relased by calling ReleaseWait.

Returns
: pointer to next available (filledset) slot, or nullptr in case of force release

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