1 /**************************************************************************
3 * Copyright 2010 VMware, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 **************************************************************************/
26 #ifndef _TRACE_MODEL_HPP_
27 #define _TRACE_MODEL_HPP_
50 virtual void visit(Visitor &visitor) = 0;
54 class Void : public Value
57 void visit(Visitor &visitor);
61 class Bool : public Value
64 Bool(bool _value) : value(_value) {}
66 void visit(Visitor &visitor);
72 class SInt : public Value
75 SInt(signed long long _value) : value(_value) {}
77 void visit(Visitor &visitor);
79 signed long long value;
83 class UInt : public Value
86 UInt(unsigned long long _value) : value(_value) {}
88 void visit(Visitor &visitor);
90 unsigned long long value;
94 class Float : public Value
97 Float(double _value) : value(_value) {}
99 void visit(Visitor &visitor);
105 class String : public Value
108 String(std::string _value) : value(_value) {}
110 void visit(Visitor &visitor);
116 class Const : public Value
119 Const(std::string _name, Value *_value) : name(_name), value(_value) {}
121 void visit(Visitor &visitor);
128 class Array : public Value
131 Array(size_t len) : values(len) {}
133 void visit(Visitor &visitor);
135 std::vector<Value *> values;
142 virtual void visit(Void *) {assert(0);}
143 virtual void visit(Bool *) {assert(0);}
144 virtual void visit(SInt *) {assert(0);}
145 virtual void visit(UInt *) {assert(0);}
146 virtual void visit(Float *) {assert(0);}
147 virtual void visit(String *) {assert(0);}
148 virtual void visit(Const *) {assert(0);}
149 virtual void visit(Array *) {assert(0);}
153 std::ostream & operator <<(std::ostream &os, Value *value);
156 signed long long asSInt(const Value &node);
157 unsigned long long asUInt(const Value &node);
158 double asFloat(const Value &node);
161 typedef std::pair<std::string, Value *> Arg;
172 Value & arg(const char *name);
177 std::ostream & operator <<(std::ostream &os, Call &call);
180 } /* namespace Trace */
182 #endif /* _TRACE_MODEL_HPP_ */