]> git.cworth.org Git - apitrace/blob - gui/retracer.h
Merge remote-tracking branch 'origin/master' into on-demand-loading
[apitrace] / gui / retracer.h
1 #ifndef RETRACER_H
2 #define RETRACER_H
3
4 #include <QThread>
5 #include <QProcess>
6
7 class ApiTraceState;
8 namespace QJson {
9     class Parser;
10 }
11
12 struct RetraceError {
13     int callIndex;
14     QString type;
15     QString message;
16 };
17
18 /* internal class used by the retracer to run
19  * in the thread */
20 class RetraceProcess : public QObject
21 {
22     Q_OBJECT
23 public:
24     RetraceProcess(QObject *parent=0);
25     ~RetraceProcess();
26
27     QProcess *process() const;
28
29     QString fileName() const;
30     void setFileName(const QString &name);
31
32     bool isBenchmarking() const;
33     void setBenchmarking(bool bench);
34
35     bool isDoubleBuffered() const;
36     void setDoubleBuffered(bool db);
37
38     void setCaptureAtCallNumber(qlonglong num);
39     qlonglong captureAtCallNumber() const;
40
41     bool captureState() const;
42     void setCaptureState(bool enable);
43
44 public slots:
45     void start();
46     void terminate();
47
48 signals:
49     void finished(const QString &output);
50     void error(const QString &msg);
51     void foundState(ApiTraceState *state);
52     void retraceErrors(const QList<RetraceError> &errors);
53
54 private slots:
55     void replayFinished();
56     void replayError(QProcess::ProcessError err);
57
58 private:
59     QString m_fileName;
60     bool m_benchmarking;
61     bool m_doubleBuffered;
62     bool m_captureState;
63     qlonglong m_captureCall;
64
65     QProcess *m_process;
66     QJson::Parser *m_jsonParser;
67 };
68
69 class Retracer : public QThread
70 {
71     Q_OBJECT
72 public:
73     Retracer(QObject *parent=0);
74
75     QString fileName() const;
76     void setFileName(const QString &name);
77
78     bool isBenchmarking() const;
79     void setBenchmarking(bool bench);
80
81     bool isDoubleBuffered() const;
82     void setDoubleBuffered(bool db);
83
84     void setCaptureAtCallNumber(qlonglong num);
85     qlonglong captureAtCallNumber() const;
86
87     bool captureState() const;
88     void setCaptureState(bool enable);
89
90 signals:
91     void finished(const QString &output);
92     void foundState(ApiTraceState *state);
93     void error(const QString &msg);
94     void retraceErrors(const QList<RetraceError> &errors);
95
96 protected:
97     virtual void run();
98
99 private slots:
100     void cleanup();
101 private:
102     QString m_fileName;
103     bool m_benchmarking;
104     bool m_doubleBuffered;
105     bool m_captureState;
106     qlonglong m_captureCall;
107
108     QProcessEnvironment m_processEnvironment;
109 };
110
111 #endif