Documentation for OpenFLUID 2.2.0
WareSrcChecker.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 WareSrcChecker.hpp
35 
36  @author Jean-Christophe Fabre <jean-christophe.fabre@inrae.fr>
37  @author Dorian GERARDIN <dorian.gerardin@inrae.fr>
38  @author Armel THÖNI <armel.thoni@inrae.fr>
39 */
40 
41 
42 #ifndef __OPENFLUID_WARESDEV_WARESRCCHECKER_HPP__
43 #define __OPENFLUID_WARESDEV_WARESRCCHECKER_HPP__
44 
45 
46 #include <string>
47 
51 #include <openfluid/dllexport.hpp>
52 
53 
54 namespace openfluid { namespace waresdev {
55 
56 
57 /**
58  Class to check wares source code
59 */
61 {
62  public:
63 
65 
66  using ChecksList = std::vector<std::string>;
67 
68 
69  private:
70 
71  const openfluid::tools::FilesystemPath m_SrcPathObj;
72 
73  const ChecksList m_IgnoredChecks;
74 
75 
76  void processReportingItem(ReportingData::ReportingList& List,
77  const std::string& Msg, std::function<bool()> Predicate,
78  ReportingData::ReportingStatus StatusIfFail =
79  ReportingData::ReportingStatus::WARNING,
80  const std::string& SpecificInformation="") const;
81 
82  WareSrcChecker::ReportingData::ReportingList performStructureCheck(bool OKToRun) const;
83 
84  WareSrcChecker::ReportingData::ReportingList performMetainfoCheck(bool OKToRun) const;
85 
86  WareSrcChecker::ReportingData::ReportingList performCodeCheck(bool OKToRun) const;
87 
88  void updateWithPedanticCheck(ReportingData& RepData);
89 
90  bool hasMigrationFiles() const;
91 
92 
93  public:
94 
96 
97  /**
98  Constructs a checker
99  @param[in] SrcPath The path to the sources to check
100  @param[in] IgnoredChecks A list of checks to ignore (none by default)
101  */
102  WareSrcChecker(const std::string& SrcPath, const ChecksList& IgnoredChecks = {});
103 
104  /**
105  Perform the checks
106  @param[in] Pedantic Enables pedantic supplementary checks
107  @return The report of the performed checks
108  */
109  ReportingData performCheck(bool Pedantic = false);
110 
111  /**
112  Tries to detect the OpenFLUID compatibility version of the sources. Currently,
113  it tries to distinguish version 2.2.x from versions below.
114  @param[in] PathObj The path to the sources to detect
115  @return The numeric representation of the detected OpenFLUID version (see below), 0 if version cannot be detected.
116  Returned value | OpenFLUID version
117  --------------- | -----------------
118  202000 | 2.2.0
119  201000 | 2.1.x or below
120  */
121  static unsigned int tryDetectWareSrcVersion(const openfluid::tools::FilesystemPath& PathObj);
122 
123 };
124 
125 
126 } } // namespaces
127 
128 
129 #endif /* __OPENFLUID_WARESDEV_WARESRCCHECKER_HPP__ */
Definition: FilesystemPath.hpp:62
Definition: ReportingData.hpp:59
ReportingStatus
Definition: ReportingData.hpp:63
Definition: WareSrcChecker.hpp:61
ReportingData performCheck(bool Pedantic=false)
static unsigned int tryDetectWareSrcVersion(const openfluid::tools::FilesystemPath &PathObj)
std::vector< std::string > ChecksList
Definition: WareSrcChecker.hpp:66
WareSrcChecker(const std::string &SrcPath, const ChecksList &IgnoredChecks={})
#define OPENFLUID_API
Definition: dllexport.hpp:86
Definition: ApplicationException.hpp:47
Definition: ReportingData.hpp:79