Use shared_ptr for the emptiness check interfaces.
At the same time, this adds a is_empty() method to the tgba class, simplifying many places that ran emptiness checks. * iface/dve2/dve2check.cc, src/bin/ltlcross.cc, src/dstarparse/dra2ba.cc, src/ltlvisit/contain.cc, src/tgba/tgba.cc, src/tgba/tgba.hh, src/tgbaalgos/emptiness.cc, src/tgbaalgos/emptiness.hh, src/tgbaalgos/gtec/ce.cc, src/tgbaalgos/gtec/ce.hh, src/tgbaalgos/gtec/gtec.cc, src/tgbaalgos/gtec/gtec.hh, src/tgbaalgos/gv04.cc, src/tgbaalgos/gv04.hh, src/tgbaalgos/magic.cc, src/tgbaalgos/magic.hh, src/tgbaalgos/minimize.cc, src/tgbaalgos/ndfs_result.hxx, src/tgbaalgos/powerset.cc, src/tgbaalgos/projrun.cc, src/tgbaalgos/projrun.hh, src/tgbaalgos/reducerun.cc, src/tgbaalgos/reducerun.hh, src/tgbaalgos/replayrun.cc, src/tgbaalgos/replayrun.hh, src/tgbaalgos/rundotdec.cc, src/tgbaalgos/rundotdec.hh, src/tgbaalgos/se05.cc, src/tgbaalgos/se05.hh, src/tgbaalgos/tau03.cc, src/tgbaalgos/tau03.hh, src/tgbaalgos/tau03opt.cc, src/tgbaalgos/tau03opt.hh, src/tgbaalgos/word.cc, src/tgbaalgos/word.hh, src/tgbatest/checkpsl.cc, src/tgbatest/complementation.cc, src/tgbatest/emptchk.cc, src/tgbatest/ltl2tgba.cc, src/tgbatest/randtgba.cc, wrap/python/ajax/spot.in, wrap/python/spot.i: Use shared_ptr.
This commit is contained in:
parent
803e17bb8d
commit
6d7c258fd7
42 changed files with 335 additions and 402 deletions
|
|
@ -88,8 +88,10 @@ namespace spot
|
|||
/// check() can be called several times (until it returns a null
|
||||
/// pointer) to enumerate all the visited accepting paths. The method
|
||||
/// visits only a finite set of accepting paths.
|
||||
virtual emptiness_check_result* check()
|
||||
virtual emptiness_check_result_ptr check()
|
||||
{
|
||||
auto t = std::static_pointer_cast<magic_search_>
|
||||
(this->emptiness_check::shared_from_this());
|
||||
if (st_red.empty())
|
||||
{
|
||||
assert(st_blue.empty());
|
||||
|
|
@ -98,19 +100,19 @@ namespace spot
|
|||
h.add_new_state(s0, BLUE);
|
||||
push(st_blue, s0, bddfalse, bddfalse);
|
||||
if (dfs_blue())
|
||||
return new magic_search_result(*this, options());
|
||||
return std::make_shared<magic_search_result>(t, options());
|
||||
}
|
||||
else
|
||||
{
|
||||
h.pop_notify(st_red.front().s);
|
||||
pop(st_red);
|
||||
if (!st_red.empty() && dfs_red())
|
||||
return new magic_search_result(*this, options());
|
||||
return std::make_shared<magic_search_result>(t, options());
|
||||
else
|
||||
if (dfs_blue())
|
||||
return new magic_search_result(*this, options());
|
||||
return std::make_shared<magic_search_result>(t, options());
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual std::ostream& print_stats(std::ostream &os) const
|
||||
|
|
@ -325,25 +327,25 @@ namespace spot
|
|||
public acss_statistics
|
||||
{
|
||||
public:
|
||||
result_from_stack(magic_search_& ms)
|
||||
: emptiness_check_result(ms.automaton()), ms_(ms)
|
||||
result_from_stack(std::shared_ptr<magic_search_> ms)
|
||||
: emptiness_check_result(ms->automaton()), ms_(ms)
|
||||
{
|
||||
}
|
||||
|
||||
virtual tgba_run* accepting_run()
|
||||
virtual tgba_run_ptr accepting_run()
|
||||
{
|
||||
assert(!ms_.st_blue.empty());
|
||||
assert(!ms_.st_red.empty());
|
||||
assert(!ms_->st_blue.empty());
|
||||
assert(!ms_->st_red.empty());
|
||||
|
||||
tgba_run* run = new tgba_run;
|
||||
auto run = std::make_shared<tgba_run>();
|
||||
|
||||
typename stack_type::const_reverse_iterator i, j, end;
|
||||
tgba_run::steps* l;
|
||||
|
||||
l = &run->prefix;
|
||||
|
||||
i = ms_.st_blue.rbegin();
|
||||
end = ms_.st_blue.rend(); --end;
|
||||
i = ms_->st_blue.rbegin();
|
||||
end = ms_->st_blue.rend(); --end;
|
||||
j = i; ++j;
|
||||
for (; i != end; ++i, ++j)
|
||||
{
|
||||
|
|
@ -353,12 +355,12 @@ namespace spot
|
|||
|
||||
l = &run->cycle;
|
||||
|
||||
j = ms_.st_red.rbegin();
|
||||
j = ms_->st_red.rbegin();
|
||||
tgba_run::step s = { i->s->clone(), j->label, j->acc };
|
||||
l->push_back(s);
|
||||
|
||||
i = j; ++j;
|
||||
end = ms_.st_red.rend(); --end;
|
||||
end = ms_->st_red.rend(); --end;
|
||||
for (; i != end; ++i, ++j)
|
||||
{
|
||||
tgba_run::step s = { i->s->clone(), j->label, j->acc };
|
||||
|
|
@ -373,7 +375,7 @@ namespace spot
|
|||
return 0;
|
||||
}
|
||||
private:
|
||||
magic_search_& ms_;
|
||||
std::shared_ptr<magic_search_> ms_;
|
||||
};
|
||||
|
||||
# define FROM_STACK "ar:from_stack"
|
||||
|
|
@ -381,8 +383,9 @@ namespace spot
|
|||
class magic_search_result: public emptiness_check_result
|
||||
{
|
||||
public:
|
||||
magic_search_result(magic_search_& m, option_map o = option_map())
|
||||
: emptiness_check_result(m.automaton(), o), ms(m)
|
||||
magic_search_result(const std::shared_ptr<magic_search_>& m,
|
||||
option_map o = option_map())
|
||||
: emptiness_check_result(m->automaton(), o), ms(m)
|
||||
{
|
||||
if (options()[FROM_STACK])
|
||||
computer = new result_from_stack(ms);
|
||||
|
|
@ -409,7 +412,7 @@ namespace spot
|
|||
delete computer;
|
||||
}
|
||||
|
||||
virtual tgba_run* accepting_run()
|
||||
virtual tgba_run_ptr accepting_run()
|
||||
{
|
||||
return computer->accepting_run();
|
||||
}
|
||||
|
|
@ -421,7 +424,7 @@ namespace spot
|
|||
|
||||
private:
|
||||
emptiness_check_result* computer;
|
||||
magic_search_& ms;
|
||||
std::shared_ptr<magic_search_> ms;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -584,18 +587,20 @@ namespace spot
|
|||
|
||||
} // anonymous
|
||||
|
||||
emptiness_check* explicit_magic_search(const const_tgba_ptr& a, option_map o)
|
||||
emptiness_check_ptr
|
||||
explicit_magic_search(const const_tgba_ptr& a, option_map o)
|
||||
{
|
||||
return new magic_search_<explicit_magic_search_heap>(a, 0, o);
|
||||
return std::make_shared<magic_search_<explicit_magic_search_heap>>(a, 0, o);
|
||||
}
|
||||
|
||||
emptiness_check* bit_state_hashing_magic_search(const const_tgba_ptr& a,
|
||||
size_t size, option_map o)
|
||||
emptiness_check_ptr
|
||||
bit_state_hashing_magic_search(const const_tgba_ptr& a,
|
||||
size_t size, option_map o)
|
||||
{
|
||||
return new magic_search_<bsh_magic_search_heap>(a, size, o);
|
||||
return std::make_shared<magic_search_<bsh_magic_search_heap>>(a, size, o);
|
||||
}
|
||||
|
||||
emptiness_check*
|
||||
emptiness_check_ptr
|
||||
magic_search(const const_tgba_ptr& a, option_map o)
|
||||
{
|
||||
size_t size = o.get("bsh");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue