ADTF File Library
Loading...
Searching...
No Matches
adtfdat_processing::SortingReader Class Referenceabstract

Proxy reader that reorders items within a sliding window to restore timestamp order. Only fixes out-of-order items. The logged file remains invalid in general. In contrast to 'sample_timestamp_sanitizer', which adjusts non-monotonic sample timestamps, this reader reorders the items but preserves the original sample data. Using the wrong reader may further corrupt the data.". More...

#include <sorting_reader.h>

Inheritance diagram for adtfdat_processing::SortingReader:
[legend]
Collaboration diagram for adtfdat_processing::SortingReader:
[legend]

Public Member Functions

void open (const std::vector< adtf_file::Stream > &streams, bool sample_timestamps, std::chrono::seconds sorting_window, bool trigger_for_each_sample)
 prepare the sorting algorithm.
 
adtf_file::FileItem getNextItem () final override
 
uint64_t getItemIndexForTimeStamp (std::chrono::nanoseconds time_stamp) override
 
uint64_t getItemIndexForStreamItemIndex (uint16_t stream_id, uint64_t stream_item_index) override
 
std::shared_ptr< const adtf_file::StreamTypegetStreamTypeBefore (uint64_t item_index, uint16_t stream_id) override
 
void seekTo (uint64_t item_index) override
 
virtual void open (const std::string &filename, std::shared_ptr< SampleFactory > sample_factory, std::shared_ptr< StreamTypeFactory > stream_type_factory)=0
 opens a file by the given filename. The given factories must be used to create samples and streamtypes for the getNextItem call
 
- Public Member Functions inherited from adtf_file::Reader
virtual std::string getReaderIdentifier () const =0
 Get the Reader Identifier of the Reader.
 
virtual void open (const std::string &filename, std::shared_ptr< SampleFactory > sample_factory, std::shared_ptr< StreamTypeFactory > stream_type_factory)=0
 opens a file by the given filename. The given factories must be used to create samples and streamtypes for the getNextItem call
 
virtual uint32_t getFileVersion () const
 
virtual std::string getDescription () const
 
virtual std::vector< ExtensiongetExtensions () const
 Get the Extensions if any.
 
virtual std::vector< StreamgetStreams () const
 Get the Streams.
 
virtual std::optional< uint64_t > getItemCount () const
 Get the Item Count. This gets the overall count of all items (samples, stream types and triggers) of all streams.
 
virtual std::optional< double > getProgress () const
 Get the Progress, a relative file position between 0.0 and 1.0.
 
- Public Member Functions inherited from adtf_file::Configurable
virtual ~Configurable ()=default
 DTOR.
 
virtual const ConfigurationgetConfiguration () const
 
virtual void setConfiguration (const Configuration &configuration)
 

Protected Member Functions

virtual adtf_file::FileItem getNextUnsortedItem ()=0
 
virtual uint64_t getUnsortedItemIndexForTimeStamp (std::chrono::nanoseconds time_stamp)
 
virtual std::shared_ptr< const adtf_file::StreamTypegetUnsortedStreamTypeBefore (uint64_t item_index, uint16_t stream_id)
 
virtual void unsortedSeekTo (uint64_t item_index)
 

Detailed Description

Proxy reader that reorders items within a sliding window to restore timestamp order. Only fixes out-of-order items. The logged file remains invalid in general. In contrast to 'sample_timestamp_sanitizer', which adjusts non-monotonic sample timestamps, this reader reorders the items but preserves the original sample data. Using the wrong reader may further corrupt the data.".

Member Function Documentation

◆ getItemIndexForStreamItemIndex()

uint64_t adtfdat_processing::SortingReader::getItemIndexForStreamItemIndex ( uint16_t stream_id,
uint64_t stream_item_index )
overridevirtual

Find the index of the given stream item.

Parameters
[in]stream_idThe stream id.
[in]stream_item_indexThe item index within the stream.
Returns
The item index.
Remarks
The SeekableReader class is an interface where implementation should at least throw following exceptions in case of error:
Exceptions
std::out_of_rangeif given item_index is out of range
std::out_of_rangeif given stream_id is out of range (must be at least 1)
std::runtime_errorif position was not found
anyother implementation dependent exceptions for the get call

