Manual for OpenFLUID 2.1.11

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