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