Documentation for OpenFLUID 2.2.2
Loading...
Searching...
No Matches
WareSignature.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 WareSignature.hpp
35
36 @author Jean-Christophe FABRE <jean-christophe.fabre@inra.fr>
37*/
38
39
41#include <openfluid/config.hpp>
42#include <openfluid/ware/TypeDefs.hpp>
48
49
50#ifndef __OPENFLUID_WARE_WARESIGNATURE_HPP__
51#define __OPENFLUID_WARE_WARESIGNATURE_HPP__
52
53
54namespace openfluid { namespace ware {
55
56
58{
59 public:
60
62
63 using Person_t = std::pair<std::string,std::string>;
64
65 using Link_t = std::pair<std::string,std::string>;
66
67 using PeopleList_t = std::vector<Person_t>;
68
69 using LinksList_t = std::vector<Link_t>;
70
71 using DependenciesMap_t = std::map<std::string, std::string>;
72
73
74 /**
75 Information about build context
76 */
78
80
82
83 std::string Description;
84
85 /**
86 Version string
87 */
89
90 /**
91 Development status
92 */
94
95 /**
96 Authors as a list of pairs [name,email]
97 */
99
100 /**
101 Contacts as a list of pairs [name,email]
102 */
104
105 /**
106 SPDX code for software license
107 */
108 std::string License;
109
110 /**
111 List of tags
112 */
113 std::vector<std::string> Tags;
114
115 /**
116 List of links
117 */
119
120 /**
121 Issues
122 */
124
125 /**
126 Dependencies
127 */
129
130
132 {
133 clear();
134 }
135
136 /*
137 // TODO make this class non-copyable
138
139 WareSignature(const WareSignature&) = delete;
140
141 WareSignature(WareSignature&&) = default;
142
143 WareSignature& operator=(const WareSignature&) = delete;
144
145 WareSignature& operator=(WareSignature&&) = default;
146 */
147
148 virtual ~WareSignature() = default;
149
150 std::vector<std::string> getTagsByType(const std::string& Type) const
151 {
152 std::vector<std::string> MatchingTags;
153 for(const auto& Tag : Tags)
154 {
155 const std::string TagType = Type + openfluid::config::STR_SEPARATOR_TAG_TYPE;
156 if(openfluid::tools::startsWith(Tag, TagType))
157 {
158 MatchingTags.push_back(openfluid::tools::replace(Tag, TagType, ""));
159 }
160 }
161
162 return MatchingTags;
163 }
164
165
166 // =====================================================================
167 // =====================================================================
168
169
170 void clear()
171 {
172 BuildInfo = SignatureBuildInfo();
173 ID.clear();
174 Name.clear();
175 Description.clear();
176 Version.clear();
177 Status = WareStatus_t::EXPERIMENTAL;
178 Authors.clear();
179 License.clear();
180 Contacts.clear();
181 Tags.clear();
182 Links.clear();
183 Issues.clear();
184 }
185
186
187 // =====================================================================
188 // =====================================================================
189
190
191 std::string getStatusAsString() const
192 {
193 if (Status == WareStatus_t::BETA)
194 {
195 return "beta";
196 }
197 else if (Status == WareStatus_t::STABLE)
198 {
199 return "stable";
200 }
201
202 return "experimental";
203 }
204
205
206 // =====================================================================
207 // =====================================================================
208
209
210 void setStatusFromString(const std::string& StatusStr)
211 {
212 Status = WareStatus_t::EXPERIMENTAL;
213
214 if (StatusStr == "beta")
215 {
216 Status = WareStatus_t::BETA;
217 }
218 else if (StatusStr == "stable")
219 {
220 Status = WareStatus_t::STABLE;
221 }
222 }
223
224};
225
226
227// =====================================================================
228// =====================================================================
229
230
231/**
232Class for storage of the definition of data handled by the simulator.
233*/
235{
236 public:
237
238 std::string Name;
239 std::string Description;
240 std::string SIUnit;
242
245
246 SignatureDataItem(const std::string& N, const std::string& D, const std::string& SI,
247 std::function<bool(const std::string&,std::string&,
249
250 SignatureDataItem(const std::string& N, const std::string& D, const std::string& SI,
251 openfluid::core::Value::Type T, std::function<bool(const std::string&)> Validator=openfluid::ware::isNonEmpty);
252};
253
254
255// =====================================================================
256// =====================================================================
257
258
259/**
260Class for storage of the definition of data handled by the simulator.
261*/
263{
264 public:
265
267
270
272 const std::string& D, const std::string& SI,
273 std::function<bool(const std::string&,std::string&,
275 SignatureDataItem(N,D,SI,Extractor),UnitsClass(U)
276 { }
277
279 const std::string& D, const std::string& SI, openfluid::core::Value::Type T,
280 std::function<bool(const std::string&)> Validator=openfluid::ware::isNonEmpty):
281 SignatureDataItem(N,D,SI,T,Validator),UnitsClass(U)
282 { }
283};
284
285
286// =====================================================================
287// =====================================================================
288
289
290/**
291 Class for storage of the definition of the data handled by the ware. This is part of the signature.
292*/
294{
295 public:
296
297 std::vector<SignatureDataItem> UsedParams;
298
299 std::vector<SignatureDataItem> RequiredParams;
300
301 std::vector<SignatureSpatialDataItem> RequiredVars;
302
303 std::vector<SignatureSpatialDataItem> UsedVars;
304
305 std::vector<SignatureSpatialDataItem> RequiredAttributes;
306
307 std::vector<SignatureSpatialDataItem> UsedAttributes;
308
309 std::vector<std::string> RequiredExtraFiles; // TODO add description associated with each file?
310
311 std::vector<std::string> UsedExtraFiles; // TODO add description associated with each file?
312
313
315 {
316 clear();
317 }
318
320
321
322 void clear()
323 {
324 UsedParams.clear();
325 RequiredParams.clear();
326 RequiredVars.clear();
327 UsedVars.clear();
328 RequiredAttributes.clear();
329 UsedAttributes.clear();
330 RequiredExtraFiles.clear();
331 UsedExtraFiles.clear();
332 }
333
334};
335
336
338{
339 public:
340 /**
341 Handled data
342 */
344
345 void clear()
346 {
347 WareSignature::clear();
348 HandledData.clear();
349 }
350
351};
352
353
354} } // openfluid::ware
355
356
357#endif /* __OPENFLUID_WARE_WARESIGNATURE_HPP__ */
Type
Definition Value.hpp:66
@ NONE
Definition Value.hpp:66
Definition WareSignature.hpp:338
SignatureHandledData HandledData
Definition WareSignature.hpp:343
void clear()
Definition WareSignature.hpp:345
Definition WareSignature.hpp:235
SignatureDataItem(const std::string &N, const std::string &D, const std::string &SI, openfluid::core::Value::Type T, std::function< bool(const std::string &)> Validator=openfluid::ware::isNonEmpty)
std::string SIUnit
Definition WareSignature.hpp:240
std::string Name
Definition WareSignature.hpp:238
SignatureDataItem()
Definition WareSignature.hpp:243
SignatureDataItem(const std::string &N, const std::string &D, const std::string &SI, std::function< bool(const std::string &, std::string &, openfluid::core::Value::Type &)> Extractor=openfluid::ware::identityExtractor)
std::string Description
Definition WareSignature.hpp:239
Definition WareSignature.hpp:294
std::vector< SignatureDataItem > UsedParams
Definition WareSignature.hpp:297
std::vector< SignatureSpatialDataItem > UsedVars
Definition WareSignature.hpp:303
std::vector< std::string > RequiredExtraFiles
Definition WareSignature.hpp:309
std::vector< std::string > UsedExtraFiles
Definition WareSignature.hpp:311
void clear()
Definition WareSignature.hpp:322
std::vector< SignatureSpatialDataItem > RequiredAttributes
Definition WareSignature.hpp:305
std::vector< SignatureSpatialDataItem > RequiredVars
Definition WareSignature.hpp:301
SignatureHandledData()
Definition WareSignature.hpp:314
std::vector< SignatureSpatialDataItem > UsedAttributes
Definition WareSignature.hpp:307
std::vector< SignatureDataItem > RequiredParams
Definition WareSignature.hpp:299
~SignatureHandledData()
Definition WareSignature.hpp:319
Definition WareSignature.hpp:263
openfluid::core::UnitsClass_t UnitsClass
Definition WareSignature.hpp:266
SignatureSpatialDataItem(const std::string &N, const openfluid::core::UnitsClass_t &U, const std::string &D, const std::string &SI, std::function< bool(const std::string &, std::string &, openfluid::core::Value::Type &)> Extractor=openfluid::ware::identityExtractor)
Definition WareSignature.hpp:271
SignatureSpatialDataItem()
Definition WareSignature.hpp:268
SignatureSpatialDataItem(const std::string &N, const openfluid::core::UnitsClass_t &U, const std::string &D, const std::string &SI, openfluid::core::Value::Type T, std::function< bool(const std::string &)> Validator=openfluid::ware::isNonEmpty)
Definition WareSignature.hpp:278
Definition WareIssues.hpp:135
void clear()
Definition WareIssues.hpp:180
Definition WareSignature.hpp:58
WareID_t ID
Definition WareSignature.hpp:79
WareStatus_t Status
Definition WareSignature.hpp:93
PeopleList_t Authors
Definition WareSignature.hpp:98
std::vector< std::string > Tags
Definition WareSignature.hpp:113
std::string Description
Definition WareSignature.hpp:83
void clear()
Definition WareSignature.hpp:170
LinksList_t Links
Definition WareSignature.hpp:118
virtual openfluid::ware::WareType getType() const =0
WareSignature()
Definition WareSignature.hpp:131
virtual ~WareSignature()=default
std::pair< std::string, std::string > Person_t
Definition WareSignature.hpp:63
std::string License
Definition WareSignature.hpp:108
std::vector< std::string > getTagsByType(const std::string &Type) const
Definition WareSignature.hpp:150
std::string getStatusAsString() const
Definition WareSignature.hpp:191
SignatureBuildInfo BuildInfo
Definition WareSignature.hpp:77
std::vector< Link_t > LinksList_t
Definition WareSignature.hpp:69
std::map< std::string, std::string > DependenciesMap_t
Definition WareSignature.hpp:71
WareName_t Name
Definition WareSignature.hpp:81
void setStatusFromString(const std::string &StatusStr)
Definition WareSignature.hpp:210
std::vector< Person_t > PeopleList_t
Definition WareSignature.hpp:67
DependenciesMap_t Dependencies
Definition WareSignature.hpp:128
WareVersion_t Version
Definition WareSignature.hpp:88
PeopleList_t Contacts
Definition WareSignature.hpp:103
WareIssues Issues
Definition WareSignature.hpp:123
std::pair< std::string, std::string > Link_t
Definition WareSignature.hpp:65
#define OPENFLUID_API
Definition dllexport.hpp:86
std::string UnitsClass_t
Definition TypeDefs.hpp:98
bool OPENFLUID_API startsWith(const std::string &Str, const std::string &SubStr)
std::string OPENFLUID_API replace(const std::string &Str, const std::string &SearchStr, const std::string &ReplaceStr)
WareType
Definition TypeDefs.hpp:61
std::string WareID_t
Definition TypeDefs.hpp:49
std::string WareVersion_t
Definition TypeDefs.hpp:53
std::string WareName_t
Definition TypeDefs.hpp:51
bool OPENFLUID_API isNonEmpty(const std::string &Str)
Definition DataItemUtils.hpp:75
WareStatus_t
Definition TypeDefs.hpp:102
bool OPENFLUID_API identityExtractor(const std::string &VO, std::string &V, openfluid::core::Value::Type &)
Definition DataItemUtils.hpp:59
Definition ApplicationException.hpp:47
Definition TypeDefs.hpp:125