ProcRun Pile   version 0.0.1
ProcRun pile.
procrun.h
Go to the documentation of this file.
1 
10 #ifndef GUARD_PROCRUN_H_INCLUDE
11 #define GUARD_PROCRUN_H_INCLUDE
12 
13 #include <procrun/procrun-config.h>
14 
15 #include <QList>
16 #include <QProcess>
17 #include <QDateTime>
18 #include <QEventLoop>
19 
21 class PROCRUN_EXPORT ProcRun : public QProcess {
22  Q_OBJECT
23 
24 public:
25 
27  ProcRun ();
28 
30  virtual ~ProcRun();
31 
32  qint64
33  runDuration() const {
34  return end_time_.secsTo (start_time_);
35  }
36 
37  void perform (
38  const QStringList & input);
39 
40  int durationInSeconds () {
41  return end_time_.secsTo (start_time_);
42  }
43 
44  int durationInMiliSeconds () {
45  return end_time_.msecsTo (start_time_);
46  }
47 
48 private slots:
49 
50  void
51  errorSlot (
52  QProcess::ProcessError error);
53 
54  void
55  finishedSlot (
56  int exitCode,
57  QProcess::ExitStatus exitStatus);
58 
59  void
60  readyReadStandardErrorSlot ();
61 
62  void
63  readyReadStandardOutputSlot ();
64 
65  void
66  startedSlot ();
67 
68  void
69  stateChangedSlot (
70  QProcess::ProcessState newState);
71 
72 public:
73 
74  QDateTime start_time_;
75  QDateTime end_time_;
76  QString std_err_output_;
77  QString std_out_output_;
78  QString all_output_;
79  bool b_started_;
80  QList<QProcess::ProcessError> errors_;
81  QList<QProcess::ProcessState> states_;
82 
83 private:
84  QEventLoop ev_loop_;
85 
86 };
87 
88 #endif // GUARD_PROCRUN_H_INCLUDE
Helper class to run a process.
Definition: procrun.h:21