adtf_file_library  0.13.2
Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
ifhd::v201_v301::IndexedFileReader Class Reference

#include <indexedfilereader_v201_v301.h>

Inheritance diagram for ifhd::v201_v301::IndexedFileReader:
[legend]
Collaboration diagram for ifhd::v201_v301::IndexedFileReader:
[legend]

Public Member Functions

 IndexedFileReader ()
 
 ~IndexedFileReader ()
 
virtual void open (const a_util::filesystem::Path &filename, const std::optional< size_t > &read_cache_size=IndexedFileReader::read_cache_default, uint32_t flags=0)
 
virtual void open (const std::shared_ptr< SourceFile > &source_file, uint32_t flags=0)
 
virtual void close ()
 
void reset ()
 
int64_t getCurrentPos (TimeFormat time_format) const
 
int64_t setCurrentPos (int64_t position, TimeFormat time_format)
 
int64_t seek (uint16_t stream_id, int64_t position, TimeFormat time_format, uint32_t flags=0)
 
void queryChunkInfo (ChunkHeader **chunk_header)
 
void readChunk (void **data, uint32_t flags=0)
 
void skipChunk ()
 
void readNextChunk (ChunkHeader **chunk_header, void **data, uint32_t flags=0, uint32_t stream_id=0)
 
void skipChunkInfo ()
 
void readNextChunkInfo (ChunkHeader **chunk_header)
 
int64_t getFilePos () const
 
int64_t getChunkCount () const
 
timestamp_t getDuration () const
 
uint32_t getVersionId () const
 
timestamp_t getTimeOffset () const
 
int64_t getStreamTableIndexCount (uint16_t stream_id) const
 
int64_t getStreamIndexCount (uint16_t stream_id) const
 
void getAdditionalStreamInfo (uint16_t stream_id, const void **info_data, size_t *info_size) const
 
std::string getStreamName (uint16_t stream_id) const
 
bool streamExists (uint16_t stream_id) const
 Checks if stream with given id exists. More...
 
timestamp_t getFirstTime (uint16_t stream_id) const
 
timestamp_t getLastTime (uint16_t stream_id) const
 
size_t getExtensionCount () const
 
bool findExtension (const char *identifier, FileExtension **extension_info, void **data) const
 
void getExtension (size_t index, FileExtension **extension_info, void **data) const
 
int64_t lookupChunkRef (uint16_t stream_id, int64_t position, TimeFormat time_format) const
 
bool getLastChunkWithFlagBefore (uint64_t chunk_index, uint16_t stream_id, uint16_t flag, ChunkHeader &header, std::vector< uint8_t > &data)
 
- Public Member Functions inherited from ifhd::v201_v301::IndexedFile
 IndexedFile ()
 
virtual ~IndexedFile ()
 
virtual std::set< uint32_t > getSupportedVersions () const
 Get a set of all supported versions. More...
 
void setDescription (const std::string &description)
 
std::string getDescription () const
 
std::string getGUID () const
 
a_util::datetime::DateTime getDateTime () const
 
uint8_t getByteOrder () const
 
size_t getExtensionCount () const
 
bool findExtension (const char *identifier, FileExtension **extension_info, void **data) const
 
void getExtension (size_t index, FileExtension **extension_info, void **data) const
 
void appendExtension (const char *identifier, const void *data, size_t data_size, uint32_t type_id=0, uint32_t file_version_id=0, uint16_t stream_id=0, uint32_t user_id=0)
 
void appendExtension (const void *data, const FileExtension *extension_info)
 
void freeExtensions ()
 
void getHeaderRef (FileHeader **file_header) const
 

Static Public Attributes

static constexpr auto read_cache_default = std::nullopt
 
static constexpr size_t read_cache_deactivated = 0
 

Protected Member Functions

virtual void initialize ()
 
void readFileHeader ()
 
void readFileHeaderExt ()
 
void readCurrentChunkHeader ()
 
void readCurrentChunkData (void *buffer)
 
void setEOF ()
 
void readDataBlock (void *buffer, size_t buffer_size)
 
void checkFilePtr ()
 
void allocReadBuffers ()
 
void freeReadBuffers ()
 
- Protected Member Functions inherited from ifhd::v201_v301::IndexedFile
void setDateTime (const a_util::datetime::DateTime &date_time)
 
void allocBuffer (uint64_t size)
 
void freeBuffer ()
 
void allocHeader ()
 
void freeHeader ()
 
void allocExtensionPage (utils5ext::FileSize size, void **data) const
 
void setGUID ()
 
void generateNewGUID (std::string &generated_guid)
 
void allocCache (int64_t size)
 
