Helios++
Helios software for LiDAR simulations
helios::filems::BufferedReadingStrategy< ReadArg > Class Template Reference

Class defining a strategy that provides support for buffering of consecutive readings. More...

#include <BufferedReadingStrategy.h>

Inheritance diagram for helios::filems::BufferedReadingStrategy< ReadArg >:
Collaboration diagram for helios::filems::BufferedReadingStrategy< ReadArg >:

Public Member Functions

 BufferedReadingStrategy (ReadingStrategy< ReadArg > &readingStrategy, size_t const bufferSize=256)
 Default constructor for buffered reading strategy. More...
 
ReadArg read () override
 Take until buffer is empty, read always that buffer needs to be fulfilled. More...
 
virtual size_t getBufferSize ()
 Obtain the buffer size. More...
 
virtual void setBufferSize (size_t const bufferSize)
 Set the buffer size and update the buffer to fit. More...
 
- Public Member Functions inherited from helios::filems::ReadingStrategy< ReadArg >
 ReadingStrategy ()=default
 Default constructor for reading strategy.
 

Protected Member Functions

virtual bool isBufferEmpty () const
 Check whether the buffer is empty or not. More...
 

Protected Attributes

size_t bufferSize
 The maximum number of ReadArg type elements that a buffer is allowed to hold.
 
ReadArg * buffer = nullptr
 The buffer where multiple consecutive reads are stored.
 
ReadingStrategy< ReadArg > & readingStrategy
 The reading strategy that is being extended with buffer support.
 
size_t cachedIndex = 0
 The cached index defining the state of the buffer.
 
size_t cachedMaxIndex = 0
 The cached index defining the next to the greatest admissible index for the current state of the buffer.
 

Detailed Description

template<typename ReadArg>
class helios::filems::BufferedReadingStrategy< ReadArg >

Class defining a strategy that provides support for buffering of consecutive readings.

Author
Alberto M. Esmoris Pena
Version
1.0
Template Parameters
ReadArgType of what is being read

Constructor & Destructor Documentation

◆ BufferedReadingStrategy()

template<typename ReadArg >
helios::filems::BufferedReadingStrategy< ReadArg >::BufferedReadingStrategy ( ReadingStrategy< ReadArg > &  readingStrategy,
size_t const  bufferSize = 256 
)
inline

Default constructor for buffered reading strategy.

See also
BufferedReadingStrategy::readingStrategy

Member Function Documentation

◆ getBufferSize()

template<typename ReadArg >
virtual size_t helios::filems::BufferedReadingStrategy< ReadArg >::getBufferSize ( )
inlinevirtual

◆ isBufferEmpty()

template<typename ReadArg >
virtual bool helios::filems::BufferedReadingStrategy< ReadArg >::isBufferEmpty ( ) const
inlineprotectedvirtual

Check whether the buffer is empty or not.

Returns
True if the buffer is empty, false otherwise

◆ read()

template<typename ReadArg >
ReadArg helios::filems::BufferedReadingStrategy< ReadArg >::read ( )
inlineoverridevirtual

Take until buffer is empty, read always that buffer needs to be fulfilled.

Returns
Either what has been read from input reading strategy or throw an exception if it passes through it

Implements helios::filems::ReadingStrategy< ReadArg >.

◆ setBufferSize()

template<typename ReadArg >
virtual void helios::filems::BufferedReadingStrategy< ReadArg >::setBufferSize ( size_t const  bufferSize)
inlinevirtual

Set the buffer size and update the buffer to fit.

Parameters
bufferSizeThe new buffer size
See also
filems::BufferedReadingStrategy::bufferSize
filems::BufferedReadingStrategy::getBufferSize

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