metaSMT git

metaSMT/support/dot_SMT_Graph.hpp

Go to the documentation of this file.
00001 #pragma once
00002 
00003 #include "SMT_Graph.hpp"
00004 #include <boost/graph/graphviz.hpp>
00005 #include <boost/variant.hpp>
00006 #include <boost/tuple/tuple_io.hpp>
00007 #include <ostream>
00008 
00009 namespace metaSMT {
00010 
00011   struct VertexDecorator
00012   {
00013     typedef void result_type;
00014     typedef boost::graph_traits<SMT_Graph>::vertex_descriptor VertexT;
00015 
00016     VertexDecorator( const SMT_Graph & g, VertexT const & v , std::ostream & out)
00017       : _g(g), _v(v), out(out) {}
00018 
00019     void operator()(logic::QF_BV::tag::bvbin_tag const &) {
00020       using namespace boost;
00021       out << "[ label=\"";
00022       out << "bvbin(" << any_cast<std::string>(get(vertex_arg, _g, _v)) << ")";
00023       out << "\"]";
00024     }
00025 
00026     void operator()(logic::QF_BV::tag::bvhex_tag const &) {
00027       using namespace boost;
00028       out << "[ label=\"";
00029       out << "bvhex(" << any_cast<std::string>(get(vertex_arg, _g, _v)) << ")";
00030       out << "\"]";
00031     }
00032 
00033     void operator()(logic::QF_BV::tag::bvuint_tag const &) {
00034       using namespace boost;
00035       out << "[ label=\"";
00036       out << "bvuint" << any_cast<tuple< unsigned long, unsigned long> >(get(vertex_arg, _g, _v));
00037       out << "\"]";
00038     }
00039 
00040     void operator()(logic::QF_BV::tag::bvsint_tag const &) {
00041       using namespace boost;
00042       out << "[ label=\"";
00043       out << "bvsint" << any_cast<tuple< long, unsigned long> >(get(vertex_arg, _g, _v));
00044       out << "\"]";
00045     }
00046 
00047     template <typename Tag>
00048     void operator()(Tag const & t ){
00049       using namespace boost;
00050       out << "[ label=\"" << out << "\"]";
00051     }
00052 
00053     private:
00054       const SMT_Graph & _g;
00055       const VertexT & _v;
00056       std::ostream & out;
00057   };
00058 
00059   struct DotDecorator {
00060     DotDecorator(const SMT_Graph & g) 
00061       : _g(g) { }
00062 
00063     typedef boost::graph_traits<SMT_Graph>::vertex_descriptor VertexT;
00064     typedef boost::graph_traits<SMT_Graph>::edge_descriptor   EdgeT;
00065 
00066     void operator()(std::ostream & out, VertexT n ) {
00067       VertexDecorator vd(_g, n, out);
00068       boost::apply_visitor(vd, boost::get(boost::vertex_tag, _g, n) );
00069     }
00070 
00071     void operator()(std::ostream & out, EdgeT e){
00072       using namespace boost;
00073       out << "[ label=\"";
00074       out << "IN: " << get(edge_input, _g, e);
00075       out << "\"]";
00076     }
00077 
00078     template <typename T2>
00079     void operator()(std::ostream & out, T2) const{
00080     }
00081 
00082     private:
00083     SMT_Graph const & _g;
00084   };
00085 
00086 
00087   inline void write_dot(std::ostream & out, SMT_Graph & g) {
00088     DotDecorator dotDecorator(g);
00089     write_graphviz(out, g, dotDecorator, dotDecorator);
00090   }
00091 
00092 } // namespace metaSMT
00093 //  vim: ft=cpp:ts=2:sw=2:expandtab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines