DynExp
Highly flexible laboratory automation for dynamically changing experiments.
DynExpInstr::CircularDataStreamBase Class Referenceabstract

Base class for all circular data streams based on Util::circularbuf. More...

+ Inheritance diagram for DynExpInstr::CircularDataStreamBase:

Public Member Functions

size_t GetNumRecentBasicSamples (size_t Count) const
 Determines the amount of samples which have been written to the stream after the last Count samples. This is useful if the caller just wants to obtain recent samples but not the entire stream. Then, the caller should remember the amount of samples it knows already and call ReadRecentBasicSamples() next. More...
 
BasicSampleListType ReadRecentBasicSamples (size_t Count)
 Reads the most recent samples from the stream skipping Count samples. Also refer to GetNumRecentBasicSamples(). More...
 
Override

Override by derived classes.

virtual size_t GetNumAvailableSamplesToReadTillEnd () const noexcept=0
 Determines the amount of samples which can be read from the stream's current get pointer position till the stream's end. More...
 
virtual size_t GetNumFreeSamplesToWrite () const noexcept=0
 Determines the amount of samples which can be written to the stream untill the stream's end is reached. More...
 
virtual std::streampos GetReadPosition () const noexcept=0
 Determines the current position of the stream's read (get) pointer in samples. More...
 
virtual std::streampos GetWritePosition () const noexcept=0
 Determines the current position of the stream's write (put) pointer in samples. More...
 
virtual bool SeekRel (signed long long OffsetInSamples, std::ios_base::seekdir SeekDir, std::ios_base::openmode Which=std::ios_base::in|std::ios_base::out)=0
 Moves the stream's read/write pointer(s) to a position relative to SeekDir. More...
 
virtual bool SeekAbs (unsigned long long PositionInSamples, std::ios_base::openmode Which=std::ios_base::in|std::ios_base::out)=0
 Moves the stream's read/write pointer(s) to an absolute position. More...
 
- Public Member Functions inherited from DynExpInstr::DataStreamBase
virtual ~DataStreamBase ()=default
 
bool CanRead () const
 Determines whether the stream contains at least one sample which can be read (i.e. GetStreamSizeRead() returns a value greater than 0). More...
 
void Clear ()
 Removes all samples from the stream's buffer. More...
 
void WriteBasicSample (const BasicSample &Sample)
 Writes a single basic sample to the stream. More...
 
BasicSample ReadBasicSample ()
 Reads a single basic sample from the stream. More...
 
void WriteBasicSamples (const BasicSampleListType &Samples)
 Writes a list of basic sample to the stream. More...
 
BasicSampleListType ReadBasicSamples (size_t Count)
 Reads a list of basic sample from the stream. More...
 
virtual bool IsBasicSampleConvertible () const noexcept
 Determines whether the data stream holds samples which are compatible to BasicSample. More...
 
virtual bool IsBasicSampleTimeUsed () const noexcept
 Determines whether the data stream holds basic samples (IsBasicSampleConvertible() returns true) which contain information in their BasicSample::Time fields. More...
 
virtual void SeekBeg (std::ios_base::openmode Which=std::ios_base::in|std::ios_base::out)=0
 Moves the read/write pointer to the first sample in the stream. More...
 
virtual void SeekEnd (std::ios_base::openmode Which=std::ios_base::in|std::ios_base::out)=0
 Moves the read pointer to the last sample in the stream and/or moves the write pointer after the last written sample in the stream. More...
 
virtual bool SeekEqual (std::ios_base::openmode Which=std::ios_base::in|std::ios_base::out)=0
 Moves the read/write pointer to the respective other one. More...
 
virtual size_t GetStreamSizeRead () const noexcept=0
 Determines the stream's read buffer size in samples. More...
 
virtual size_t GetStreamSizeWrite () const noexcept=0
 Determines the stream's write buffer size in samples. More...
 
virtual size_t GetNumSamplesWritten () const noexcept=0
 Determines the number of samples which have been written to the stream in total. Before overflowing, this function should keep continuing to return the largest possible value. More...
 
virtual void SetStreamSize (size_t BufferSizeInSamples)=0
 Sets the stream size in samples. More...
 

Protected Member Functions

 CircularDataStreamBase ()=default
 
virtual ~CircularDataStreamBase ()=default
 

Additional Inherited Members

- Public Types inherited from DynExpInstr::DataStreamBase
using BasicSampleListType = std::vector< BasicSample >
 Type of a list containing data stream samples of type BasicSample. More...
 

Detailed Description

Base class for all circular data streams based on Util::circularbuf.

Definition at line 269 of file DataStreamInstrument.h.

