Helios++
Helios software for LiDAR simulations
Yielder< T > Class Template Referenceabstract

Abstract class representing a yielder. It is, an object which can be used to accumulate inputs until either a yield is explicitly deleted or the yield condition is triggered, probably after a push request. More...

#include <Yielder.h>

Inheritance diagram for Yielder< T >:
Collaboration diagram for Yielder< T >:

Public Member Functions

 Yielder (std::size_t bufferSize=256)
 Default constructor for the abstract yielder. More...
 
void yield ()
 Make the yielder flush its elements so the output is performed.
 
void push (T const &elem)
 Push the element into the yielder. The element could be simply accumulated or either it could be directly written to file depending on yielder status at push time. More...
 
virtual void digest (vector< T > &copy)=0
 Abstract method that must be overridden by any concrete Yielder implementation to specify how a yield output must be handled/digested.
 
virtual vector< T > copyBuffer () const
 Make a copy of the buffer with its current state. More...
 
void setBufferSize (size_t const bufferSize)
 Set the buffer size of the yielder, effectively. More...
 
size_t getBufferSize () const
 Obtain the current buffer size of the yielder. More...
 

Protected Attributes

std::mutex mtx
 The mutex to handle concurrent push backs to the buffer vector and the yielding operation itself.
 
std::size_t bufferSize
 The number of elements that can be buffered before forcing the yield operation.
 
std::vector< T > buffer
 Where the elements are stored.
 

Detailed Description

template<typename T>
class Yielder< T >

Abstract class representing a yielder. It is, an object which can be used to accumulate inputs until either a yield is explicitly deleted or the yield condition is triggered, probably after a push request.

Author
Alberto M. Esmoris Pena
Version
1.0
Template Parameters
TThe type of object handled by the yielder

Constructor & Destructor Documentation

◆ Yielder()

template<typename T >
Yielder< T >::Yielder ( std::size_t  bufferSize = 256)
inline

Default constructor for the abstract yielder.

See also
Yielder::bufferSize

Member Function Documentation

◆ copyBuffer()

template<typename T >
virtual vector<T> Yielder< T >::copyBuffer ( ) const
inlinevirtual

Make a copy of the buffer with its current state.

Returns
The copy of the buffer at its current state

◆ getBufferSize()

template<typename T >
size_t Yielder< T >::getBufferSize ( ) const
inline

Obtain the current buffer size of the yielder.

Returns
The buffer size of the yielder

◆ push()

template<typename T >
void Yielder< T >::push ( T const &  elem)
inline

Push the element into the yielder. The element could be simply accumulated or either it could be directly written to file depending on yielder status at push time.

Parameters
elemElement to be pushed into the yielder

◆ setBufferSize()

template<typename T >
void Yielder< T >::setBufferSize ( size_t const  bufferSize)
inline

Set the buffer size of the yielder, effectively.

Parameters
bufferSizeNew buffer size for the yielder

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