Implements adtf_file::SeekableReader.

◆ getItemIndexForTimeStamp()

uint64_t adtfdat_processing::SortingReader::getItemIndexForTimeStamp ( std::chrono::nanoseconds time_stamp)
overridevirtual

Find the index of the first item that has a timestamp greator or equal to the one specified.

Parameters
[in]time_stampThe timestamp.
Returns
The item index.
Remarks
The SeekableReader class is an interface where implementation should at least throw following exceptions in case of error:
Exceptions
std::runtime_errorif position was not found
anyother implementation dependent exceptions for the get call

Implements adtf_file::SeekableReader.

◆ getNextItem()

adtf_file::FileItem adtfdat_processing::SortingReader::getNextItem ( )
finaloverridevirtual

Returns the next item of the file and increase the item index to the next one. These can be samples, streamtypes or trigger.

Returns
The next item.
Remarks
Use the given factories from the open call to create sample and streamtypes.
The Reader class is an interface where implementation should at least throw following exceptions in case of error:
Exceptions
exceptions::EndOfFileif end of file was reached
std::exceptionbased exception for any other implementation dependent case to identify error on getNextItem call

Implements adtf_file::Reader.

◆ getNextUnsortedItem()

virtual adtf_file::FileItem adtfdat_processing::SortingReader::getNextUnsortedItem ( )
protectedpure virtual

Returns the next item of the file and increase the item index to the next one. These can be samples, streamtypes or trigger.

Returns
The next item.
Exceptions
exceptions::EndOfFileif end of file was reached
std::exceptionbased exception for any other implementation dependent case to identify error on getNextUnsortedItem call

Implemented in adtfdat_processing::SortingProxyReader.

◆ getStreamTypeBefore()

std::shared_ptr< const adtf_file::StreamType > adtfdat_processing::SortingReader::getStreamTypeBefore ( uint64_t item_index,
uint16_t stream_id )
overridevirtual

Returns the stream type that is valid

Parameters
[in]item_indexThe global index before which the stream type should be retrieved.
[in]stream_idThe stream id for which the stream type should be retrieved.
Returns
A shared pointer to the stream type.
Remarks
The SeekableReader class is an interface where implementation should at least throw following exceptions in case of error:
Exceptions
std::out_of_rangeif given item_index is out of range
std::out_of_rangeif given stream_id is out of range (must be at least 1)
anyother implementation dependent exceptions for the get call

Implements adtf_file::SeekableReader.

◆ open() [1/2]

virtual void adtf_file::Reader::open ( const std::string & filename,
std::shared_ptr< SampleFactory > sample_factory,
std::shared_ptr< StreamTypeFactory > stream_type_factory )

opens a file by the given filename. The given factories must be used to create samples and streamtypes for the getNextItem call

Parameters
filenameThe file to open
sample_factoryThe sample factory to create samples for the getNextItem call.
stream_type_factoryThe stream type factory to create streamtype for the getNextItem call.
Remarks
The Reader class is an interface where implementation should at least throw following exceptions in case of error:
Exceptions
std::exceptionbased exception for any other implementation dependent case to identify error on open call

◆ open() [2/2]

void adtfdat_processing::SortingReader::open ( const std::vector< adtf_file::Stream > & streams,
bool sample_timestamps,
std::chrono::seconds sorting_window,
bool trigger_for_each_sample )

prepare the sorting algorithm.

Parameters
streamsthe list of streams
sample_timestampsuse sample timestamp or chunk timestamp
sorting_windowdefinition for the timing window in seconds
trigger_for_each_samplewhether or not to create a trigger for each sample
Exceptions
std::exceptionbased exception for any other implementation dependent case to identify error on open call

◆ seekTo()

void adtfdat_processing::SortingReader::seekTo ( uint64_t item_index)
overridevirtual

Seek to the given index, such that getNextItem() will return the item corresponding to the index on the next call.

Parameters
[in]item_indexThe index to seek to.
Remarks
The SeekableReader class is an interface where implementation should at least throw following exceptions in case of error:
Exceptions
std::out_of_rangeif given item_index is out of range (check for getItemCount())
anyother implementation dependent exceptions for the seek call

Implements adtf_file::SeekableReader.


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