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