MDF Lib 2.2
Interface against MDF 3/4 files
Loading...
Searching...
No Matches
mdffile.h
Go to the documentation of this file.
1/*
2 * Copyright 2021 Ingemar Hedvall
3 * SPDX-License-Identifier: MIT
4 */
8#pragma once
9#include <cstdio>
10
11#include <string>
12#include <vector>
13
14#include "mdf/iheader.h"
15
16namespace mdf {
17
18class IAttachment;
19class IDataGroup;
20class IChannel;
21
24using AttachmentList = std::vector<const IAttachment*>;
25
28using DataGroupList = std::vector<IDataGroup*>;
29
37class MdfFile {
38 public:
39 virtual ~MdfFile() = default;
40
48 virtual void Attachments(AttachmentList& dest) const = 0;
49
55 virtual void DataGroups(DataGroupList& dest) const = 0;
56
62 [[nodiscard]] virtual std::string Version() const = 0;
63
69 [[nodiscard]] int MainVersion() const;
70
77 virtual void MinorVersion(int minor) = 0;
78
85 [[nodiscard]] int MinorVersion() const;
86
94 virtual void ProgramId(const std::string& program_id) = 0;
95
102 [[nodiscard]] virtual std::string ProgramId() const = 0;
103
111 [[nodiscard]] virtual IHeader* Header() const = 0;
112
122 [[nodiscard]] virtual IAttachment* CreateAttachment();
123
131 [[nodiscard]] virtual IDataGroup* CreateDataGroup() = 0;
132
138 [[nodiscard]] virtual bool IsMdf4() const = 0;
139
146 virtual void ReadHeader(std::FILE* file) = 0;
147
157 virtual void ReadMeasurementInfo(std::FILE* file) = 0;
158
169 virtual void
170 ReadEverythingButData(std::FILE* file) = 0;
171
181 virtual bool Write(std::FILE* file) = 0;
182
189 [[nodiscard]] const std::string& Name() const { return name_; }
190
197 void Name(const std::string& name) { name_ = name; }
198
204 [[nodiscard]] const std::string& FileName() const { return filename_; }
205
211 void FileName(const std::string& filename);
212
214 virtual void IsFinalized(bool finalized, std::FILE* file,
215 uint16_t standard_flags, uint16_t custom_flags) = 0;
217 [[nodiscard]] virtual bool IsFinalized(uint16_t& standard_flags,
218 uint16_t& custom_flags) const = 0;
219
226 [[nodiscard]] virtual bool IsFinalizedDone() const;
227
229 [[nodiscard]] virtual IDataGroup* FindParentDataGroup(
230 const IChannel &channel) const = 0;
231 protected:
232 MdfFile() = default;
233 private:
234 std::string name_;
235 std::string filename_;
236};
237
238} // namespace mdf
Interface against an attached file.
Definition iattachment.h:21
Defines a MDF channel (CN) block.
Definition ichannel.h:126
Interface to a data group (DG) block.
Definition idatagroup.h:42
Interface class against an MDF HD block.
Definition iheader.h:34
Implements an user interface against a MDF file.
Definition mdffile.h:37
virtual void ProgramId(const std::string &program_id)=0
Sets the program identifier int the ID block.
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 void DataGroups(DataGroupList &dest) const =0
Fetch a list of all measurements.
virtual std::string Version() const =0
Returns the file version.
const std::string & Name() const
Display name of the file.
Definition mdffile.h:189
virtual bool Write(std::FILE *file)=0
Saves all blocks onto the file.
MdfFile()=default
Default constructor.
virtual std::string ProgramId() const =0
Returns the program identifier.
virtual bool IsFinalized(uint16_t &standard_flags, uint16_t &custom_flags) const =0
Returns true if the file is finalized.
virtual void ReadEverythingButData(std::FILE *file)=0
Reads in all expect raw data from the file.
int MainVersion() const
Returns the main version of the file.
virtual bool IsFinalizedDone() const
virtual void ReadHeader(std::FILE *file)=0
Reads the information about the file.
virtual IHeader * Header() const =0
Returns the header object.
virtual void Attachments(AttachmentList &dest) const =0
Fetch a list of attachments.
virtual bool IsMdf4() const =0
Returns true if this is a MDF4 file.
virtual void ReadMeasurementInfo(std::FILE *file)=0
Reads the measurement information about the file.
virtual void MinorVersion(int minor)=0
Sets the minor version of the file.
virtual IDataGroup * CreateDataGroup()=0
Creates a new measurement (DG block).
virtual ~MdfFile()=default
Default destructor.
const std::string & FileName() const
Returns the full name of the file.
Definition mdffile.h:204
virtual IDataGroup * FindParentDataGroup(const IChannel &channel) const =0
Returns a parent data group (DG) depending a channel.
void Name(const std::string &name)
Set the display name of the file.
Definition mdffile.h:197
virtual IAttachment * CreateAttachment()
Creates a new attachment (AT block).
void FileName(const std::string &filename)
Sets the file name.
int MinorVersion() const
Returns the minor version number of the MDF file.
Interface against a HD block.
Main namespace for the MDF library.
Definition canmessage.h:17
std::vector< const IAttachment * > AttachmentList
List of pointers to attachments.
Definition mdffile.h:24
std::vector< IDataGroup * > DataGroupList
List of pointers to measurements (DG block).
Definition mdffile.h:28