]> git.cworth.org Git - apitrace/blob - gui/retracer.h
Lookup call state on double-click.
[apitrace] / gui / retracer.h
1 #ifndef RETRACER_H
2 #define RETRACER_H
3
4 #include "trace_api.hpp"
5 #include "apitracecall.h"
6
7 #include <QThread>
8 #include <QProcess>
9
10 class ApiTraceState;
11 namespace QJson {
12     class Parser;
13 }
14
15 /* internal class used by the retracer to run
16  * in the thread */
17 class RetraceProcess : public QObject
18 {
19     Q_OBJECT
20 public:
21     RetraceProcess(QObject *parent=0);
22     ~RetraceProcess();
23
24     QProcess *process() const;
25
26     QString fileName() const;
27     void setFileName(const QString &name);
28
29     void setAPI(trace::API api);
30
31     bool isBenchmarking() const;
32     void setBenchmarking(bool bench);
33
34     bool isDoubleBuffered() const;
35     void setDoubleBuffered(bool db);
36
37     void setCaptureAtCallNumber(qlonglong num);
38     qlonglong captureAtCallNumber() const;
39
40     bool captureState() const;
41     void setCaptureState(bool enable);
42
43 public slots:
44     void start();
45     void terminate();
46
47 signals:
48     void finished(const QString &output);
49     void error(const QString &msg);
50     void foundState(ApiTraceState *state);
51     void retraceErrors(const QList<ApiTraceError> &errors);
52
53 private slots:
54     void replayFinished(int exitCode, QProcess::ExitStatus exitStatus);
55     void replayError(QProcess::ProcessError err);
56
57 private:
58     QString m_fileName;
59     trace::API m_api;
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     void setAPI(trace::API api);
79
80     bool isBenchmarking() const;
81     void setBenchmarking(bool bench);
82
83     bool isDoubleBuffered() const;
84     void setDoubleBuffered(bool db);
85
86     void setCaptureAtCallNumber(qlonglong num);
87     qlonglong captureAtCallNumber() const;
88
89     bool captureState() const;
90     void setCaptureState(bool enable);
91
92 signals:
93     void finished(const QString &output);
94     void foundState(ApiTraceState *state);
95     void error(const QString &msg);
96     void retraceErrors(const QList<ApiTraceError> &errors);
97
98 protected:
99     virtual void run();
100
101 private slots:
102     void cleanup();
103 private:
104     QString m_fileName;
105     trace::API m_api;
106     bool m_benchmarking;
107     bool m_doubleBuffered;
108     bool m_captureState;
109     qlonglong m_captureCall;
110
111     QProcessEnvironment m_processEnvironment;
112 };
113
114 #endif