MDF Lib 2.2
Interface against MDF 3/4 files
Loading...
Searching...
No Matches
mdf::MdfFile Class Referenceabstract

Implements an user interface against a MDF file. More...

#include <mdf/mdffile.h>

Public Member Functions

virtual ~MdfFile ()=default
 Default destructor.
 
virtual void Attachments (AttachmentList &dest) const =0
 Fetch a list of attachments.
 
virtual void DataGroups (DataGroupList &dest) const =0
 Fetch a list of all measurements.
 
virtual std::string Version () const =0
 Returns the file version.
 
int MainVersion () const
 Returns the main version of the file.
 
virtual void MinorVersion (int minor)=0
 Sets the minor version of the file.
 
int MinorVersion () const
 Returns the minor version number of the MDF file.
 
virtual void ProgramId (const std::string &program_id)=0
 Sets the program identifier int the ID block.
 
virtual std::string ProgramId () const =0
 Returns the program identifier.
 
virtual IHeaderHeader () const =0
 Returns the header object.
 
virtual IAttachmentCreateAttachment ()
 Creates a new attachment (AT block).
 
virtual IDataGroupCreateDataGroup ()=0
 Creates a new measurement (DG block).
 
virtual bool IsMdf4 () const =0
 Returns true if this is a MDF4 file.
 
virtual void ReadHeader (std::FILE *file)=0
 Reads the information about the file.
 
virtual void ReadMeasurementInfo (std::FILE *file)=0
 Reads the measurement information about the file.
 
virtual void ReadEverythingButData (std::FILE *file)=0
 Reads in all expect raw data from the file.
 
virtual bool Write (std::FILE *file)=0
 Saves all blocks onto the file.
 
const std::string & Name () const
 Display name of the file.
 
void Name (const std::string &name)
 Set the display name of the file.
 
const std::string & FileName () const
 Returns the full name of the file.
 
void FileName (const std::string &filename)
 Sets the file name.
 
virtual void IsFinalized (bool finalized, std::FILE *file, uint16_t standard_flags, uint16_t custom_flags)=0
 Sets the finalize state for the file.
 
virtual bool IsFinalized (uint16_t &standard_flags, uint16_t &custom_flags) const =0
 Returns true if the file is finalized.
 
virtual bool IsFinalizedDone () const
 
virtual IDataGroupFindParentDataGroup (const IChannel &channel) const =0
 Returns a parent data group (DG) depending a channel.
 

Protected Member Functions

 MdfFile ()=default
 Default constructor.
 

Detailed Description

Implements an interface against a MDF file object. Note that the object holds the file contents.

Member Function Documentation

◆ Attachments()

virtual void mdf::MdfFile::Attachments ( AttachmentList & dest) const
pure virtual

Fetches a list of file attachments. An attachment is a reference to an external or an embedded file. Note that MDF3 doesn't support attachments.

Parameters
destDestination list of attachments.

◆ CreateAttachment()

virtual IAttachment * mdf::MdfFile::CreateAttachment ( )
nodiscardvirtual

Creates a new attachment to the file also known as a AT block. An attachemnt is either a reference to an external file or an embedded file block).

Note that MDF3 doesn't support attachments.

Returns
Pointer to the new attachment.

◆ CreateDataGroup()

virtual IDataGroup * mdf::MdfFile::CreateDataGroup ( )
nodiscardpure virtual

Creates a new measurement block in the file also known as a DG block. A DG block defines one measurement with one or more sub-measurements (CG block). The new DG block is always put last in the file.

Returns
Pointer to the new measurement.

◆ DataGroups()

virtual void mdf::MdfFile::DataGroups ( DataGroupList & dest) const
pure virtual

Fetches a list aof all measurements (DG blocks) in the file.

Parameters
destDestination list of all measurements.

◆ FileName() [1/2]

const std::string & mdf::MdfFile::FileName ( ) const
inlinenodiscard

Returns the file name with path and extension.

