adtf_file_library  0.13.1
Public Member Functions | Static Public Attributes | List of all members
adtf_file::ADTFDatFileReader Class Reference

ADTF File Reader to deserialze and read the content of a ADTF DAT File. More...

#include <adtf_file_reader.h>

Inheritance diagram for adtf_file::ADTFDatFileReader:
[legend]
Collaboration diagram for adtf_file::ADTFDatFileReader:
[legend]

Public Member Functions

 ADTFDatFileReader ()
 
 ADTFDatFileReader (std::optional< StreamTypeDeserializers > type_factories, std::optional< SampleDeserializerFactories > sample_deserializer_factories)
 CTOR for a new Reader. More...
 
 ADTFDatFileReader (const ADTFDatFileReader &)=delete
 
 ADTFDatFileReader (ADTFDatFileReader &&)=default
 Move CTOR.
 
std::string getReaderIdentifier () const override
 Get the Reader Identifier of the Reader. More...
 
void open (const std::string &filename, std::shared_ptr< SampleFactory > sample_factory, std::shared_ptr< StreamTypeFactory > stream_type_factory) override
 CTOR for a new Reader. More...
 
void open (const std::string &filename)
 a file and uses default sample and stream type factories. More...
 
FileItem getNextItem () override
 
uint32_t getFileVersion () const override
 
std::string getDescription () const override
 
std::vector< ExtensiongetExtensions () const override
 Get the Extensions if any. More...
 
std::vector< StreamgetStreams () const override
 Get the Streams. More...
 
std::optional< uint64_t > getItemCount () const override
 Get the Item Count. This gets the overall count of all items (samples, stream types and triggers) of all streams. More...
 
std::optional< double > getProgress () const override
 Get the Progress, a relative file position between 0.0 and 1.0. More...
 
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 StreamTypegetStreamTypeBefore (uint64_t item_index, uint16_t stream_id) override
 
void seekTo (uint64_t item_index) override
 
int64_t getNextItemIndex () const
 
a_util::datetime::DateTime getDateTime () const
 Get the File Date Time of creating the adtfdat file from fileheader. More...
 
std::chrono::nanoseconds getFirstTime () const
 Get the timestamp of the very first file item. More...
 
std::chrono::nanoseconds getLastTime () const
 Get the timestamp of the very last file item. More...
 
- Public Member Functions inherited from adtf_file::Configurable
virtual ~Configurable ()=default
 DTOR.
 
virtual const ConfigurationgetConfiguration () const
 
virtual void setConfiguration (const Configuration &configuration)
 

Static Public Attributes

static constexpr int64_t read_cache_default = -1
 
static constexpr int64_t read_cache_deactivated = 0
 

Detailed Description

ADTF File Reader to deserialze and read the content of a ADTF DAT File.

Remarks
The reader supports SeekableReader since "adtfdat" is a seekable file format.

Constructor & Destructor Documentation

◆ ADTFDatFileReader() [1/2]

adtf_file::ADTFDatFileReader::ADTFDatFileReader ( )

Constructor that uses the sample and stream type factories from the object registry.

◆ ADTFDatFileReader() [2/2]

adtf_file::ADTFDatFileReader::ADTFDatFileReader ( std::optional< StreamTypeDeserializers type_factories,
std::optional< SampleDeserializerFactories sample_deserializer_factories 
)

CTOR for a new Reader.

Parameters
type_factoriesThe deserializer factorys for stream types. If not specified, the factories will be retrieved from the object registry.
sample_deserializer_factoriesThe deserializer factorys for samples. If not specified, the factories will be retrieved from the object registry.

Member Function Documentation

◆ getDateTime()

a_util::datetime::DateTime adtf_file::ADTFDatFileReader::getDateTime ( ) const

Get the File Date Time of creating the adtfdat file from fileheader.

Returns
a_util::datetime::DateTime

◆ getDescription()

std::string adtf_file::ADTFDatFileReader::getDescription ( ) const
overridevirtual
Returns
A descriptive text for the opened file.

Reimplemented from adtf_file::Reader.

◆ getExtensions()

std::vector<Extension> adtf_file::ADTFDatFileReader::getExtensions ( ) const
overridevirtual

Get the Extensions if any.

Returns
std::vector<Extension> A vector of all available extensions.

Reimplemented from adtf_file::Reader.

◆ getFileVersion()

uint32_t adtf_file::ADTFDatFileReader::getFileVersion ( ) const
overridevirtual

