]> git.cworth.org Git - apitrace/blobdiff - gui/retracer.h
Replay and parse json in a thread.
[apitrace] / gui / retracer.h
index 37502e45b79e5d580396c2eb34db1bb4df592ac5..617861e6cdc4e314c752410238f040f178aced08 100644 (file)
@@ -1,14 +1,24 @@
 #ifndef RETRACER_H
 #define RETRACER_H
 
-#include <QObject>
+#include <QThread>
 #include <QProcess>
 
-class Retracer : public QObject
+class ApiTraceState;
+namespace QJson {
+    class Parser;
+}
+
+/* internal class used by the retracer to run
+ * in the thread */
+class RetraceProcess : public QObject
 {
     Q_OBJECT
 public:
-    Retracer(QObject *parent=0);
+    RetraceProcess(QObject *parent=0);
+    ~RetraceProcess();
+
+    QProcess *process() const;
 
     QString fileName() const;
     void setFileName(const QString &name);
@@ -30,12 +40,14 @@ public slots:
     void terminate();
 
 signals:
-    void finished(const QByteArray &output);
+    void finished(const QString &output);
     void error(const QString &msg);
+    void foundState(const ApiTraceState &state);
 
 private slots:
     void replayFinished();
     void replayError(QProcess::ProcessError err);
+
 private:
     QString m_fileName;
     bool m_benchmarking;
@@ -44,6 +56,48 @@ private:
     qlonglong m_captureCall;
 
     QProcess *m_process;
+    QJson::Parser *m_jsonParser;
+};
+
+class Retracer : public QThread
+{
+    Q_OBJECT
+public:
+    Retracer(QObject *parent=0);
+
+    QString fileName() const;
+    void setFileName(const QString &name);
+
+    bool isBenchmarking() const;
+    void setBenchmarking(bool bench);
+
+    bool isDoubleBuffered() const;
+    void setDoubleBuffered(bool db);
+
+    void setCaptureAtCallNumber(qlonglong num);
+    qlonglong captureAtCallNumber() const;
+
+    bool captureState() const;
+    void setCaptureState(bool enable);
+
+signals:
+    void finished(const QString &output);
+    void foundState(const ApiTraceState &state);
+    void error(const QString &msg);
+
+protected:
+    virtual void run();
+
+private slots:
+    void cleanup();
+private:
+    QString m_fileName;
+    bool m_benchmarking;
+    bool m_doubleBuffered;
+    bool m_captureState;
+    qlonglong m_captureCall;
+
+    QProcessEnvironment m_processEnvironment;
 };
 
 #endif