twa_run: keep a pointer to the automaton

This simplify all laters invocations, because we do not have to pass
the automaton the run was generated on.

This fixes #113 by allowing the __str__ function to be implemented on
runs.

* src/twaalgos/emptiness.cc, src/twaalgos/emptiness.hh (twa_run):
Store the automaton.
(prin_twa_run): Rewrite as an overloaded <<.
* src/twaalgos/reducerun.cc, src/twaalgos/reducerun.hh (reduce_run):
Do not like the automaton as a parameter.
* src/twaalgos/replayrun.cc, src/twaalgos/replayrun.hh (replay_twa_run):
Likewise.
* src/bin/common_aoutput.hh, src/bin/ltlcross.cc,
src/tests/complementation.cc, src/tests/ikwiad.cc,
src/tests/randtgba.cc, src/twaalgos/gtec/ce.cc, src/twaalgos/gv04.cc,
src/twaalgos/magic.cc, src/twaalgos/ndfs_result.hxx,
src/twaalgos/se05.cc, src/twaalgos/projrun.cc: Adjust.
* wrap/python/ajax/spotcgi.in: Add a __str__ function to twa_run_ptr.
* wrap/python/spot_impl.i: Adjust.
This commit is contained in:
Alexandre Duret-Lutz 2015-10-25 11:58:14 +01:00
parent e7cc89264a
commit 63917def2d
19 changed files with 85 additions and 97 deletions

View file

@ -47,16 +47,15 @@ namespace spot
twa_run::twa_run(const twa_run& run)
{
for (steps::const_iterator i = run.prefix.begin();
i != run.prefix.end(); ++i)
aut = run.aut;
for (step s : run.prefix)
{
step s = { i->s->clone(), i->label, i->acc };
s.s = s.s->clone();
prefix.push_back(s);
}
for (steps::const_iterator i = run.cycle.begin();
i != run.cycle.end(); ++i)
for (step s : run.cycle)
{
step s = { i->s->clone(), i->label, i->acc };
s.s = s.s->clone();
cycle.push_back(s);
}
}
@ -72,37 +71,27 @@ namespace spot
return *this;
}
// print_twa_run
//////////////////////////////////////////////////////////////////////
std::ostream&
print_twa_run(std::ostream& os,
const const_twa_ptr& a,
const const_twa_run_ptr& run)
operator<<(std::ostream& os, const twa_run_ptr& run)
{
auto& a = run->aut;
bdd_dict_ptr d = a->get_dict();
auto pstep = [&](const twa_run::step& st)
{
os << " " << a->format_state(st.s) << "\n | ";
bdd_print_formula(os, d, st.label);
if (st.acc)
os << '\t' << st.acc;
os << '\n';
};
os << "Prefix:" << std::endl;
for (twa_run::steps::const_iterator i = run->prefix.begin();
i != run->prefix.end(); ++i)
{
os << " " << a->format_state(i->s) << std::endl;
os << " | ";
bdd_print_formula(os, d, i->label);
os << '\t';
os << a->acc().format(i->acc);
os << std::endl;
}
for (auto& s: run->prefix)
pstep(s);
os << "Cycle:" << std::endl;
for (twa_run::steps::const_iterator i = run->cycle.begin();
i != run->cycle.end(); ++i)
{
os << " " << a->format_state(i->s) << std::endl;
os << " | ";
bdd_print_formula(os, d, i->label);
os << '\t';
os << a->acc().format(i->acc);
os << '\n';
}
for (auto& s: run->cycle)
pstep(s);
return os;
}