void freeCache ()
 
void * getCacheAddr () const
 
void * internalMalloc (size_t size) const
 
void internalFree (void *memory) const
 

Additional Inherited Members

- Protected Types inherited from ifhd::v201_v301::IndexedFile
typedef std::list< FileExtensionStruct * > FileExtensionList
 own type definition for a better work with file extension lists
 
- Protected Attributes inherited from ifhd::v201_v301::IndexedFile
utils5ext::File _file
 the open file
 
FilePos _file_pos
 current filepos
 
uint8_t * _buffer
 internal Buffer
 
int64_t _buffer_size
 internal Buffer size
 
FileHeader_file_header
 current file header
 
bool _write_guid
 protection for writing GUID
 
FileExtensionList _extensions
 list with all extensions
 
void * _cache
 cache data area
 
uint64_t _cache_size
 size of cache
 
bool _write_mode
 For internal use only (will be moved to a private implementation).
 
- Static Protected Attributes inherited from ifhd::v201_v301::IndexedFile
static const uint8_t byte_order
 current value of platform ByteOrder ( More...
 
static int64_t default_block_size
 Default block size in bytes.
 
static int64_t default_cache_size
 Default cache size in bytes.
 

Detailed Description

Class for reading indexed files.

Constructor & Destructor Documentation

◆ IndexedFileReader()

ifhd::v201_v301::IndexedFileReader::IndexedFileReader ( )

Default constructor.

◆ ~IndexedFileReader()

ifhd::v201_v301::IndexedFileReader::~IndexedFileReader ( )

Destructor.

Member Function Documentation

◆ allocReadBuffers()

void ifhd::v201_v301::IndexedFileReader::allocReadBuffers ( )
protected

Initializes the internal read buffers.

◆ checkFilePtr()

void ifhd::v201_v301::IndexedFileReader::checkFilePtr ( )
protected

Checks whether the current position in the file is valid.

Exceptions
std::runtime_error

◆ close()

virtual void ifhd::v201_v301::IndexedFileReader::close ( )
virtual

This function closes all.

Reimplemented from ifhd::v201_v301::IndexedFile.

◆ findExtension()

bool ifhd::v201_v301::IndexedFileReader::findExtension ( const char *  identifier,
FileExtension **  extension_info,
void **  data 
) const

This function gets the extension data if exist.

Parameters
[in]identifierthe extension name
[out]extension_infothe FileExtension struct
[out]datathe extension data
Return values
truethe extension with identifier was found
falsethe extension with identifier was not found
Remarks
implemented rt safe

◆ freeReadBuffers()

void ifhd::v201_v301::IndexedFileReader::freeReadBuffers ( )
protected

Releases the internal read buffers.

◆ getAdditionalStreamInfo()

void ifhd::v201_v301::IndexedFileReader::getAdditionalStreamInfo ( uint16_t  stream_id,
const void **  info_data,
size_t *  info_size 
) const

This function gets the additional stream information data of the given stream.

Parameters
stream_id[in] the stream Id
info_data[out] the tSampleStreamHeader data
info_size[out] the size of the returned data
Remarks
implemented rt safe

◆ getChunkCount()

int64_t ifhd::v201_v301::IndexedFileReader::getChunkCount ( ) const

This function returns the number of chunks of the current file.

Returns
int64_t
Remarks
implemented rt safe

◆ getCurrentPos()

int64_t ifhd::v201_v301::IndexedFileReader::getCurrentPos ( TimeFormat  time_format) const

This function returns the current file position (Index or TimeStamp)

Parameters
time_format[in] a format value (tTimeFormat)
Returns
int64_t -> the current file position (Index or TimeStamp)
Remarks
implemented rt safe

◆ getDuration()

timestamp_t ifhd::v201_v301::IndexedFileReader::getDuration ( ) const

This function returns the duration of the current file [microsec].

Returns
timestamp_t
Remarks
implemented rt safe

◆ getExtension()

void ifhd::v201_v301::IndexedFileReader::getExtension ( size_t  index,
FileExtension **  extension_info,
void **  data 
) const

This function gets the extension data.

Parameters
index[in] the extension index
extension_info[out] the FileExtension struct
data[out] the extension data
Remarks
implemented rt safe

◆ getExtensionCount()

size_t ifhd::v201_v301::IndexedFileReader::getExtensionCount ( ) const

Get the amount of extensions in the file.

Returns
The amount of extensions in the file.
Remarks
implemented rt safe

◆ getFilePos()

int64_t ifhd::v201_v301::IndexedFileReader::getFilePos ( ) const

This function returns the current chunk index.

Returns
int64_t

◆ getFirstTime()

timestamp_t ifhd::v201_v301::IndexedFileReader::getFirstTime ( uint16_t  stream_id) const

This function gets the first time stamp of the given stream.

Parameters
stream_id[in] the stream Id
Returns
The first time appears in file for the stream.
Remarks
implemented rt safe

◆ getLastChunkWithFlagBefore()

bool ifhd::v201_v301::IndexedFileReader::getLastChunkWithFlagBefore ( uint64_t  chunk_index,
uint16_t  stream_id,
uint16_t  flag,
ChunkHeader header,
std::vector< uint8_t > &  data 
)

Returns the last chunk of a stream before the given chunk index, that has a given flag

Remarks
Mind that this function only searches within the index! It will return the last item that has an index entry before the given chunk index.
Parameters
chunk_index[in] the chunk index
stream_id[in] the stream Id
flag[in] the flag
header[out] the header of the found chunk
data[out] the data of the found chunk
Returns
true if a chunk with the requested flasg was found, false otherwise.

◆ getLastTime()

timestamp_t ifhd::v201_v301::IndexedFileReader::getLastTime ( uint16_t  stream_id) const

This function gets the last time stamp of the given stream.

Parameters
stream_id[in] the stream Id
Returns
The last time in file for the stream.
Remarks
implemented rt safe

◆ getStreamIndexCount()

int64_t ifhd::v201_v301::IndexedFileReader::getStreamIndexCount ( uint16_t  stream_id) const

This function gets the number of chunks of the given stream.

Parameters
stream_id[in] the stream Id
Returns
int64_t
Remarks
implemented rt safe

◆ getStreamName()

std::string ifhd::v201_v301::IndexedFileReader::getStreamName ( uint16_t  stream_id) const

This function gets the stream name which is set.

Parameters
stream_id[in] the stream Id
Returns
The stream name for the given stream id if set. Returns nullptr if stream id is invalid.
Remarks
implemented rt safe

◆ getStreamTableIndexCount()

int64_t ifhd::v201_v301::IndexedFileReader::getStreamTableIndexCount ( uint16_t  stream_id) const

This function gets the number of indices of the given stream.

Parameters
stream_id[in] the stream Id
Returns
int64_t
Remarks
implemented rt safe

◆ getTimeOffset()

timestamp_t ifhd::v201_v301::IndexedFileReader::getTimeOffset ( ) const

This function returns the Time Zero Point Offset every Time is referring to.

Returns
timestamp_t the time offset of point zero
Remarks
implemented rt safe

◆ getVersionId()

uint32_t ifhd::v201_v301::IndexedFileReader::getVersionId ( ) const

This function returns the Version Id of the current file.

Returns
uint32_t
Remarks
implemented rt safe

◆ initialize()

virtual void ifhd::v201_v301::IndexedFileReader::initialize ( )
protectedvirtual

Initializes the reader.

Reimplemented from ifhd::v201_v301::IndexedFile.

◆ lookupChunkRef()

int64_t ifhd::v201_v301::IndexedFileReader::lookupChunkRef ( uint16_t  stream_id,
int64_t  position,
TimeFormat  time_format 
) const

This function gets the chunk index of the given file position.

Parameters
stream_id[in] the stream Id
position[in] the file position
time_format[in] the format of position (tTimeFormat)
Returns
int64_t -> the chunk index
Remarks
implemented rt safe

◆ open() [1/2]

virtual void ifhd::v201_v301::IndexedFileReader::open ( const a_util::filesystem::Path &  filename,
const std::optional< size_t > &  read_cache_size = IndexedFileReader::read_cache_default,
uint32_t  flags = 0 
)
virtual

This function opens a file on a local filesystem for reading.

Parameters
[in]filenamethe file name to be opened
[in]read_cache_sizeread cache size in bytes;
[in]flagsthe OpenMode value
Exceptions
exceptions::ErrorFileAccessfor any failure to access the file
std::exception(exactly ddl::dd::Error from a_util) for ddl description dependend errors
std::runtime_errorfor file content and reading errors

◆ open() [2/2]

virtual void ifhd::v201_v301::IndexedFileReader::open ( const std::shared_ptr< SourceFile > &  source_file,
uint32_t  flags = 0 
)
virtual

This function opens a dat-file for reading.

Parameters
[in]source_filethe file to use as a source
[in]flagsthe OpenMode value
Exceptions
exceptions::ErrorFileAccessfor any failure to access the file
std::exception(exactly ddl::dd::Error from a_util) for ddl description dependend errors
std::runtime_errorfor file content and reading errors

◆ queryChunkInfo()

void ifhd::v201_v301::IndexedFileReader::queryChunkInfo ( ChunkHeader **  chunk_header)

This function returns the ChunkInfo of the current chunk.

Parameters
chunk_header[out] the current chunk info

◆ readChunk()

void ifhd::v201_v301::IndexedFileReader::readChunk ( void **  data,
uint32_t  flags = 0 
)

This function reads and returns the current Chunk and increments the current chunk index

Parameters
data[out] the current chunk data
flags[in] a tReadFlags the value

◆ readCurrentChunkData()

void ifhd::v201_v301::IndexedFileReader::readCurrentChunkData ( void *  buffer)
protected

Reads the data of the current chunk.

◆ readCurrentChunkHeader()

void ifhd::v201_v301::IndexedFileReader::readCurrentChunkHeader ( )
protected

Reads the next chunk header

◆ readDataBlock()

void ifhd::v201_v301::IndexedFileReader::readDataBlock ( void *  buffer,
size_t  buffer_size 
)
protected

Reads a raw data block from the file.

Parameters
[out]bufferHere the data will be stored.
[in]buffer_sizeThe amount of bytes to read.

◆ readFileHeader()

void ifhd::v201_v301::IndexedFileReader::readFileHeader ( )
protected

Reads and initializes the Header struct

◆ readFileHeaderExt()

void ifhd::v201_v301::IndexedFileReader::readFileHeaderExt ( )
protected

Reads and initializes the ExtendedHeader

◆ readNextChunk()

void ifhd::v201_v301::IndexedFileReader::readNextChunk ( ChunkHeader **  chunk_header,
void **  data,
uint32_t  flags = 0,
uint32_t  stream_id = 0 
)

This function reads and returns the current Chunk and ChunkInfo struct and increments the current chunk index. If a stream Id is specified, the next Chunk and ChunkInfo struct of this stream will be returned.

Parameters
chunk_header[out] the current chunk info
data[out] the current chunk data
flags[in] a tReadFlagsthe value
stream_id[in] the stream Id

◆ readNextChunkInfo()

void ifhd::v201_v301::IndexedFileReader::readNextChunkInfo ( ChunkHeader **  chunk_header)

This function gets the next chunk information.

Parameters
chunk_header[out] the ChunkHeader data

◆ reset()

void ifhd::v201_v301::IndexedFileReader::reset ( )

This function resets the file to the beginning of data.

◆ seek()

int64_t ifhd::v201_v301::IndexedFileReader::seek ( uint16_t  stream_id,
int64_t  position,
TimeFormat  time_format,
uint32_t  flags = 0 
)

This function sets the new file position and returns the new chunk index or -1 in case the chunk can not be found (for example stream Id is invalid or file position is out of range).

Parameters
stream_id[in] the stream Id
position[in] the new file position
time_format[in] the format of position (tTimeFormat)
flags[in] a SeekFlags value
Returns
int64_t -> the current chunk index or -1

◆ setCurrentPos()

int64_t ifhd::v201_v301::IndexedFileReader::setCurrentPos ( int64_t  position,
TimeFormat  time_format 
)

This function sets the file position.

Parameters
position[in] the new file position
time_format[in] the format of position (tTimeFormat)
Returns
int64_t -> the current chunk index

◆ setEOF()

void ifhd::v201_v301::IndexedFileReader::setEOF ( )
protected

Set the end of file indication.

Remarks
implemented rt safe

◆ skipChunk()

void ifhd::v201_v301::IndexedFileReader::skipChunk ( )

This function skips the next Chunk by incrementing the current chunk index and setting the new FilePosition.

◆ skipChunkInfo()

void ifhd::v201_v301::IndexedFileReader::skipChunkInfo ( )

This function increments the current chunk index.

◆ streamExists()

bool ifhd::v201_v301::IndexedFileReader::streamExists ( uint16_t  stream_id) const

Checks if stream with given id exists.

Parameters
stream_idthe stream id to check for
Return values
trueexists
falsedoes not exist

Member Data Documentation

◆ read_cache_deactivated

constexpr size_t ifhd::v201_v301::IndexedFileReader::read_cache_deactivated = 0
staticconstexpr

Caching is deactivated, for use in open.

◆ read_cache_default

constexpr auto ifhd::v201_v301::IndexedFileReader::read_cache_default = std::nullopt
staticconstexpr

Caching is defaulted, for use in open.


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

Copyright © CARIAD SE.
Generated on Mon Jun 10 2024 by doxygen 1.9.1
GIT Commit Hash: eb3af397a6b49ad6fcad9a60d8277d909b458b48