OSDN Git Service

b4f25d47ce17d29b800ce9cad6bc5c82ebc7779c
[qt-creator-jp/qt-creator-jp.git] / src / plugins / projectexplorer / processparameters.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 **
9 ** No Commercial Usage
10 **
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
14 ** this package.
15 **
16 ** GNU Lesser General Public License Usage
17 **
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights.  These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **************************************************************************/
33
34 #ifndef PROCESSPARAMETERS_H
35 #define PROCESSPARAMETERS_H
36
37 #include "projectexplorer_export.h"
38
39 #include <utils/environment.h>
40
41 namespace Utils {
42 class AbstractMacroExpander;
43 }
44
45 namespace ProjectExplorer {
46
47 /*!
48   ProcessParameters aggregates all parameters needed to start a process.
49
50   It offers a set of functions which expand macros and environment variables
51   inside the raw parameters to obtain final values for starting a process
52   or for display purposes.
53 */
54
55 class PROJECTEXPLORER_EXPORT ProcessParameters
56 {
57 public:
58     ProcessParameters();
59
60     /// setCommand() sets the executable to run
61     void setCommand(const QString &cmd);
62     QString command() const { return m_command; }
63
64     /// sets the command line arguments used by the process
65     void setArguments(const QString &arguments);
66     QString arguments() const { return m_arguments; }
67
68     /// sets the workingDirectory for the process for a buildConfiguration
69     /// should be called from init()
70     void setWorkingDirectory(const QString &workingDirectory);
71     QString workingDirectory() const { return m_workingDirectory; }
72
73     /// Set the Environment for running the command
74     /// should be called from init()
75     void setEnvironment(const Utils::Environment &env) { m_environment = env; }
76     Utils::Environment environment() const { return m_environment; }
77
78     /// Set the macro expander to use on the command, arguments and working dir.
79     /// Note that the caller retains ownership of the object.
80     void setMacroExpander(Utils::AbstractMacroExpander *mx) { m_macroExpander = mx; }
81     Utils::AbstractMacroExpander *macroExpander() const { return m_macroExpander; }
82
83     /// Get the fully expanded working directory:
84     QString effectiveWorkingDirectory() const;
85     /// Get the fully expanded command name to run:
86     QString effectiveCommand() const;
87     /// Get the fully expanded arguments to use:
88     QString effectiveArguments() const;
89
90     /// True if effectiveCommand() would return only a fallback
91     bool commandMissing() const;
92
93     QString prettyCommand() const;
94     QString prettyArguments() const;
95     QString summary(const QString &displayName) const;
96     QString summaryInWorkdir(const QString &displayName) const;
97
98 private:
99     QString m_workingDirectory;
100     QString m_command;
101     QString m_arguments;
102     Utils::Environment m_environment;
103     Utils::AbstractMacroExpander *m_macroExpander;
104
105     mutable QString m_effectiveWorkingDirectory;
106     mutable QString m_effectiveCommand;
107     mutable QString m_effectiveArguments;
108     mutable bool m_commandMissing;
109 };
110
111 } // namespace ProjectExplorer
112
113 #endif // PROCESSPARAMETERS_H