Returns
File name with path and extension.

◆ FileName() [2/2]

void mdf::MdfFile::FileName ( const std::string & filename)

Sets the file name and the short name of the object.

Parameters
filenameFile name with path and extension.

◆ Header()

virtual IHeader * mdf::MdfFile::Header ( ) const
nodiscardpure virtual

Returns the header object. This object hold general information about the file and its contents. The header is the root of most information in the file.

Returns
Pointer to the header object.

◆ IsFinalizedDone()

virtual bool mdf::MdfFile::IsFinalizedDone ( ) const
nodiscardvirtual

Returns true if the finalize was done.

The function may be used to check on not finalized file to verify that the file have been finalized.

Returns
True if the finalization was successful.

◆ IsMdf4()

virtual bool mdf::MdfFile::IsMdf4 ( ) const
nodiscardpure virtual

Returns true if this is an MDF4 version fo the file.

Returns
True if MDF version 4.

◆ MainVersion()

int mdf::MdfFile::MainVersion ( ) const
nodiscard

Returns the main version (4.10 -> 4) of the file.

Returns
Returns the main version of the file (1..4).

◆ MinorVersion() [1/2]

int mdf::MdfFile::MinorVersion ( ) const
nodiscard

Returns the minor version of the MDF file. Note that it will return 1 for version 4.1 and 11 for version 4.11.

Returns
Minor version of the MDF file

◆ MinorVersion() [2/2]

virtual void mdf::MdfFile::MinorVersion ( int minor)
pure virtual

Sets the minor version of the file. This function is typical used when saving a MDF file.

Parameters
minorMinor version of the file.

◆ Name() [1/2]

const std::string & mdf::MdfFile::Name ( ) const
inlinenodiscard

Default set to the stem of the file. Not stored in the file itself. Only used for display purpose.

Returns
Short name of the file.

◆ Name() [2/2]

void mdf::MdfFile::Name ( const std::string & name)
inline

Sets the display name of the file. By default this is set to the file name without path and extension (stem).

Parameters
nameShort name of the file.

◆ ProgramId() [1/2]

virtual std::string mdf::MdfFile::ProgramId ( ) const
nodiscardpure virtual

Returns the program identifier i.e. software who created the file.

Returns
Program identifier (max 8 characters).

◆ ProgramId() [2/2]

virtual void mdf::MdfFile::ProgramId ( const std::string & program_id)
pure virtual

Sets the program identifier in the MDF file (ID block). Note that only 8 characters are stored.

Parameters
program_idProgram identifier.

◆ ReadEverythingButData()

virtual void mdf::MdfFile::ReadEverythingButData ( std::FILE * file)
pure virtual

Reads all information about the file but not raw data as sample data or embedded attachment data.

There is no need to call the ReadHeader or ReadMeasurement functions before this function.

Parameters
filePointer to an opened file.

◆ ReadHeader()

virtual void mdf::MdfFile::ReadHeader ( std::FILE * file)
pure virtual

Reads information about the file i.e. the ID and HD block. It doesn't read in any other information as measurement information.

Parameters
filePointer to an opened file.

◆ ReadMeasurementInfo()

virtual void mdf::MdfFile::ReadMeasurementInfo ( std::FILE * file)
pure virtual

Reads information about the measurements (DG) and sub-measurements (CG) in the file. It doesn't read any information about the channels.

There is no need to call the ReadHeader function before this function.

Parameters
filePointer to an opened file.

◆ Version()

virtual std::string mdf::MdfFile::Version ( ) const
nodiscardpure virtual

Returns the MDF file version.

Returns
File version.

◆ Write()

virtual bool mdf::MdfFile::Write ( std::FILE * file)
pure virtual

Saves all blocks onto the file. You may call this function many times as it keep track of which blocks has been saved or not. You may close and open the file in between calls but this object keeps track of which block has been written or not, so don't delete this object.

Parameters
filePointer to an open file.
Returns
True on success.

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