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  openfluid::ware::WareType getType() const;
184 
185  QString getID() const;
186 
187  QString getTypeSubDir() const;
188 
189  /**
190  Returns the absolute path of the main .cpp as set in the CMake config file, if this .cpp file exists,
191  otherwise an empty string
192  */
193  QString getMainCppPath() const;
194 
195  /**
196  Returns the absolute path of the ui-parameterization .cpp as set in the CMake config file,
197  if this .cpp file exists, otherwise an empty string
198  */
199  QString getUiParamCppPath() const;
200 
201  /**
202  Returns the absolute path of the CMake config file, if this file exists,
203  otherwise an empty string
204  */
205  QString getCMakeConfigPath() const;
206 
207  /**
208  Returns the absolute path of the CMakeLists.txt file, if this file exists,
209  otherwise an empty string
210  */
211  QString getCMakeListsPath() const;
212 
213  /**
214  Returns the absolute path of the wareshub.json file, if this file exists,
215  otherwise an empty string
216  */
217  QString getJsonPath() const;
218 
219  void setMsgStream(openfluid::waresdev::WareSrcMsgStream& Stream);
220 
221  void setConfigMode(ConfigMode Mode);
222 
223  void setBuildMode(BuildMode Mode);
224 
225  void configure();
226 
227  void build();
228 
229  QList<WareSrcMsgParser::WareSrcMsg> getMessages();
230 
231 };
232 
233 
234 } } // namespaces
235 
236 
237 #endif /* __OPENFLUID_WARESDEV_WARESRCCONTAINER_HPP__ */
#define OPENFLUID_API
Definition: dllexport.hpp:87
Type
Definition: WareSrcProcess.hpp:57
WareType
Definition: TypeDefs.hpp:62
ConfigMode
Definition: WareSrcContainer.hpp:63
Definition: WareSrcMsgStream.hpp:52
Definition: ApplicationException.hpp:47
Definition: WareSrcContainer.hpp:57
Header of ...
Definition: WareSrcMsgParser.hpp:54
Header of ...
Definition: WareSrcProcess.hpp:52
BuildMode
Definition: WareSrcContainer.hpp:68