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