]> git.cworth.org Git - apitrace/blobdiff - retrace.hpp
Fix a crash when loading multiple frames at once.
[apitrace] / retrace.hpp
index 56fc330e74316d82f64a175c3af963c12334bb4c..b697adb6b2c7fa7495be034f831c1f47d23b025f 100644 (file)
@@ -26,6 +26,8 @@
 #ifndef _RETRACE_HPP_
 #define _RETRACE_HPP_
 
+#include <string.h>
+
 #include <map>
 
 #include "trace_model.hpp"
@@ -82,11 +84,44 @@ public:
 extern int verbosity;
 
 
-void retrace_call(Trace::Call &call);
-
+void ignore(Trace::Call &call);
 void retrace_unknown(Trace::Call &call);
 
 
+typedef void (*Callback)(Trace::Call &call);
+
+struct Entry {
+    const char *name;
+    Callback callback;
+};
+
+
+struct stringComparer {
+  bool operator() (const char *a, const  char *b) const {
+    return strcmp(a, b) < 0;
+  }
+};
+
+
+class Retracer
+{
+    typedef std::map<const char *, Callback, stringComparer> Map;
+    Map map;
+
+    std::vector<Callback> callbacks;
+
+public:
+    Retracer() {}
+
+    virtual ~Retracer() {}
+
+    void addCallback(const Entry *entry);
+    void addCallbacks(const Entry *entries);
+
+    void retrace(Trace::Call &call);
+};
+
+
 } /* namespace retrace */
 
 #endif /* _RETRACE_HPP_ */