00001 // This file is part of jdl_parser. 00002 // 00003 // jdl_parser is free software: you can redistribute it and/or modify 00004 // it under the terms of the GNU General Public License as published by 00005 // the Free Software Foundation, either version 3 of the License, or 00006 // (at your option) any later version. 00007 // 00008 // jdl_parser is distributed in the hope that it will be useful, 00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 // GNU General Public License for more details. 00012 // 00013 // You should have received a copy of the GNU General Public License 00014 // along with jdl_parser. If not, see <http://www.gnu.org/licenses/>. 00015 00016 // Copyright Simone Pellegrini 2007-2008; e-mail: motonacciu@gmail.com 00017 00018 #ifndef DAG_VISITOR_HPP_ 00019 #define DAG_VISITOR_HPP_ 00020 00021 #include "graph_node.hpp" 00022 00023 namespace graph{ 00024 00025 class const_visitor{ 00026 public: 00027 virtual void visit(node const& node) = 0; 00028 virtual ~const_visitor(){} 00029 }; 00030 00031 class visitor{ 00032 public: 00033 virtual void visit(node& node) = 0; 00034 virtual ~visitor(){} 00035 }; 00036 00037 class dump_visitor : public const_visitor{ 00038 int indentation; 00039 ostream& out; 00040 public: 00041 dump_visitor(int indent_): indentation(indent_), out(cout){} 00042 00043 dump_visitor(int indent_, ostream& out_): indentation(indent_), out(out_){} 00044 00045 void visit(node const& node); 00046 00047 ~dump_visitor(){} 00048 }; 00049 00050 class acyclic_visitor : public const_visitor{ 00051 std::vector<std::string> nodes; 00052 public: 00053 void visit(node const& node); 00054 00055 ~acyclic_visitor(){} 00056 }; 00057 00058 } 00059 00060 #endif /*DAG_VISITOR_HPP_*/