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 
64  {
65  CONFIG_DEBUG, CONFIG_RELEASE
66  };
67 
68  enum BuildMode
69  {
70  BUILD_WITHINSTALL, BUILD_NOINSTALL
71  };
72 
73  private:
74 
75  QString m_AbsolutePath;
76 
78 
79  QString m_Name;
80 
81  /**
82  * Absolute path of the CMake config file if it exists, otherwise an empty string
83  */
84  QString m_AbsoluteCMakeConfigPath;
85 
86  /**
87  * Absolute path of the main .cpp as set in the CMake config file, if this .cpp file exists,
88  * otherwise an empty string
89  */
90  QString m_AbsoluteMainCppPath;
91 
92  /**
93  * Absolute path of the ui-parameterization .cpp as set in the CMake config file, if this .cpp file exists,
94  * otherwise an empty string
95  */
96  QString m_AbsoluteUiParamCppPath;
97 
98  /**
99  * Absolute path of the CMake config file if it exists, otherwise an empty string
100  */
101  QString m_AbsoluteCMakeListsPath;
102 
103  /**
104  * Absolute path of the wareshub.json file if it exists, otherwise an empty string
105  */
106  QString m_AbsoluteJsonPath;
107 
108  QString m_CMakeProgramPath;
109 
111 
112  ConfigMode m_ConfigMode;
113 
114  BuildMode m_BuildMode;
115 
116  QString m_BuildDirPath;
117 
118  QProcess* mp_Process;
119 
120  QString m_OFVersion;
121 
122  WareSrcMsgParser* mp_CurrentParser;
123 
124  QList<WareSrcMsgParser::WareSrcMsg> m_Messages;
125 
126  /**
127  * @throw openfluid::base::FrameworkException
128  */
129  void findCMake();
130 
131  void runCommand(const QString& Command, const QProcessEnvironment& Env);
132 
133 
134  private slots:
135 
136  void processStandardOutput();
137 
138  void processErrorOutput();
139 
140  void processFinishedOutput(int ExitCode);
141 
142 
143  public:
144 
145  WareSrcContainer(const QString& AbsolutePath, WareSrcManager::WareType Type, const QString& WareName);
146 
147  ~WareSrcContainer();
148 
149  void update();
150 
151  static QString searchMainCppFileName(const QString& CMakeFileContent);
152 
153  static QString searchUiParamCppFileName(const QString& CMakeFileContent);
154 
155  /**
156  * Return the absolute paths of:
157  * - the CMake config file if it exists on disk,
158  * - the main .cpp file as set in the CMakeLists.txt, if this .cpp exists on disk.
159  * If no .cpp file was found (because it doesn't exists, it wasn't found in CMake file,
160  * or CMake file doesn't exist):
161  * - the first .cpp file found in this ware directory (not recursive).
162  * @return a list of existing absolute paths into this ware directory. It can be empty.
163  */
164  QStringList getDefaultFilesPaths();
165 
166  QString getAbsolutePath() const;
167 
168  WareSrcManager::WareType getType() const;
169 
170  QString getName() const;
171 
172  QString getTypeSubDir() const;
173 
174  /**
175  * Return the absolute path of the main .cpp as set in the CMake config file, if this .cpp file exists,
176  * otherwise an empty string
177  */
178  QString getMainCppPath() const;
179 
180  /**
181  * Return the absolute path of the ui-parameterization .cpp as set in the CMake config file,
182  * if this .cpp file exists, otherwise an empty string
183  */
184  QString getUiParamCppPath() const;
185 
186  /**
187  * Return the absolute path of the CMake config file, if this file exists,
188  * otherwise an empty string
189  */
190  QString getCMakeConfigPath() const;
191 
192  /**
193  * Return the absolute path of the CMakeLists.txt file, if this file exists,
194  * otherwise an empty string
195  */
196  QString getCMakeListsPath() const;
197 
198  /**
199  * Return the absolute path of the wareshub.json file, if this file exists,
200  * otherwise an empty string
201  */
202  QString getJsonPath() const;
203 
204  void setMsgStream(openfluid::waresdev::WareSrcMsgStream& Stream);
205 
206  void setConfigMode(ConfigMode Mode);
207 
208  void setBuildMode(BuildMode Mode);
209 
210  void configure();
211 
212  void build();
213 
214  QList<WareSrcMsgParser::WareSrcMsg> getMessages();
215 
216  signals:
217 
218  void processFinished();
219 };
220 
221 
222 } } // namespaces
223 
224 
225 #endif /* __OPENFLUID_WARESDEV_WARESRCCONTAINER_HPP__ */
WareType
Definition: WareSrcManager.hpp:57
Definition: WareSrcMsgParser.hpp:57
ConfigMode
Definition: WareSrcContainer.hpp:63
BuildMode
Definition: WareSrcContainer.hpp:68
#define OPENFLUID_API
Definition: dllexport.hpp:87
Header of ...
Header of ...
Definition: WareSrcMsgStream.hpp:52
Definition: WareSrcContainer.hpp:57