]> git.cworth.org Git - apitrace/blobdiff - trace_model.hpp
Delete loadertest and cleanup some of the new api.
[apitrace] / trace_model.hpp
index 03a23894cc41f8fce08f50575752e6e905160075..a74508efc5e0a0fc2411f9fe19b3e1aea070beda 100644 (file)
 #include <assert.h>
 
 #include <map>
-#include <list>
 #include <vector>
 #include <iostream>
 
-#include "trace_writer.hpp"
-
 
 namespace Trace {
 
 
+typedef unsigned Id;
+
+
+struct FunctionSig {
+    Id id;
+    const char *name;
+    unsigned num_args;
+    const char **arg_names;
+};
+
+
+struct StructSig {
+    Id id;
+    const char *name;
+    unsigned num_members;
+    const char **member_names;
+};
+
+
+struct EnumSig {
+    Id id;
+    const char *name;
+    signed long long value;
+};
+
+
+struct BitmaskFlag {
+    const char *name;
+    unsigned long long value;
+};
+
+
+struct BitmaskSig {
+    Id id;
+    unsigned num_flags;
+    const BitmaskFlag *flags;
+};
+
+
 class Visitor;
 
 
@@ -60,10 +96,13 @@ public:
     virtual double toDouble(void) const;
 
     virtual void *toPointer(void) const;
+    virtual void *toPointer(bool bind);
     virtual unsigned long long toUIntPtr(void) const;
     virtual const char *toString(void) const;
 
     const Value & operator[](size_t index) const;
+
+    void dump(std::ostream &os, bool color=true);
 };
 
 
@@ -76,6 +115,7 @@ public:
     virtual float toFloat(void) const;
     virtual double toDouble(void) const;
     void *toPointer(void) const;
+    void *toPointer(bool bind);
     unsigned long long toUIntPtr(void) const;
     const char *toString(void) const;
     void visit(Visitor &visitor);
@@ -150,6 +190,7 @@ class String : public Value
 {
 public:
     String(const char * _value) : value(_value) {}
+    ~String();
 
     bool toBool(void) const;
     const char *toString(void) const;
@@ -219,16 +260,19 @@ public:
     Blob(size_t _size) {
         size = _size;
         buf = new char[_size];
+        bound = false;
     }
 
     ~Blob();
 
     bool toBool(void) const;
     void *toPointer(void) const;
+    void *toPointer(bool bind);
     void visit(Visitor &visitor);
 
     size_t size;
     char *buf;
+    bool bound;
 };
 
 
@@ -239,6 +283,7 @@ public:
 
     bool toBool(void) const;
     void *toPointer(void) const;
+    void *toPointer(bool bind);
     unsigned long long toUIntPtr(void) const;
     void visit(Visitor &visitor);
 };
@@ -269,7 +314,12 @@ protected:
 };
 
 
-std::ostream & operator <<(std::ostream &os, Value *value);
+inline std::ostream & operator <<(std::ostream &os, Value *value) {
+    if (value) {
+        value->dump(os);
+    }
+    return os;
+}
 
 
 class Call
@@ -291,10 +341,15 @@ public:
         assert(index < args.size());
         return *(args[index]);
     }
+
+    void dump(std::ostream &os, bool color=true);
 };
 
 
-std::ostream & operator <<(std::ostream &os, Call &call);
+inline std::ostream & operator <<(std::ostream &os, Call &call) {
+    call.dump(os);
+    return os;
+}
 
 
 } /* namespace Trace */