blob: 617861e6cdc4e314c752410238f040f178aced08 [file] [log] [blame]
Zack Rusin3acde362011-04-06 01:11:55 -04001#ifndef RETRACER_H
2#define RETRACER_H
3
Zack Rusinf389ae82011-04-10 19:27:28 -04004#include <QThread>
Zack Rusin3acde362011-04-06 01:11:55 -04005#include <QProcess>
6
Zack Rusinf389ae82011-04-10 19:27:28 -04007class ApiTraceState;
8namespace QJson {
9 class Parser;
10}
11
12/* internal class used by the retracer to run
13 * in the thread */
14class RetraceProcess : public QObject
Zack Rusin3acde362011-04-06 01:11:55 -040015{
16 Q_OBJECT
17public:
Zack Rusinf389ae82011-04-10 19:27:28 -040018 RetraceProcess(QObject *parent=0);
19 ~RetraceProcess();
20
21 QProcess *process() const;
Zack Rusin3acde362011-04-06 01:11:55 -040022
23 QString fileName() const;
24 void setFileName(const QString &name);
25
26 bool isBenchmarking() const;
27 void setBenchmarking(bool bench);
28
29 bool isDoubleBuffered() const;
30 void setDoubleBuffered(bool db);
31
32 void setCaptureAtCallNumber(qlonglong num);
33 qlonglong captureAtCallNumber() const;
34
35 bool captureState() const;
36 void setCaptureState(bool enable);
37
38public slots:
39 void start();
40 void terminate();
41
42signals:
Zack Rusinf389ae82011-04-10 19:27:28 -040043 void finished(const QString &output);
Zack Rusin3acde362011-04-06 01:11:55 -040044 void error(const QString &msg);
Zack Rusinf389ae82011-04-10 19:27:28 -040045 void foundState(const ApiTraceState &state);
Zack Rusin3acde362011-04-06 01:11:55 -040046
47private slots:
48 void replayFinished();
49 void replayError(QProcess::ProcessError err);
Zack Rusinf389ae82011-04-10 19:27:28 -040050
Zack Rusin3acde362011-04-06 01:11:55 -040051private:
52 QString m_fileName;
53 bool m_benchmarking;
54 bool m_doubleBuffered;
55 bool m_captureState;
56 qlonglong m_captureCall;
57
58 QProcess *m_process;
Zack Rusinf389ae82011-04-10 19:27:28 -040059 QJson::Parser *m_jsonParser;
60};
61
62class Retracer : public QThread
63{
64 Q_OBJECT
65public:
66 Retracer(QObject *parent=0);
67
68 QString fileName() const;
69 void setFileName(const QString &name);
70
71 bool isBenchmarking() const;
72 void setBenchmarking(bool bench);
73
74 bool isDoubleBuffered() const;
75 void setDoubleBuffered(bool db);
76
77 void setCaptureAtCallNumber(qlonglong num);
78 qlonglong captureAtCallNumber() const;
79
80 bool captureState() const;
81 void setCaptureState(bool enable);
82
83signals:
84 void finished(const QString &output);
85 void foundState(const ApiTraceState &state);
86 void error(const QString &msg);
87
88protected:
89 virtual void run();
90
91private slots:
92 void cleanup();
93private:
94 QString m_fileName;
95 bool m_benchmarking;
96 bool m_doubleBuffered;
97 bool m_captureState;
98 qlonglong m_captureCall;
99
100 QProcessEnvironment m_processEnvironment;
Zack Rusin3acde362011-04-06 01:11:55 -0400101};
102
103#endif