Debian Codegraph @

HercUtilities/GenericUtility.h

raw symbols SCIP
1 /*
2 * File: GenericUtility.h
3 *
4 * Author: Jacob Dekel
5 * Created on: Aug 26, 2010
6 *
7 * Copyright (c) 2010 Jacob Dekel
8 * $Id$
9 *
10 * This object is a base class for all utilities
11 *
12 * This program is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 *
25 */
26 #ifndef GENERICUTILITY_H_
27 #define GENERICUTILITY_H_
28
29 #include <QDialog>
30 #include <QProcess>
31 #include <string>
32 #include <vector>
33
34 class UtilityExecutor;
35 class UtilityRunner;
36
37 class GenericUtility : public QDialog
38 {
39 Q_OBJECT
40 public:
41 GenericUtility(QString name, QWidget *parent = 0);
42 virtual ~GenericUtility();
43
44 protected:
45 QString mName;
46 UtilityExecutor * mExecutor;
47 UtilityRunner * mRunner;
48 UtilityRunner * mErrorRunner;
49 bool mStarted, mFinished, mFinishedOK;
50 int mRc;
51
52 bool runOrStopClicked(); // returns false if currently running
53 int execute(const std::string & pCommand, const std::string& pPath, std::vector<std::string>& pParameters, const QString &workingDIrectory=QString());
54 std::string getFlatCommand(const std::string & command, const std::string& path, std::vector<std::string>& parameters);
55
56 protected:
57 virtual void finishedSlot() = 0;
58
59 private slots:
60 void timeout();
61 void finished(int result, QProcess::ExitStatus status);
62 void errorSlot();
63 void runnerError(const QByteArray& line);
64
65 signals:
66 void error();
67 void output(QByteArray line);
68 };
69
70 #endif /* GENERICUTILITY_H_ */