* src/tgba/bddprint.cc (dict): Make this variable static.
(want_prom): New global static variable. (print_handle): Honor want_prom. (print_sat_handler, bdd_print_sat, bdd_format_sat): New functions. (bdd_print_set, bdd_print_dot, bdd_print_table): Set want_prom. * src/tgba/bddprint.hh (bdd_print_sat, bdd_format_sat): New functions. * src/tgbaalgos/save.cc, src/tgbaalgos/save.hh, src/tgbatest/readsave.cc, src/tgbatest/readsave.test: New files. * src/tgbaalgos/Makefile.am (libtgbaalgos_la_SOURCES): Add save.cc and save.hh. * src/tgbatest/Makefile.am (check_PROGRAMS): Add readsave. (readsave_SOURCES): New variable. (TESTS): Add readsave.test.
This commit is contained in:
parent
6884a7f985
commit
19e47ee6e4
10 changed files with 237 additions and 8 deletions
|
|
@ -4,4 +4,7 @@ AM_CXXFLAGS = $(WARNING_CXXFLAGS)
|
|||
noinst_LTLIBRARIES = libtgbaalgos.la
|
||||
libtgbaalgos_la_SOURCES = \
|
||||
dotty.cc \
|
||||
dotty.hh
|
||||
dotty.hh \
|
||||
save.cc \
|
||||
save.hh
|
||||
|
||||
|
|
|
|||
52
src/tgbaalgos/save.cc
Normal file
52
src/tgbaalgos/save.cc
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
#include <set>
|
||||
#include "tgba/tgba.hh"
|
||||
#include "save.hh"
|
||||
#include "tgba/bddprint.hh"
|
||||
|
||||
namespace spot
|
||||
{
|
||||
typedef std::set<state*, state_ptr_less_than> seen_set;
|
||||
|
||||
/// Process successors.
|
||||
static void
|
||||
save_rec(std::ostream& os, const tgba& g, state* st, seen_set& m)
|
||||
{
|
||||
m.insert(st);
|
||||
std::string cur = g.format_state(st);
|
||||
tgba_succ_iterator* si = g.succ_iter(st);
|
||||
for (si->first(); !si->done(); si->next())
|
||||
{
|
||||
state* s = si->current_state();
|
||||
os << "\"" << cur << "\", \"" << g.format_state(s) << "\", ";
|
||||
|
||||
bdd_print_sat(os, g.get_dict(), si->current_condition()) << ", ";
|
||||
bdd_print_sat(os, g.get_dict(), si->current_promise()) << ";"
|
||||
<< std::endl;
|
||||
|
||||
// Destination already explored?
|
||||
seen_set::iterator i = m.find(s);
|
||||
if (i != m.end())
|
||||
{
|
||||
delete s;
|
||||
}
|
||||
else
|
||||
{
|
||||
save_rec(os, g, s, m);
|
||||
// Do not delete S, it is used as key in M.
|
||||
}
|
||||
}
|
||||
delete si;
|
||||
}
|
||||
|
||||
std::ostream&
|
||||
tgba_save_reachable(std::ostream& os, const tgba& g)
|
||||
{
|
||||
seen_set m;
|
||||
state* state = g.get_init_state();
|
||||
save_rec(os, g, state, m);
|
||||
// Finally delete all states used as keys in m:
|
||||
for (seen_set::iterator i = m.begin(); i != m.end(); ++i)
|
||||
delete *i;
|
||||
return os;
|
||||
}
|
||||
}
|
||||
13
src/tgbaalgos/save.hh
Normal file
13
src/tgbaalgos/save.hh
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#ifndef SPOT_TGBAALGOS_SAVE_HH
|
||||
# define SPOT_TGBAALGOS_SAVE_HH
|
||||
|
||||
#include "tgba/tgba.hh"
|
||||
#include <iostream>
|
||||
|
||||
namespace spot
|
||||
{
|
||||
/// \brief Save reachable states in text format.
|
||||
std::ostream& tgba_save_reachable(std::ostream& os, const tgba& g);
|
||||
}
|
||||
|
||||
#endif // SPOT_TGBAALGOS_SAVE_HH
|
||||
Loading…
Add table
Add a link
Reference in a new issue