summaryrefslogtreecommitdiff
path: root/src/nodedumper.h
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2010-04-12 00:16:36 (GMT)
committerMarius Kintel <marius@kintel.net>2010-10-31 00:42:35 (GMT)
commite8e213b3c9ce0580045ea6e7e86b00ab41d4c58b (patch)
treecb32e67b6334aa1f1dc62aa4a0686a22782e7f77 /src/nodedumper.h
parent53a9953b7dc4ab4a366046c91529b32fb6652551 (diff)
Another refactoring session:
o mk_cache_id() obsoleted by removing the node index from the dump o node index output removed from each node and make optional in NodeDumper o The visitors are no longer global, but associated with a tree o Added Tree class to manage node trees and the (now implicit) dump cache o Moved PolySet cache into PolySetRenderer
Diffstat (limited to 'src/nodedumper.h')
-rw-r--r--src/nodedumper.h20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/nodedumper.h b/src/nodedumper.h
index ca76814..fceaacb 100644
--- a/src/nodedumper.h
+++ b/src/nodedumper.h
@@ -14,31 +14,27 @@ using std::list;
class NodeDumper : public Visitor
{
public:
- NodeDumper() : root(NULL) {}
+ /*! If idPrefix is true, we will output "n<id>:" in front of each node,
+ which is useful for debugging. */
+ NodeDumper(NodeCache &cache, bool idPrefix = false) :
+ cache(cache), idprefix(idPrefix), 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);
+ bool isCached(const AbstractNode &node) const;
void handleIndent(const State &state);
string dumpChildren(const AbstractNode &node);
+ NodeCache &cache;
+ bool idprefix;
+
string currindent;
const AbstractNode *root;
typedef list<const AbstractNode *> ChildList;
map<int, ChildList> visitedchildren;
- NodeCache<string> cache;
-
- static NodeDumper *global_dumper;
};
#endif
contact: Jan Huwald // Impressum