00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef VCSN_TOOLS_FSM_DUMP_HXX
00018 # define VCSN_TOOLS_FSM_DUMP_HXX
00019
00020 # include <vaucanson/tools/fsm_dump.hh>
00021 # include <map>
00022 # include <set>
00023 # include <vaucanson/automata/concept/handlers.hh>
00024 # include <vaucanson/misc/usual_macros.hh>
00025 # include <vaucanson/automata/concept/automata_base.hh>
00026
00027 namespace vcsn {
00028
00029 namespace tools {
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 template <typename St, typename auto_t>
00041 void fsm_dump(St& out, const auto_t& a)
00042 {
00043 AUTOMATON_TYPES(auto_t);
00044 if (a.initial().size() > 1)
00045 {
00046 auto_t b(a);
00047 hstate_t i = b.add_state();
00048 for_all_initial_states(j, b)
00049 b.add_spontaneous(i, *j);
00050 b.clear_initial();
00051 b.set_initial(i);
00052 fsm_dump(out, b);
00053 return ;
00054 }
00055 if (a.states().size() == 0)
00056 return;
00057
00058 typename auto_t::initial_iterator initial = a.initial().begin();
00059 std::set<htransition_t> succ;
00060
00061 a.deltac(succ, *initial, delta_kind::transitions());
00062 for_all_const_(std::set<htransition_t>, e, succ)
00063 out << *initial << "\t" << a.dst_of(*e) << "\t"
00064 << a.series_of(*e) << "\t 0"
00065 << std::endl;
00066 for_all_states(s, a)
00067 if (!a.is_initial(*s))
00068 {
00069 succ.clear();
00070 a.deltac(succ, *s, delta_kind::transitions());
00071 for_all_const_(std::set<htransition_t>, e, succ)
00072 out << *s << "\t" << a.dst_of(*e) << "\t"
00073 << a.series_of(*e) << "\t 0"
00074 << std::endl;
00075 }
00076 for_all_final_states(f, a)
00077 out << *f << "\t 0" << std::endl;
00078 }
00079
00080 }
00081
00082 }
00083
00084 #endif // ! VCSN_TOOLS_FSM_DUMP_HXX