MnaProject
Namespace: MNALIB · Library: MNA Library
#include <mna/mna_project.h>
class MNALIB::MnaProject
Top-level MNA project container.
Holds subjects, pipeline steps, and project metadata.
src/examples/ex_mna/main.cpp
MnaProject project;
project.name = "ex_mna";
project.subjects.append(subject);
project.pipeline = graph.nodes();
const QString jsonPath = dir.filePath("pipeline.mna"); // UTF-8 JSON
const QString cborPath = dir.filePath("pipeline.mnx"); // CBOR with an "MNX1" magic
const bool saved = MnaIO::write(project, jsonPath) && MnaIO::write(project, cborPath);
const MnaProject fromJson = MnaIO::read(jsonPath);
const MnaProject fromCbor = MnaIO::read(cborPath);
Public Methods
MnaProject()
Default constructor.
toJson()
Serialize to QJsonObject.
Returns:
- QJsonObject — JSON object with all project fields, subjects, pipeline nodes and preserved extras.
toCbor()
Serialize to QCborMap.
Returns:
- QCborMap — CBOR map with all project fields, subjects, pipeline nodes and preserved extras.
Static Methods
fromJson(json)
Deserialize from QJsonObject.
Parameters:
- json : const QJsonObject &
JSON object as produced by
toJson().
Returns:
- MnaProject — The project; missing keys take default values and unknown keys go to extras.
fromCbor(cbor)
Deserialize from QCborMap.
Parameters:
- cbor : const QCborMap &
CBOR map as produced by
toCbor().
Returns:
- MnaProject — The project; missing keys take default values and unknown keys go to extras.
read(path)
Read an MNA project from file.
Delegates to MnaIO.
Parameters:
- path : const QString & Path to the .mna or .mnx file.
Returns:
- MnaProject — The deserialized
MnaProject.
write(project, path)
Write an MNA project to file.
Delegates to MnaIO.
Parameters:
-
project : const MnaProject & The project to write.
-
path : const QString & Path to the .mna or .mnx file.
Returns:
- bool — True if successful.
Example
- Full source:
src/examples/ex_mna/main.cpp - Build target:
ex_mna(runs under CTest)
Used in examples
ex_mna
MNA library: register operations, build and run a graph, bind parameters and save a project.
src/examples/ex_mna/main.cpp, line 213
MnaProject project;
project.name = "ex_mna";
project.subjects.append(subject);
project.pipeline = graph.nodes();
const QString jsonPath = dir.filePath("pipeline.mna"); // UTF-8 JSON
const QString cborPath = dir.filePath("pipeline.mnx"); // CBOR with an "MNX1" magic
const bool saved = MnaIO::write(project, jsonPath) && MnaIO::write(project, cborPath);
const MnaProject fromJson = MnaIO::read(jsonPath);
const MnaProject fromCbor = MnaIO::read(cborPath);
ok &= expect(saved && fromJson.name == "ex_mna" && fromCbor.subjects.size() == 1 && fromCbor.subjects[0].sessions[0].recordings[0].files[0].path == raw.path && fromJson.pipeline[2].verification.postResults.first().message == verdict.message && report.language == "python" && fromJson.pipeline.size() == 3 && fromCbor.pipeline.size() == 3 && fromCbor.pipeline[1].inputs[0].sourceNodeId == "source" && fromJson.pipeline[1].attributes.value("gain").toDouble() == 2.0,
"MnaIO round-trips the 3-node pipeline through .mna and .mnx");
Authors of this file
- Christoph Dinh <christoph.dinh@mne-cpp.org>