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 <QProcess>
48 
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_Name;
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  QProcess* 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);
140 
141 
142  signals:
143 
144  void processFinished();
145 
146 
147  public:
148 
149  WareSrcContainer(const QString& AbsolutePath, openfluid::ware::WareType Type, const QString& WareName);
150 
151  ~WareSrcContainer();
152 
153  void update();
154 
155  static QString searchMainCppFileName(const QString& CMakeFileContent);
156 
157  static QString searchUiParamCppFileName(const QString& CMakeFileContent);
158 
159  /**
160  Return the absolute paths of:
161  - the CMake config file if it exists on disk,
162  - the main .cpp file as set in the CMakeLists.txt, if this .cpp exists on disk.
163  If no .cpp file was found (because it doesn't exists, it wasn't found in CMake file,
164  or CMake file doesn't exist):
165  - the first .cpp file found in this ware directory (not recursive).
166  @return a list of existing absolute paths into this ware directory. It can be empty.
167  */
168  QStringList getDefaultFilesPaths();
169 
170  QString getAbsolutePath() const;
171 
172  openfluid::ware::WareType getType() const;
173 
174  QString getName() const;
175 
176  QString getTypeSubDir() const;
177 
178  /**
179  Returns the absolute path of the main .cpp as set in the CMake config file, if this .cpp file exists,
180  otherwise an empty string
181  */
182  QString getMainCppPath() const;
183 
184  /**
185  Returns the absolute path of the ui-parameterization .cpp as set in the CMake config file,
186  if this .cpp file exists, otherwise an empty string
187  */
188  QString getUiParamCppPath() const;
189 
190  /**
191  Returns the absolute path of the CMake config file, if this file exists,
192  otherwise an empty string
193  */
194  QString getCMakeConfigPath() const;
195 
196  /**
197  Returns the absolute path of the CMakeLists.txt file, if this file exists,
198  otherwise an empty string
199  */
200  QString getCMakeListsPath() const;
201 
202  /**
203  Returns the absolute path of the wareshub.json file, if this file exists,
204  otherwise an empty string
205  */
206  QString getJsonPath() const;
207 
208  void setMsgStream(openfluid::waresdev::WareSrcMsgStream& Stream);
209 
210  void setConfigMode(ConfigMode Mode);
211 
212  void setBuildMode(BuildMode Mode);
213 
214  void configure();
215 
216  void build();
217 
218  QList<WareSrcMsgParser::WareSrcMsg> getMessages();
219 
220 };
221 
222 
223 } } // namespaces
224 
225 
226 #endif /* __OPENFLUID_WARESDEV_WARESRCCONTAINER_HPP__ */
BuildMode
Definition: WareSrcContainer.hpp:68
ConfigMode
Definition: WareSrcContainer.hpp:63
Definition: WareSrcMsgParser.hpp:54
Header of ...
Definition: WareSrcMsgStream.hpp:52
Definition: ApplicationException.hpp:47
WareType
Definition: TypeDefs.hpp:62
Header of ...
#define OPENFLUID_API
Definition: dllexport.hpp:87
Definition: WareSrcContainer.hpp:57