Documentation for OpenFLUID 2.2.2
Loading...
Searching...
No Matches
FluidXIO.hpp
Go to the documentation of this file.
1/*
2
3 This file is part of OpenFLUID software
4 Copyright(c) 2021-2026, INRAE
5
6
7 == GNU General Public License Usage ==
8
9 OpenFLUID is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 OpenFLUID is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
21
22
23 == Other Usage ==
24
25 Other Usage means a use of OpenFLUID that is inconsistent with the GPL
26 license, and requires a written agreement between You and INRA.
27 Licensees for Other Usage of OpenFLUID may use this file in accordance
28 with the terms contained in the written agreement between You and INRA.
29
30*/
31
32
33/**
34 @file FluidXIO.hpp
35
36 @author Jean-Christophe Fabre <jean-christophe.fabre@inrae.fr>
37*/
38
39
40#ifndef __OPENFLUID_FLUIDX_FLUIDXIO_HPP__
41#define __OPENFLUID_FLUIDX_FLUIDXIO_HPP__
42
43
44#include <string>
45
49
50
51namespace openfluid { namespace fluidx {
52
53
55{
56 public:
57
59 {
60 public:
61
62 std::string FormatVersion;
63
64 std::vector<std::string> UnknownTags;
65
66 void clear()
67 {
68 FormatVersion.clear();
69 UnknownTags.clear();
70 }
71
72 bool hasFormat() const
73 {
74 return !FormatVersion.empty();
75 }
76
77 bool isCorrectFormat() const
78 {
79 return FormatVersion == FluidXIO::FormatVersion;
80 }
81
82 bool isOK() const
83 {
84 return isCorrectFormat() && UnknownTags.empty();
85 }
86 };
87
88 class LoadingReport : public std::map<std::string,FileLoadingReport>
89 {
90 public:
91
92 bool hasFormat() const
93 {
94 bool OK = true;
95 for (const auto& File : *this)
96 {
97 OK = OK && File.second.hasFormat();
98 }
99 return OK;
100 }
101
102 bool isCorrectFormat() const
103 {
104 bool OK = true;
105 for (const auto& File : *this)
106 {
107 OK = OK && File.second.isCorrectFormat();
108 }
109 return OK;
110 }
111
112 bool hasUnknownTags() const
113 {
114 bool Found = false;
115 for (const auto& File : *this)
116 {
117 Found = Found || !File.second.UnknownTags.empty();
118 }
119 return Found;
120 }
121
122 bool isOK() const
123 {
124 bool OK = true;
125 for (const auto& File : *this)
126 {
127 OK = OK && File.second.isOK();
128 }
129 return OK;
130 }
131 };
132
133
134 private:
135
136 openfluid::base::IOListener* mp_Listener;
137
138 LoadingReport m_LoadingReport;
139
140
141 public:
142
143 static inline std::string const FormatVersion = "fluidx 4";
144
146
147 FluidXDescriptor loadFromDirectory(const std::string& DirPath);
148
150 {
151 return m_LoadingReport;
152 }
153
154 void writeToManyFiles(const FluidXDescriptor& Desc, const std::string& DirPath) const;
155
156 void writeToSingleFile(const FluidXDescriptor& Desc, const std::string& FilePath) const;
157};
158
159
160} } // namespaces
161
162
163#endif /* __OPENFLUID_FLUIDX_FLUIDXIO_HPP__ */
Definition IOListener.hpp:53
Definition FluidXDescriptor.hpp:60
bool hasFormat() const
Definition FluidXIO.hpp:72
void clear()
Definition FluidXIO.hpp:66
std::string FormatVersion
Definition FluidXIO.hpp:62
std::vector< std::string > UnknownTags
Definition FluidXIO.hpp:64
bool isOK() const
Definition FluidXIO.hpp:82
bool isCorrectFormat() const
Definition FluidXIO.hpp:77
bool isOK() const
Definition FluidXIO.hpp:122
bool hasFormat() const
Definition FluidXIO.hpp:92
bool isCorrectFormat() const
Definition FluidXIO.hpp:102
bool hasUnknownTags() const
Definition FluidXIO.hpp:112
Definition FluidXIO.hpp:55
void writeToSingleFile(const FluidXDescriptor &Desc, const std::string &FilePath) const
FluidXIO(openfluid::base::IOListener *Listener)
FluidXDescriptor loadFromDirectory(const std::string &DirPath)
const LoadingReport & getLoadingReport() const
Definition FluidXIO.hpp:149
void writeToManyFiles(const FluidXDescriptor &Desc, const std::string &DirPath) const
#define OPENFLUID_API
Definition dllexport.hpp:86
Definition ApplicationException.hpp:47