Manual for OpenFLUID 2.1.10

WareSrcContainer.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 WareSrcContainer.hpp
35  @brief Header of ...
36 
37  @author Aline LIBRES <aline.libres@gmail.com>
38  */
39 
40 
41 #ifndef __OPENFLUID_WARESDEV_WARESRCCONTAINER_HPP__
42 #define __OPENFLUID_WARESDEV_WARESRCCONTAINER_HPP__
43 
44 
45 #include <QString>
46 #include <QObject>
47 #include <QElapsedTimer>
48 
52 #include <openfluid/dllexport.hpp>
53 
54 
55 namespace openfluid { namespace waresdev {
56 
57 
58 class OPENFLUID_API WareSrcContainer: public QObject
59 {
60  Q_OBJECT
61 
62  public:
63 
64  enum class ConfigMode
65  {
66  CONFIG_DEBUG, CONFIG_RELEASE
67  };
68 
69  enum class BuildMode
70  {
71  BUILD_WITHINSTALL, BUILD_NOINSTALL
72  };
73 
74 
75  private slots:
76 
77  void processStandardOutput();
78 
79  void processErrorOutput();
80 
81  void processFinishedOutput(int ExitCode);
82 
83 
84  private:
85 
86  QString m_AbsolutePath;
87 
89 
90  QString m_ID;
91 
92  /**
93  * Absolute path of the CMake config file if it exists, otherwise an empty string
94  */
95  QString m_AbsoluteCMakeConfigPath;
96 
97  /**
98  * Absolute path of the main .cpp as set in the CMake config file, if this .cpp file exists,
99  * otherwise an empty string
100  */
101  QString m_AbsoluteMainCppPath;
102 
103  /**
104  * Absolute path of the ui-parameterization .cpp as set in the CMake config file, if this .cpp file exists,
105  * otherwise an empty string
106  */
107  QString m_AbsoluteUiParamCppPath;
108 
109  /**
110  * Absolute path of the CMake config file if it exists, otherwise an empty string
111  */
112  QString m_AbsoluteCMakeListsPath;
113 
114  /**
115  * Absolute path of the wareshub.json file if it exists, otherwise an empty string
116  */
117  QString m_AbsoluteJsonPath;
118 
120 
121  ConfigMode m_ConfigMode;
122 
123  BuildMode m_BuildMode;
124 
125  unsigned int m_BuildJobs;
126 
127  QString m_BuildDirPath;
128 
129  WareSrcProcess* mp_Process;
130 
131  QElapsedTimer m_ProcessTimer;
132 
133  QString m_OFVersion;
134 
135  WareSrcMsgParser* mp_CurrentParser;
136 
137  QList<WareSrcMsgParser::WareSrcMsg> m_Messages;
138 
139  /**
140  @throw openfluid::base::FrameworkException
141  */
142  void findCMake();
143 
144  void runCommand(const QString& Command, const QProcessEnvironment& Env,
146 
147 
148  signals:
149 
150  void processLaunched();
151 
152  void processFinished();
153 
154  void configureProcessLaunched(openfluid::ware::WareType Type, const QString& ID);
155 
156  void configureProcessFinished(openfluid::ware::WareType Type, const QString& ID);
157 
158  void buildProcessLaunched(openfluid::ware::WareType Type, const QString& ID);
159 
160  void buildProcessFinished(openfluid::ware::WareType Type, const QString& ID);
161 
162 
163  public:
164 
165  WareSrcContainer(const QString& AbsolutePath, openfluid::ware::WareType Type, const QString& WareID);
166 
167  ~WareSrcContainer();
168 
169  void update();
170 
171  static QString searchMainCppFileName(const QString& CMakeFileContent);
172 
173  static QString searchUiParamCppFileName(const QString& CMakeFileContent);
174 
175  /**
176  Return the absolute paths of:
177  - the CMake config file if it exists on disk,
178  - the main .cpp file as set in the CMakeLists.txt, if this .cpp exists on disk.
179  If no .cpp file was found (because it doesn't exists, it wasn't found in CMake file,
180  or CMake file doesn't exist):
181  - the first .cpp file found in this ware directory (not recursive).
182  @return a list of existing absolute paths into this ware directory. It can be empty.
183  */
184  QStringList getDefaultFilesPaths();
185 
186  QString getAbsolutePath() const;
187 
188  QString getBuildDirPath() const;
189 
190  openfluid::ware::WareType getType() const;
191 
192  QString getID() const;
193 
194  QString getTypeSubDir() const;
195 
196  /**
197  Returns the absolute path of the main .cpp as set in the CMake config file, if this .cpp file exists,
198  otherwise an empty string
199  */
200  QString getMainCppPath() const;
201 
202  /**
203  Returns the absolute path of the ui-parameterization .cpp as set in the CMake config file,
204  if this .cpp file exists, otherwise an empty string
205  */
206  QString getUiParamCppPath() const;
207 
208  /**
209  Returns the absolute path of the CMake config file, if this file exists,
210  otherwise an empty string
211  */
212  QString getCMakeConfigPath() const;
213 
214  /**
215  Returns the absolute path of the CMakeLists.txt file, if this file exists,
216  otherwise an empty string
217  */
218  QString getCMakeListsPath() const;
219 
220  /**
221  Returns the absolute path of the wareshub.json file, if this file exists,
222  otherwise an empty string
223  */
224  QString getJsonPath() const;
225 
226  std::map<QString,QString> getConfigureVariables() const;
227 
228  QString getConfigureGenerator() const;
229 
230  QString getConfigureExtraOptions() const;
231 
232  QProcessEnvironment getConfigureEnvironment() const;
233 
234  QProcessEnvironment getBuildEnvironment() const;
235 
236  QString getBuildTarget() const;
237 
238  unsigned int getBuildJobs() const;
239 
240  QString getGenerateDocTarget() const;
241 
242  void prepareBuildDirectory() const;
243 
244  void setMsgStream(openfluid::waresdev::WareSrcMsgStream& Stream);
245 
246  void setConfigMode(ConfigMode Mode);
247 
248  void setBuildMode(BuildMode Mode);
249 
250  void setBuildJobs(unsigned int Jobs);
251 
252  void configure();
253 
254  void build();
255 
256  void generateDoc();
257 
258  QList<WareSrcMsgParser::WareSrcMsg> getMessages();
259 
260  bool isProcessRunning() const;
261 
262 };
263 
264 
265 } } // namespaces
266 
267 
268 #endif /* __OPENFLUID_WARESDEV_WARESRCCONTAINER_HPP__ */
Definition: ApplicationException.hpp:47
BuildMode
Definition: WareSrcContainer.hpp:69
WareType
Definition: TypeDefs.hpp:60
Definition: WareSrcProcess.hpp:51
Header of ...
ConfigMode
Definition: WareSrcContainer.hpp:64
Definition: WareSrcContainer.hpp:58
Type
Definition: WareSrcProcess.hpp:56
#define OPENFLUID_API
Definition: dllexport.hpp:86
Header of ...
Definition: WareSrcMsgParser.hpp:54
Definition: WareSrcMsgStream.hpp:52