blob: ca76814c97fabc6237e5373f6f1578c1a14d2f87 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#ifndef NODEDUMPER_H_
#define NODEDUMPER_H_
#include <string>
#include <map>
#include <list>
#include "visitor.h"
#include "nodecache.h"
using std::string;
using std::map;
using std::list;
class NodeDumper : public Visitor
{
public:
NodeDumper() : root(NULL) {}
virtual ~NodeDumper() {}
virtual Response visit(const State &state, const AbstractNode &node);
const string &getDump() const;
const NodeCache<string> &getCache() const { return this->cache; }
void clearCache() { this->cache.clear(); }
// FIXME: Questionable design...
static NodeDumper *dumper() { return global_dumper; }
static void setDumper(NodeDumper *d) { global_dumper = d; }
private:
void handleVisitedChildren(const State &state, const AbstractNode &node);
bool isCached(const AbstractNode &node);
void handleIndent(const State &state);
string dumpChildren(const AbstractNode &node);
string currindent;
const AbstractNode *root;
typedef list<const AbstractNode *> ChildList;
map<int, ChildList> visitedchildren;
NodeCache<string> cache;
static NodeDumper *global_dumper;
};
#endif
|