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