Constructor & Destructor Documentation

◆ CircularDataStreamBase()

DynExpInstr::CircularDataStreamBase::CircularDataStreamBase ( )
protecteddefault

◆ ~CircularDataStreamBase()

virtual DynExpInstr::CircularDataStreamBase::~CircularDataStreamBase ( )
protectedvirtualdefault

Member Function Documentation

◆ GetNumAvailableSamplesToReadTillEnd()

virtual size_t DynExpInstr::CircularDataStreamBase::GetNumAvailableSamplesToReadTillEnd ( ) const
pure virtualnoexcept

Determines the amount of samples which can be read from the stream's current get pointer position till the stream's end.

Returns
Returns the amount of available samples.

Implemented in DynExpInstr::CircularDataStream< SampleT, >, and DynExpInstr::CircularDataStream< BasicSample >.

◆ GetNumFreeSamplesToWrite()

virtual size_t DynExpInstr::CircularDataStreamBase::GetNumFreeSamplesToWrite ( ) const
pure virtualnoexcept

Determines the amount of samples which can be written to the stream untill the stream's end is reached.

Returns
Returns the amount of free samples.

Implemented in DynExpInstr::CircularDataStream< SampleT, >, and DynExpInstr::CircularDataStream< BasicSample >.

◆ GetNumRecentBasicSamples()

size_t DynExpInstr::CircularDataStreamBase::GetNumRecentBasicSamples ( size_t  Count) const

Determines the amount of samples which have been written to the stream after the last Count samples. This is useful if the caller just wants to obtain recent samples but not the entire stream. Then, the caller should remember the amount of samples it knows already and call ReadRecentBasicSamples() next.

Parameters
CountAmount of samples which are known by the caller.
Returns
Number of samples written to the stream recently.

Definition at line 48 of file DataStreamInstrument.cpp.

◆ GetReadPosition()

virtual std::streampos DynExpInstr::CircularDataStreamBase::GetReadPosition ( ) const
pure virtualnoexcept

Determines the current position of the stream's read (get) pointer in samples.

Returns
Returns the get pointer position in samples.

Implemented in DynExpInstr::CircularDataStream< SampleT, >, and DynExpInstr::CircularDataStream< BasicSample >.

◆ GetWritePosition()

virtual std::streampos DynExpInstr::CircularDataStreamBase::GetWritePosition ( ) const
pure virtualnoexcept

Determines the current position of the stream's write (put) pointer in samples.

Returns
Returns the put pointer position in samples.

Implemented in DynExpInstr::CircularDataStream< SampleT, >, and DynExpInstr::CircularDataStream< BasicSample >.

◆ ReadRecentBasicSamples()

DataStreamBase::BasicSampleListType DynExpInstr::CircularDataStreamBase::ReadRecentBasicSamples ( size_t  Count)

Reads the most recent samples from the stream skipping Count samples. Also refer to GetNumRecentBasicSamples().

Parameters
CountAmount of samples which are known by the caller.
Returns
Read samples

Definition at line 53 of file DataStreamInstrument.cpp.

◆ SeekAbs()

virtual bool DynExpInstr::CircularDataStreamBase::SeekAbs ( unsigned long long  PositionInSamples,
std::ios_base::openmode  Which = std::ios_base::in|std::ios_base::out 
)
pure virtual

Moves the stream's read/write pointer(s) to an absolute position.

Parameters
PositionInSamplesDestiny position
WhichCombination of flags std::ios_base::in (read) and std::ios_base::out (write) specifying the pointers to move.
Returns
Returns true in case of success, false otherwise.

Implemented in DynExpInstr::CircularDataStream< SampleT, >, and DynExpInstr::CircularDataStream< BasicSample >.

◆ SeekRel()

virtual bool DynExpInstr::CircularDataStreamBase::SeekRel ( signed long long  OffsetInSamples,
std::ios_base::seekdir  SeekDir,
std::ios_base::openmode  Which = std::ios_base::in|std::ios_base::out 
)
pure virtual

Moves the stream's read/write pointer(s) to a position relative to SeekDir.

Parameters
OffsetInSamplesDestiny position (relative to SeekDir)
SeekDirSet position relative to stream's beginning (std::ios_base::beg), its end (std::ios_base::end) or the current position (std::ios_base::cur).
WhichCombination of flags std::ios_base::in (read) and std::ios_base::out (write) specifying the pointers to move.
Returns
Returns true in case of success, false otherwise.

Implemented in DynExpInstr::CircularDataStream< SampleT, >, and DynExpInstr::CircularDataStream< BasicSample >.


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