Reader interface to an MDF file.
More...
#include "mdf/mdfreader.h"
|
| MdfReader (const std::string &filename) |
|
virtual | ~MdfReader () |
| Destructor that close any open file and destructs.
|
|
| MdfReader (const MdfReader &)=delete |
|
| MdfReader (MdfReader &&)=delete |
|
MdfReader & | operator= (const MdfReader &)=delete |
|
MdfReader & | operator= (MdfReader &&)=delete |
|
int64_t | Index () const |
|
void | Index (int64_t index) |
|
bool | IsOk () const |
|
bool | IsFinalized () const |
| Return true if the file is marked as finalized.
|
|
const MdfFile * | GetFile () const |
|
const IHeader * | GetHeader () const |
| Returns the header (HD) block.
|
|
IDataGroup * | GetDataGroup (size_t order) const |
| Returns the data group (DG) block.
|
|
std::string | ShortName () const |
| Returns the file name without paths.
|
|
bool | Open () |
| Opens the file stream for reading.
|
|
void | Close () |
| Closes the file stream.
|
|
bool | ReadHeader () |
| Reads the ID and the HD block.
|
|
bool | ReadMeasurementInfo () |
| Reads everything but not CG and raw data.
|
|
bool | ReadEverythingButData () |
| Reads all blocks but not raw data.
|
|
bool | ExportAttachmentData (const IAttachment &attachment, const std::string &dest_file) |
| Export the attachment data to a detination file.
|
|
bool | ReadData (IDataGroup &data_group) |
| Reads all sample, sample reduction and signal data into memory.
|
|
bool | ReadPartialData (IDataGroup &data_group, size_t min_sample, size_t max_sample) |
| Reads a range of samples.
|
|
bool | ReadSrData (ISampleReduction &sr_group) |
| Reads in data bytes to a sample reduction (SR) block.
|
|
bool | ReadVlsdData (IDataGroup &data_group, IChannel &vlsd_channel, const std::vector< uint64_t > &offset_list, std::function< void(uint64_t, const std::vector< uint8_t > &)> &callback) |
| Read in partial variable length data with an offset list.
|
|
This is the main interface when reading MDF3 and MDF4 files.
◆ MdfReader()
mdf::MdfReader::MdfReader |
( |
const std::string & | filename | ) |
|
|
explicit |
Constructor that opens the file and read ID and HD block.
◆ GetFile()
const MdfFile * mdf::MdfReader::GetFile |
( |
| ) |
const |
|
inlinenodiscard |
Returns a pointer to the MDF file. This file holds references to the MDF blocks.
- Returns
- Pointer to the MDF file object. Note it may return a null pointer.
◆ Index() [1/2]
int64_t mdf::MdfReader::Index |
( |
| ) |
const |
|
inlinenodiscard |
Unique index for this reader. This index is typically used when fetching files from a database. The index itself is not used by the reader.
- Returns
- An unique index.
◆ Index() [2/2]
void mdf::MdfReader::Index |
( |
int64_t | index | ) |
|
|
inline |
Sets a unique index to this reader or actually its file. This index is typically retrieved from a database and makes finding files much easier than comparing paths.
- Parameters
-
◆ IsFinalized()
bool mdf::MdfReader::IsFinalized |
( |
| ) |
const |
|
nodiscard |
This function returns true if the file is marked as finalized. This is done by checking the ID block.
- Returns
- True if the file is marked as finalized.
◆ IsOk()
bool mdf::MdfReader::IsOk |
( |
| ) |
const |
|
inlinenodiscard |
Checks if the file was read without errors.
- Returns
- True if the file was read OK.
◆ ReadData()
bool mdf::MdfReader::ReadData |
( |
IDataGroup & | data_group | ) |
|
Reads in all data bytes that belongs to a data group (DG). The function reads in sample data (DT..) blocks, sample reduction (RD/RV/RI) blocks and signal data (SD) blocks. Note that this function may consume a lot of memory, so remember to call the IDataGroup::ClearData() function when data not are needed anymore.
The attached observers also consumes memory, so remember to delete them when they are no more needed.
- Parameters
-
data_group | Reference to the data group (DG) object. |
- Returns
- True if the read was successful.
◆ ReadPartialData()
bool mdf::MdfReader::ReadPartialData |
( |
IDataGroup & | data_group, |
|
|
size_t | min_sample, |
|
|
size_t | max_sample ) |
Reads in a range of samples a data group (DG). The function reads in sample data (DT..) blocks, sample reduction (RD/RV/RI) blocks and signal data (SD) blocks. The function is faster that reading all data bytes, skipping records it doesn't need to read.
Note that this function still may consume a lot of memory, so remember to call the IDataGroup::ClearData() function when data not are needed anymore.
The attached observers also consumes memory, so remember to delete them when they are no more needed.
- Parameters
-
data_group | Reference to the data group (DG) object. |
min_sample | First sample index to read. |
max_sample | Last sample index to read. |
- Returns
- True if the read was successful.
◆ ReadSrData()
To minimÃze the use of time and memory, this function reads in data for one sample reduction (SR) block. The function is much faster than to read in all data bytes for a data group (DG).
- Parameters
-
sr_group | Reference to a sample reduction (SR) block. |
- Returns
- True if the read was successful.
◆ ReadVlsdData()
bool mdf::MdfReader::ReadVlsdData |
( |
IDataGroup & | data_group, |
|
|
IChannel & | vlsd_channel, |
|
|
const std::vector< uint64_t > & | offset_list, |
|
|
std::function< void(uint64_t, const std::vector< uint8_t > &)> & | callback ) |
This function reads in VLSD stored data according to an offset list. For smaller MDF files that fits in the primary memory, this function is not needed but sometimes the VLSD data sample holds a large amount of data bytes typical a video stream. These files tends to be huge so the application runs out of memory.
This function reads in VLSD stored data in smaller batcher. The application first reads in all offsets to the raw data. Using these offsets the application can read in typically one sample (offset) at a time. This tactic saves primary memory.
- Parameters
-
data_group | Data group to read VLSD data from |
vlsd_channel | Which channel that stores the VLSD data |
offset_list | List of offsets (samples) to read. |
callback | Callback function for each offset/sample data |
- Returns
- Returns true if the read was successful
The documentation for this class was generated from the following file: