adtf_file_library
0.13.2
|
#include <indexedfilereader_v201_v301.h>
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. | |
Class for reading indexed files.
ifhd::v201_v301::IndexedFileReader::IndexedFileReader | ( | ) |
Default constructor.
ifhd::v201_v301::IndexedFileReader::~IndexedFileReader | ( | ) |
Destructor.
|
protected |
Initializes the internal read buffers.
|
protected |
Checks whether the current position in the file is valid.
std::runtime_error |
|
virtual |
This function closes all.
Reimplemented from ifhd::v201_v301::IndexedFile.
bool ifhd::v201_v301::IndexedFileReader::findExtension | ( | const char * | identifier, |
FileExtension ** | extension_info, | ||
void ** | data | ||
) | const |
This function gets the extension data if exist.
[in] | identifier | the extension name |
[out] | extension_info | the FileExtension struct |
[out] | data | the extension data |
true | the extension with identifier was found |
false | the extension with identifier was not found |
|
protected |
Releases the internal read buffers.
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.
stream_id | [in] the stream Id |
info_data | [out] the tSampleStreamHeader data |
info_size | [out] the size of the returned data |
int64_t ifhd::v201_v301::IndexedFileReader::getChunkCount | ( | ) | const |
This function returns the number of chunks of the current file.
int64_t ifhd::v201_v301::IndexedFileReader::getCurrentPos | ( | TimeFormat | time_format | ) | const |
This function returns the current file position (Index or TimeStamp)
time_format | [in] a format value (tTimeFormat) |
timestamp_t ifhd::v201_v301::IndexedFileReader::getDuration | ( | ) | const |
This function returns the duration of the current file [microsec].
void ifhd::v201_v301::IndexedFileReader::getExtension | ( | size_t | index, |
FileExtension ** | extension_info, | ||
void ** | data | ||
) | const |
This function gets the extension data.
index | [in] the extension index |
extension_info | [out] the FileExtension struct |
data | [out] the extension data |
size_t ifhd::v201_v301::IndexedFileReader::getExtensionCount | ( | ) | const |
Get the amount of extensions in the file.
int64_t ifhd::v201_v301::IndexedFileReader::getFilePos | ( | ) | const |
This function returns the current chunk index.
timestamp_t ifhd::v201_v301::IndexedFileReader::getFirstTime | ( | uint16_t | stream_id | ) | const |
This function gets the first time stamp of the given stream.
stream_id | [in] the stream Id |
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
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 |
timestamp_t ifhd::v201_v301::IndexedFileReader::getLastTime | ( | uint16_t | stream_id | ) | const |
This function gets the last time stamp of the given stream.
stream_id | [in] the stream Id |
int64_t ifhd::v201_v301::IndexedFileReader::getStreamIndexCount | ( | uint16_t | stream_id | ) | const |
This function gets the number of chunks of the given stream.
stream_id | [in] the stream Id |
std::string ifhd::v201_v301::IndexedFileReader::getStreamName | ( | uint16_t | stream_id | ) | const |
This function gets the stream name which is set.
stream_id | [in] the stream Id |
int64_t ifhd::v201_v301::IndexedFileReader::getStreamTableIndexCount | ( | uint16_t | stream_id | ) | const |
This function gets the number of indices of the given stream.
stream_id | [in] the stream Id |
timestamp_t ifhd::v201_v301::IndexedFileReader::getTimeOffset | ( | ) | const |
This function returns the Time Zero Point Offset every Time is referring to.
uint32_t ifhd::v201_v301::IndexedFileReader::getVersionId | ( | ) | const |
This function returns the Version Id of the current file.
|
protectedvirtual |
Initializes the reader.
Reimplemented from ifhd::v201_v301::IndexedFile.
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.
stream_id | [in] the stream Id |
position | [in] the file position |
time_format | [in] the format of position (tTimeFormat) |
|
virtual |
This function opens a file on a local filesystem for reading.
[in] | filename | the file name to be opened |
[in] | read_cache_size | read cache size in bytes;
|
[in] | flags | the OpenMode value |
exceptions::ErrorFileAccess | for any failure to access the file |
std::exception | (exactly ddl::dd::Error from a_util) for ddl description dependend errors |
std::runtime_error | for file content and reading errors |
|
virtual |
This function opens a dat-file for reading.
[in] | source_file | the file to use as a source |
[in] | flags | the OpenMode value |
exceptions::ErrorFileAccess | for any failure to access the file |
std::exception | (exactly ddl::dd::Error from a_util) for ddl description dependend errors |
std::runtime_error | for file content and reading errors |
void ifhd::v201_v301::IndexedFileReader::queryChunkInfo | ( | ChunkHeader ** | chunk_header | ) |
This function returns the ChunkInfo of the current chunk.
chunk_header | [out] the current chunk info |
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
data | [out] the current chunk data |
flags | [in] a tReadFlags the value |
|
protected |
Reads the data of the current chunk.
|
protected |
Reads the next chunk header
|
protected |
Reads a raw data block from the file.
[out] | buffer | Here the data will be stored. |
[in] | buffer_size | The amount of bytes to read. |
|
protected |
Reads and initializes the Header struct
|
protected |
Reads and initializes the ExtendedHeader
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.
chunk_header | [out] the current chunk info |
data | [out] the current chunk data |
flags | [in] a tReadFlagsthe value |
stream_id | [in] the stream Id |
void ifhd::v201_v301::IndexedFileReader::readNextChunkInfo | ( | ChunkHeader ** | chunk_header | ) |
This function gets the next chunk information.
chunk_header | [out] the ChunkHeader data |
void ifhd::v201_v301::IndexedFileReader::reset | ( | ) |
This function resets the file to the beginning of data.
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).
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 |
int64_t ifhd::v201_v301::IndexedFileReader::setCurrentPos | ( | int64_t | position, |
TimeFormat | time_format | ||
) |
This function sets the file position.
position | [in] the new file position |
time_format | [in] the format of position (tTimeFormat) |
|
protected |
Set the end of file indication.
void ifhd::v201_v301::IndexedFileReader::skipChunk | ( | ) |
This function skips the next Chunk by incrementing the current chunk index and setting the new FilePosition.
void ifhd::v201_v301::IndexedFileReader::skipChunkInfo | ( | ) |
This function increments the current chunk index.
bool ifhd::v201_v301::IndexedFileReader::streamExists | ( | uint16_t | stream_id | ) | const |
Checks if stream with given id exists.
stream_id | the stream id to check for |
true | exists |
false | does not exist |
|
staticconstexpr |
Caching is deactivated, for use in open.
|
staticconstexpr |
Caching is defaulted, for use in open.