All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ExternalProgram.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 ExternalProgram.hpp
35  \brief Header of ...
36 
37  \author Jean-Christophe FABRE <fabrejc@supagro.inra.fr>
38  */
39 
40 
41 #ifndef __EXTERNALPROGRAM_HPP__
42 #define __EXTERNALPROGRAM_HPP__
43 
44 #include <openfluid/dllexport.hpp>
45 
46 #include <QStringList>
47 
48 
49 namespace openfluid { namespace tools {
50 
51 /**
52  Management of external programs
53 */
55 {
56  private:
57 
58  QString m_Program;
59 
60  QString m_FullProgramPath;
61 
62  QStringList m_SearchPaths;
63 
64  bool m_UsePathEnv;
65 
66 
67  public:
68 
69  /**
70  List of pre-registered external programs
71  */
72  enum RegisteredPrograms { CMakeProgram, ZipProgram, SevenZipProgram,
73  GnuplotProgram, GoogleEarthProgram, GccProgram,
74  PdfLatexProgram, BibTexProgram, Latex2HTMLProgram };
75 
76  /**
77  Constructor for a given external programs. Automatically searches for the program at construction
78  @param[in] Program The program to find
79  @param[in] SearchPaths The list of paths to search. Default value is an empty list
80  @param[in] UsePathEnv Enable the use of PATH environment variable to search for the program. Default value is true.
81  */
82  ExternalProgram(const QString& Program,
83  const QStringList& SearchPaths = QStringList(),
84  bool UsePathEnv = true);
85 
86  ~ExternalProgram();
87 
88  /**
89  Returns an ExternalProgram object initialized with the registered program to find
90  @param[in] Prog The registered program to find
91  @param[in] SearchPaths The list of paths to search. Default value is an empty list
92  @param[in] UsePathEnv Enable the use of PATH environment variable to search for the registered program. Default value is true.
93  @return An ExternalProgram object initialized with the registered program to find
94  */
95  static ExternalProgram getRegisteredProgram(RegisteredPrograms Prog,
96  const QStringList& SearchPaths = QStringList(),
97  bool UsePathEnv = true);
98 
99  /**
100  Finds a program using the PATH environment variable
101  @param[in] Program The command of the program to find
102  @return The full path of the first found program
103  */
104  static QString findUsingPATHEnvVar(const QString& Program);
105 
106  /**
107  Finds a program using a given paths list
108  @param[in] Program The program to find
109  @param[in] PathsList The list of paths to search
110  @return The full path of the first found program
111  */
112  static QString findUsingPathsList(const QString& Program, const QStringList& PathsList);
113 
114  /**
115  Returns true if the current program has been found
116  @return true if the current program has been found
117  */
118  bool isFound() const { return !m_FullProgramPath.isEmpty(); };
119 
120  /**
121  Searches for the program
122  */
123  void searchForProgram();
124 
125  /**
126  Returns the full path of the program
127  @return the full path of the program if it has been found, otherwise an empty string
128  */
129  QString getFullProgramPath() const { return m_FullProgramPath; };
130 
131 };
132 
133 
134 } } // namespaces
135 
136 #endif /* __EXTERNALPROGRAM_HPP__ */
bool isFound() const
Definition: ExternalProgram.hpp:118
Definition: ExternalProgram.hpp:72
Definition: ExternalProgram.hpp:74
Definition: ExternalProgram.hpp:54
RegisteredPrograms
Definition: ExternalProgram.hpp:72
QString getFullProgramPath() const
Definition: ExternalProgram.hpp:129
#define DLLEXPORT
Definition: dllexport.hpp:51