The file version with respect to ADTF DAT Format. When implementing a reader yourself

  • use ifhd::v201_v301::version_id if you do not explicitly create trigger items.
  • use ifhd::v500::version_id otherwise.
    Returns
    the file format version.

Reimplemented from adtf_file::Reader.

◆ getFirstTime()

std::chrono::nanoseconds adtf_file::ADTFDatFileReader::getFirstTime ( ) const

Get the timestamp of the very first file item.

Returns
std::chrono::nanoseconds

◆ getItemCount()

std::optional<uint64_t> adtf_file::ADTFDatFileReader::getItemCount ( ) const
overridevirtual

Get the Item Count. This gets the overall count of all items (samples, stream types and triggers) of all streams.

Remarks
if it is not possible to retrieve the item count, return std::nullopt instead.
Returns
std::optional<uint64_t>

Reimplemented from adtf_file::Reader.

◆ getItemIndexForStreamItemIndex()

uint64_t adtf_file::ADTFDatFileReader::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 adtf_file::ADTFDatFileReader::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.

◆ getLastTime()

std::chrono::nanoseconds adtf_file::ADTFDatFileReader::getLastTime ( ) const

Get the timestamp of the very last file item.

Returns
std::chrono::nanoseconds

◆ getNextItem()

FileItem adtf_file::ADTFDatFileReader::getNextItem ( )
overridevirtual

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.

◆ getNextItemIndex()

int64_t adtf_file::ADTFDatFileReader::getNextItemIndex ( ) const
Returns
the index of the next item, or -1 if the file is empty.

◆ getProgress()

std::optional<double> adtf_file::ADTFDatFileReader::getProgress ( ) const
overridevirtual

Get the Progress, a relative file position between 0.0 and 1.0.

Returns
std::optional<double> The relative value between 0.0 and 1.0 where internal file position is.

Reimplemented from adtf_file::Reader.

◆ getReaderIdentifier()

std::string adtf_file::ADTFDatFileReader::getReaderIdentifier ( ) const
inlineoverridevirtual

Get the Reader Identifier of the Reader.

Returns
the reader identifier

Implements adtf_file::Reader.

◆ getStreams()

std::vector<Stream> adtf_file::ADTFDatFileReader::getStreams ( ) const
overridevirtual

Get the Streams.

Returns
std::vector<Stream> A vector of all available streams.

Reimplemented from adtf_file::Reader.

◆ getStreamTypeBefore()

std::shared_ptr<const StreamType> adtf_file::ADTFDatFileReader::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]

void adtf_file::ADTFDatFileReader::open ( const std::string &  filename)

a file and uses default sample and stream type factories.

Parameters
filenameThe file path of the file to open.

◆ open() [2/2]

void adtf_file::ADTFDatFileReader::open ( const std::string &  filename,
std::shared_ptr< SampleFactory sample_factory,
std::shared_ptr< StreamTypeFactory stream_type_factory 
)
overridevirtual

CTOR for a new Reader.

Parameters
filenameThe file path of the file to open.
sample_factoryThe sample factory to create the deserialized samples.
stream_type_factoryThe stream type factory to create the deserialized stream types.
Remarks
The set configuration for open call is considered as follows:
  • "ignore_unsupported_streams" : Property to ignore unsupported streams with no error (true, false)
  • "read_cache_size" : Property to set readcache size in bytes for cached block reading to optimize read operations of file content
  • ... ADTFDatFileReader::read_cache_default use the default the cache size (currently 8kB)
  • ... ADTFDatFileReader::read_cache_deactivated deactivates the read cache
Exceptions
exceptions::ErrorFileAccess,std::exception(exactly ddl::dd::Error), std::runtime_error

Implements adtf_file::Reader.

◆ seekTo()

void adtf_file::ADTFDatFileReader::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 Reader::getItemCount)
anyother implementation dependent exceptions for the seek call

Implements adtf_file::SeekableReader.

Member Data Documentation

◆ read_cache_deactivated

constexpr int64_t adtf_file::ADTFDatFileReader::read_cache_deactivated = 0
staticconstexpr

Deactivates the read cache for property "read_cache_size"

◆ read_cache_default

constexpr int64_t adtf_file::ADTFDatFileReader::read_cache_default = -1
staticconstexpr

Uses the default size for the read cache for property "read_cache_size"


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

Copyright © CARIAD SE.
Generated on Fri Apr 19 2024 by doxygen 1.9.1
GIT Commit Hash: 82d535f82776c20b12fc60740bdae991b62444a7