Inferno  0.2
graph.hpp
Go to the documentation of this file.
00001 #ifndef GRAPH_HPP
00002 #define GRAPH_HPP
00003 
00004 #include "tree/cpptree.hpp"
00005 #include "helpers/transformation.hpp"
00006 
00007 //
00008 // Generate a GraphViz compatible graph description from a subtree (when used as a
00009 // Transformation) or a search/replace pattern set.
00010 //
00011 class CompareReplace;
00012 class Graph : public OutOfPlaceTransformation
00013 {
00014 public:
00015     Graph( string of = string() );
00016   using Transformation::operator();
00017     void operator()( Transformation *root ); // Graph the search/replace pattern
00018     TreePtr<Node> operator()( TreePtr<Node> context, TreePtr<Node> root ); // graph the subtree under root node
00019 private:
00020     string Header();
00021     string Footer();
00022     string MakeGraphTx(Transformation *root);
00023     void Disburse( string s );
00024     string UniqueWalk( TreePtr<Node> root, bool links_pass );
00025     string UniqueWalk( Transformation *sr, string id, bool links_pass );
00026   string DoTransformation( Transformation *sr, string id );
00027   string DoTransformationLinks( Transformation *sr, string id );
00028     string Id( void *p );
00029     string SeqField( int i, int j=0 );
00030     string Sanitise( string s, bool remove_tp=false );
00031     string Name( TreePtr<Node> sp, bool *bold, string *shape );   // TODO put stringize capabilities into the Property nodes as virtual methods
00032     string Colour( TreePtr<Node> n );
00033     string HTMLLabel( string name, TreePtr<Node> n );
00034     string SimpleLabel( string name, TreePtr<Node> n );
00035     string DoNode( TreePtr<Node> n );
00036     string DoNodeLinks( TreePtr<Node> n );
00037     bool IsRecord( TreePtr<Node> n );
00038     string DoLink( TreePtr<Node> from, string field, TreePtr<Node> to, string atts=string(), const TreePtrInterface *ptr=NULL );
00039     UniqueFilter unique_filter;
00040     const string outfile; // empty means stdout
00041 };
00042 
00043 #endif