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
|
|
@ -32,7 +32,7 @@ namespace spot
|
|||
{
|
||||
public:
|
||||
shortest_path(const state_set* t,
|
||||
const couvreur99_check_status* ecs,
|
||||
const std::shared_ptr<const couvreur99_check_status>& ecs,
|
||||
couvreur99_check_result* r)
|
||||
: bfs_steps(ecs->aut), target(t), ecs(ecs), r(r)
|
||||
{
|
||||
|
|
@ -68,13 +68,14 @@ namespace spot
|
|||
private:
|
||||
state_set seen;
|
||||
const state_set* target;
|
||||
const couvreur99_check_status* ecs;
|
||||
std::shared_ptr<const couvreur99_check_status> ecs;
|
||||
couvreur99_check_result* r;
|
||||
};
|
||||
}
|
||||
|
||||
couvreur99_check_result::couvreur99_check_result
|
||||
(const couvreur99_check_status* ecs, option_map o)
|
||||
(const std::shared_ptr<const couvreur99_check_status>& ecs,
|
||||
option_map o)
|
||||
: emptiness_check_result(ecs->aut, o), ecs_(ecs)
|
||||
{
|
||||
}
|
||||
|
|
@ -90,10 +91,10 @@ namespace spot
|
|||
return count;
|
||||
}
|
||||
|
||||
tgba_run*
|
||||
tgba_run_ptr
|
||||
couvreur99_check_result::accepting_run()
|
||||
{
|
||||
run_ = new tgba_run;
|
||||
run_ = std::make_shared<tgba_run>();
|
||||
|
||||
assert(!ecs_->root.empty());
|
||||
|
||||
|
|
@ -212,7 +213,7 @@ namespace spot
|
|||
return false;
|
||||
}
|
||||
|
||||
} b(ecs_, this, acc_to_traverse);
|
||||
} b(ecs_.get(), this, acc_to_traverse);
|
||||
|
||||
substart = b.search(substart, run_->cycle);
|
||||
assert(substart);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2013 Laboratoire de Recherche et Développement de
|
||||
// Copyright (C) 2013, 2014 Laboratoire de Recherche et Développement de
|
||||
// l'Epita (LRDE).
|
||||
// Copyright (C) 2004, 2005 Laboratoire d'Informatique de Paris 6 (LIP6),
|
||||
// département Systèmes Répartis Coopératifs (SRC), Université Pierre
|
||||
|
|
@ -35,10 +35,11 @@ namespace spot
|
|||
public acss_statistics
|
||||
{
|
||||
public:
|
||||
couvreur99_check_result(const couvreur99_check_status* ecs,
|
||||
couvreur99_check_result(const
|
||||
std::shared_ptr<const couvreur99_check_status>& ecs,
|
||||
option_map o = option_map());
|
||||
|
||||
virtual tgba_run* accepting_run();
|
||||
virtual tgba_run_ptr accepting_run();
|
||||
|
||||
void print_stats(std::ostream& os) const;
|
||||
|
||||
|
|
@ -50,8 +51,8 @@ namespace spot
|
|||
void accepting_cycle();
|
||||
|
||||
private:
|
||||
const couvreur99_check_status* ecs_;
|
||||
tgba_run* run_;
|
||||
std::shared_ptr<const couvreur99_check_status> ecs_;
|
||||
tgba_run_ptr run_;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ namespace spot
|
|||
removed_components(0)
|
||||
{
|
||||
poprem_ = o.get("poprem", 1);
|
||||
ecs_ = new couvreur99_check_status(a);
|
||||
ecs_ = std::make_shared<couvreur99_check_status>(a);
|
||||
stats["removed components"] =
|
||||
static_cast<spot::unsigned_statistics::unsigned_fun>
|
||||
(&couvreur99_check::get_removed_components);
|
||||
|
|
@ -56,7 +56,6 @@ namespace spot
|
|||
|
||||
couvreur99_check::~couvreur99_check()
|
||||
{
|
||||
delete ecs_;
|
||||
}
|
||||
|
||||
unsigned
|
||||
|
|
@ -129,7 +128,7 @@ namespace spot
|
|||
}
|
||||
}
|
||||
|
||||
emptiness_check_result*
|
||||
emptiness_check_result_ptr
|
||||
couvreur99_check::check()
|
||||
{
|
||||
// We use five main data in this algorithm:
|
||||
|
|
@ -281,15 +280,15 @@ namespace spot
|
|||
// cycle.
|
||||
ecs_->cycle_seed = p.first->first;
|
||||
set_states(ecs_->states());
|
||||
return new couvreur99_check_result(ecs_, options());
|
||||
return std::make_shared<couvreur99_check_result>(ecs_, options());
|
||||
}
|
||||
}
|
||||
// This automaton recognizes no word.
|
||||
set_states(ecs_->states());
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const couvreur99_check_status*
|
||||
std::shared_ptr<const couvreur99_check_status>
|
||||
couvreur99_check::result() const
|
||||
{
|
||||
return ecs_;
|
||||
|
|
@ -383,7 +382,7 @@ namespace spot
|
|||
}
|
||||
}
|
||||
|
||||
emptiness_check_result*
|
||||
emptiness_check_result_ptr
|
||||
couvreur99_check_shy::check()
|
||||
{
|
||||
// Position in the loop seeking known successors.
|
||||
|
|
@ -418,7 +417,7 @@ namespace spot
|
|||
// This automaton recognizes no word.
|
||||
set_states(ecs_->states());
|
||||
assert(poprem_ || depth() == 0);
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
pos = todo.back().q.begin();
|
||||
|
|
@ -554,7 +553,7 @@ namespace spot
|
|||
// We have found an accepting SCC. Clean up TODO.
|
||||
clear_todo();
|
||||
set_states(ecs_->states());
|
||||
return new couvreur99_check_result(ecs_, options());
|
||||
return std::make_shared<couvreur99_check_result>(ecs_, options());
|
||||
}
|
||||
// Group the pending successors of formed SCC if requested.
|
||||
if (group_)
|
||||
|
|
@ -592,12 +591,12 @@ namespace spot
|
|||
}
|
||||
}
|
||||
|
||||
emptiness_check*
|
||||
emptiness_check_ptr
|
||||
couvreur99(const const_tgba_ptr& a, option_map o)
|
||||
{
|
||||
if (o.get("shy"))
|
||||
return new couvreur99_check_shy(a, o);
|
||||
return new couvreur99_check(a, o);
|
||||
return std::make_shared<couvreur99_check_shy>(a, o);
|
||||
return std::make_shared<couvreur99_check>(a, o);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,10 +136,10 @@ namespace spot
|
|||
/// states that belong to the same SCC will be considered when
|
||||
/// choosing a successor. Otherwise, only the successor of the
|
||||
/// topmost state on the DFS stack are considered.
|
||||
SPOT_API emptiness_check*
|
||||
SPOT_API emptiness_check_ptr
|
||||
couvreur99(const const_tgba_ptr& a, option_map options = option_map());
|
||||
|
||||
|
||||
#ifndef SWIG
|
||||
/// \brief An implementation of the Couvreur99 emptiness-check algorithm.
|
||||
///
|
||||
/// See the documentation for spot::couvreur99.
|
||||
|
|
@ -150,7 +150,7 @@ namespace spot
|
|||
virtual ~couvreur99_check();
|
||||
|
||||
/// Check whether the automaton's language is empty.
|
||||
virtual emptiness_check_result* check();
|
||||
virtual emptiness_check_result_ptr check();
|
||||
|
||||
virtual std::ostream& print_stats(std::ostream& os) const;
|
||||
|
||||
|
|
@ -162,10 +162,10 @@ namespace spot
|
|||
/// This status should not be deleted, it is a pointer
|
||||
/// to a member of this class that will be deleted when
|
||||
/// the couvreur99 object is deleted.
|
||||
const couvreur99_check_status* result() const;
|
||||
std::shared_ptr<const couvreur99_check_status> result() const;
|
||||
|
||||
protected:
|
||||
couvreur99_check_status* ecs_;
|
||||
std::shared_ptr<couvreur99_check_status> ecs_;
|
||||
/// \brief Remove a strongly component from the hash.
|
||||
///
|
||||
/// This function remove all accessible state from a given
|
||||
|
|
@ -191,7 +191,7 @@ namespace spot
|
|||
couvreur99_check_shy(const const_tgba_ptr& a, option_map o = option_map());
|
||||
virtual ~couvreur99_check_shy();
|
||||
|
||||
virtual emptiness_check_result* check();
|
||||
virtual emptiness_check_result_ptr check();
|
||||
|
||||
protected:
|
||||
struct successor {
|
||||
|
|
@ -239,7 +239,7 @@ namespace spot
|
|||
// reprocess the successor states of SCC that have been merged.
|
||||
bool group2_;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/// @}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue