Make bdd_dict a shared pointer.

* src/tgba/bdddict.hh (bdd_dict_ptr): New type.
(make_bdd_dict): New function.
* iface/dve2/dve2.cc, iface/dve2/dve2.hh, iface/dve2/dve2check.cc,
src/bin/dstar2tgba.cc, src/bin/ltlcross.cc,
src/dstarparse/dstarparse.yy, src/dstarparse/public.hh,
src/graphtest/tgbagraph.cc, src/kripke/kripkeexplicit.cc,
src/kripke/kripkeexplicit.hh, src/kripke/kripkeprint.cc,
src/kripkeparse/kripkeparse.yy, src/kripkeparse/public.hh,
src/kripketest/parse_print_test.cc, src/ltlvisit/apcollect.cc,
src/ltlvisit/contain.cc, src/ltlvisit/contain.hh,
src/ltlvisit/simplify.cc, src/ltlvisit/simplify.hh,
src/neverparse/neverclaimparse.yy, src/neverparse/public.hh,
src/priv/accmap.hh, src/saba/saba.hh, src/saba/sabacomplementtgba.cc,
src/saba/sabacomplementtgba.hh, src/sabatest/sabacomplementtgba.cc,
src/ta/ta.hh, src/ta/taexplicit.cc, src/ta/taexplicit.hh,
src/ta/taproduct.cc, src/ta/taproduct.hh, src/ta/tgtaexplicit.cc,
src/ta/tgtaexplicit.hh, src/taalgos/dotty.cc, src/tgba/bddprint.cc,
src/tgba/bddprint.hh, src/tgba/formula2bdd.cc, src/tgba/formula2bdd.hh,
src/tgba/taatgba.cc, src/tgba/taatgba.hh, src/tgba/tgba.hh,
src/tgba/tgbagraph.hh, src/tgba/tgbakvcomplement.cc,
src/tgba/tgbakvcomplement.hh, src/tgba/tgbaproduct.cc,
src/tgba/tgbaproduct.hh, src/tgba/tgbaproxy.cc, src/tgba/tgbaproxy.hh,
src/tgba/tgbasafracomplement.cc, src/tgba/tgbasafracomplement.hh,
src/tgba/tgbascc.cc, src/tgba/tgbascc.hh, src/tgba/tgbasgba.cc,
src/tgba/tgbasgba.hh, src/tgba/tgbaunion.cc, src/tgba/tgbaunion.hh,
src/tgba/wdbacomp.cc, src/tgbaalgos/compsusp.cc,
src/tgbaalgos/compsusp.hh, src/tgbaalgos/degen.cc,
src/tgbaalgos/dtbasat.cc, src/tgbaalgos/dtgbasat.cc,
src/tgbaalgos/emptiness.cc, src/tgbaalgos/lbtt.cc,
src/tgbaalgos/lbtt.hh, src/tgbaalgos/ltl2taa.cc,
src/tgbaalgos/ltl2taa.hh, src/tgbaalgos/ltl2tgba_fm.cc,
src/tgbaalgos/ltl2tgba_fm.hh, src/tgbaalgos/randomgraph.cc,
src/tgbaalgos/randomgraph.hh, src/tgbaalgos/save.cc,
src/tgbaalgos/translate.cc, src/tgbaalgos/translate.hh,
src/tgbaalgos/word.cc, src/tgbaalgos/word.hh, src/tgbaparse/public.hh,
src/tgbaparse/tgbaparse.yy, src/tgbatest/complementation.cc,
src/tgbatest/explprod.cc, src/tgbatest/ltl2tgba.cc,
src/tgbatest/ltlprod.cc, src/tgbatest/maskacc.cc,
src/tgbatest/powerset.cc, src/tgbatest/randtgba.cc,
src/tgbatest/taatgba.cc, src/tgbatest/tgbaread.cc,
src/tgbatest/tripprod.cc, wrap/python/ajax/spot.in,
wrap/python/tests/alarm.py, wrap/python/tests/ltl2tgba.py,
wrap/python/tests/parsetgba.py: Update to use bdd_dict_ptr and
make_bdd_dict().
This commit is contained in:
Alexandre Duret-Lutz 2014-08-13 16:55:25 +02:00
parent 10e5c62386
commit dc5ad78b3e
93 changed files with 199 additions and 245 deletions

View file

@ -29,6 +29,7 @@
#include <iosfwd>
#include <bdd.h>
#include <vector>
#include <memory>
#include "ltlast/formula.hh"
namespace spot
@ -227,7 +228,12 @@ namespace spot
bdd_dict& operator=(const bdd_dict& other) SPOT_DELETED;
};
typedef std::shared_ptr<bdd_dict> bdd_dict_ptr;
inline bdd_dict_ptr make_bdd_dict()
{
return std::make_shared<bdd_dict>();
}
}
#endif // SPOT_TGBA_BDDDICT_HH

View file

@ -31,7 +31,7 @@
namespace spot
{
/// Global dictionary used by print_handler() to lookup variables.
static const bdd_dict* dict;
static bdd_dict_ptr dict;
/// Global flag to enable Acc[x] output (instead of `x').
static bool want_acc;
@ -98,7 +98,7 @@ namespace spot
}
std::ostream&
bdd_print_sat(std::ostream& os, const bdd_dict* d, bdd b)
bdd_print_sat(std::ostream& os, bdd_dict_ptr d, bdd b)
{
dict = d;
where = &os;
@ -120,7 +120,7 @@ namespace spot
}
std::ostream&
bdd_print_acc(std::ostream& os, const bdd_dict* d, bdd b)
bdd_print_acc(std::ostream& os, bdd_dict_ptr d, bdd b)
{
dict = d;
where = &os;
@ -143,7 +143,7 @@ namespace spot
}
std::ostream&
bdd_print_accset(std::ostream& os, const bdd_dict* d, bdd b)
bdd_print_accset(std::ostream& os, bdd_dict_ptr d, bdd b)
{
dict = d;
where = &os;
@ -156,7 +156,7 @@ namespace spot
}
std::string
bdd_format_accset(const bdd_dict* d, bdd b)
bdd_format_accset(bdd_dict_ptr d, bdd b)
{
std::ostringstream os;
bdd_print_accset(os, d, b);
@ -164,7 +164,7 @@ namespace spot
}
std::string
bdd_format_sat(const bdd_dict* d, bdd b)
bdd_format_sat(bdd_dict_ptr d, bdd b)
{
std::ostringstream os;
bdd_print_sat(os, d, b);
@ -172,7 +172,7 @@ namespace spot
}
std::ostream&
bdd_print_set(std::ostream& os, const bdd_dict* d, bdd b)
bdd_print_set(std::ostream& os, bdd_dict_ptr d, bdd b)
{
dict = d;
want_acc = true;
@ -183,7 +183,7 @@ namespace spot
}
std::string
bdd_format_set(const bdd_dict* d, bdd b)
bdd_format_set(const bdd_dict_ptr d, bdd b)
{
std::ostringstream os;
bdd_print_set(os, d, b);
@ -191,7 +191,7 @@ namespace spot
}
std::ostream&
bdd_print_formula(std::ostream& os, const bdd_dict* d, bdd b)
bdd_print_formula(std::ostream& os, bdd_dict_ptr d, bdd b)
{
const ltl::formula* f = bdd_to_formula(b, d);
print_ltl(f, os);
@ -200,7 +200,7 @@ namespace spot
}
std::string
bdd_format_formula(const bdd_dict* d, bdd b)
bdd_format_formula(bdd_dict_ptr d, bdd b)
{
std::ostringstream os;
bdd_print_formula(os, d, b);
@ -208,7 +208,7 @@ namespace spot
}
std::ostream&
bdd_print_dot(std::ostream& os, const bdd_dict* d, bdd b)
bdd_print_dot(std::ostream& os, bdd_dict_ptr d, bdd b)
{
dict = d;
want_acc = true;
@ -219,7 +219,7 @@ namespace spot
}
std::ostream&
bdd_print_table(std::ostream& os, const bdd_dict* d, bdd b)
bdd_print_table(std::ostream& os, bdd_dict_ptr d, bdd b)
{
dict = d;
want_acc = true;
@ -236,7 +236,7 @@ namespace spot
}
std::ostream&
bdd_print_isop(std::ostream& os, const bdd_dict* d, bdd b)
bdd_print_isop(std::ostream& os, bdd_dict_ptr d, bdd b)
{
dict = d;
want_acc = true;
@ -252,7 +252,7 @@ namespace spot
}
std::string
bdd_format_isop(const bdd_dict* d, bdd b)
bdd_format_isop(bdd_dict_ptr d, bdd b)
{
std::ostringstream os;
bdd_print_isop(os, d, b);

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2012, 2013 Laboratoire de Recherche et Développement
// Copyright (C) 2012, 2013, 2014 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
// Copyright (C) 2003, 2004 Laboratoire d'Informatique de
// Paris 6 (LIP6), département Systèmes Répartis Coopératifs (SRC),
@ -38,7 +38,7 @@ namespace spot
/// \param dict The dictionary to use, to lookup variables.
/// \param b The BDD to print.
SPOT_API std::ostream&
bdd_print_sat(std::ostream& os, const bdd_dict* dict, bdd b);
bdd_print_sat(std::ostream& os, bdd_dict_ptr dict, bdd b);
/// \brief Format a BDD as a list of literals.
///
@ -47,7 +47,7 @@ namespace spot
/// \param b The BDD to print.
/// \return The BDD formated as a string.
SPOT_API std::string
bdd_format_sat(const bdd_dict* dict, bdd b);
bdd_format_sat(bdd_dict_ptr dict, bdd b);
/// \brief Print a BDD as a list of acceptance conditions.
///
@ -57,7 +57,7 @@ namespace spot
/// \param b The BDD to print.
/// \return The BDD formated as a string.
SPOT_API std::ostream&
bdd_print_acc(std::ostream& os, const bdd_dict* dict, bdd b);
bdd_print_acc(std::ostream& os, bdd_dict_ptr dict, bdd b);
/// \brief Print a BDD as a set of acceptance conditions.
///
@ -67,7 +67,7 @@ namespace spot
/// \param b The BDD to print.
/// \return The BDD formated as a string.
SPOT_API std::ostream&
bdd_print_accset(std::ostream& os, const bdd_dict* dict, bdd b);
bdd_print_accset(std::ostream& os, bdd_dict_ptr dict, bdd b);
/// \brief Format a BDD as a set of acceptance conditions.
///
@ -76,49 +76,49 @@ namespace spot
/// \param b The BDD to print.
/// \return The BDD formated as a string.
SPOT_API std::string
bdd_format_accset(const bdd_dict* dict, bdd b);
bdd_format_accset(bdd_dict_ptr dict, bdd b);
/// \brief Print a BDD as a set.
/// \param os The output stream.
/// \param dict The dictionary to use, to lookup variables.
/// \param b The BDD to print.
SPOT_API std::ostream&
bdd_print_set(std::ostream& os, const bdd_dict* dict, bdd b);
bdd_print_set(std::ostream& os, bdd_dict_ptr dict, bdd b);
/// \brief Format a BDD as a set.
/// \param dict The dictionary to use, to lookup variables.
/// \param b The BDD to print.
/// \return The BDD formated as a string.
SPOT_API std::string
bdd_format_set(const bdd_dict* dict, bdd b);
bdd_format_set(bdd_dict_ptr dict, bdd b);
/// \brief Print a BDD as a formula.
/// \param os The output stream.
/// \param dict The dictionary to use, to lookup variables.
/// \param b The BDD to print.
SPOT_API std::ostream&
bdd_print_formula(std::ostream& os, const bdd_dict* dict, bdd b);
bdd_print_formula(std::ostream& os, bdd_dict_ptr dict, bdd b);
/// \brief Format a BDD as a formula.
/// \param dict The dictionary to use, to lookup variables.
/// \param b The BDD to print.
/// \return The BDD formated as a string.
SPOT_API std::string
bdd_format_formula(const bdd_dict* dict, bdd b);
bdd_format_formula(bdd_dict_ptr dict, bdd b);
/// \brief Print a BDD as a diagram in dotty format.
/// \param os The output stream.
/// \param dict The dictionary to use, to lookup variables.
/// \param b The BDD to print.
SPOT_API std::ostream&
bdd_print_dot(std::ostream& os, const bdd_dict* dict, bdd b);
bdd_print_dot(std::ostream& os, bdd_dict_ptr dict, bdd b);
/// \brief Print a BDD as a table.
/// \param os The output stream.
/// \param dict The dictionary to use, to lookup variables.
/// \param b The BDD to print.
SPOT_API std::ostream&
bdd_print_table(std::ostream& os, const bdd_dict* dict, bdd b);
bdd_print_table(std::ostream& os, bdd_dict_ptr dict, bdd b);
/// \brief Enable UTF-8 output for bdd printers.
SPOT_API void enable_utf8();
@ -129,7 +129,7 @@ namespace spot
/// \param b The BDD to print.
/// \return The BDD formated as a string.
SPOT_API std::string
bdd_format_isop(const bdd_dict* dict, bdd b);
bdd_format_isop(bdd_dict_ptr dict, bdd b);
/// \brief Print a BDD as an irredundant sum of product.
@ -137,7 +137,7 @@ namespace spot
/// \param dict The dictionary to use, to lookup variables.
/// \param b The BDD to print.
SPOT_API std::ostream&
bdd_print_isop(std::ostream& os, const bdd_dict* dict, bdd b);
bdd_print_isop(std::ostream& os, bdd_dict_ptr dict, bdd b);
}

View file

@ -35,7 +35,7 @@ namespace spot
class formula_to_bdd_visitor: public ltl::visitor
{
public:
formula_to_bdd_visitor(bdd_dict* d, void* owner)
formula_to_bdd_visitor(bdd_dict_ptr d, void* owner)
: d_(d), owner_(owner)
{
}
@ -167,14 +167,14 @@ namespace spot
}
private:
bdd_dict* d_;
bdd_dict_ptr d_;
void* owner_;
bdd res_;
};
// Convert a BDD which is known to be a conjonction into a formula.
static const ltl::formula*
conj_to_formula(bdd b, const bdd_dict* d)
conj_to_formula(bdd b, const bdd_dict_ptr d)
{
if (b == bddfalse)
return constant::false_instance();
@ -207,7 +207,7 @@ namespace spot
} // anonymous
bdd
formula_to_bdd(const formula* f, bdd_dict* d, void* for_me)
formula_to_bdd(const formula* f, bdd_dict_ptr d, void* for_me)
{
formula_to_bdd_visitor v(d, for_me);
f->accept(v);
@ -215,7 +215,7 @@ namespace spot
}
const formula*
bdd_to_formula(bdd f, const bdd_dict* d)
bdd_to_formula(bdd f, const bdd_dict_ptr d)
{
if (f == bddfalse)
return constant::false_instance();

View file

@ -39,7 +39,7 @@ namespace spot
/// to unregister the variables that have been registered for \a
/// for_me. See bdd_dict::unregister_all_my_variables().
SPOT_API bdd
formula_to_bdd(const ltl::formula* f, bdd_dict* d, void* for_me);
formula_to_bdd(const ltl::formula* f, bdd_dict_ptr d, void* for_me);
/// \brief Convert a BDD into a formula.
///
@ -50,7 +50,7 @@ namespace spot
/// been registered in \a d. Although the result has type
/// ltl::formula*, it obviously does not use any temporal operator.
SPOT_API const
ltl::formula* bdd_to_formula(bdd f, const bdd_dict* d);
ltl::formula* bdd_to_formula(bdd f, const bdd_dict_ptr d);
}
#endif // SPOT_TGBA_FORMULA2BDD_HH

View file

@ -33,7 +33,7 @@ namespace spot
| taa_tgba |
`--------*/
taa_tgba::taa_tgba(bdd_dict* dict)
taa_tgba::taa_tgba(bdd_dict_ptr dict)
: dict_(dict),
all_acceptance_conditions_(bddfalse),
all_acceptance_conditions_computed_(false),
@ -72,7 +72,7 @@ namespace spot
return new taa_succ_iterator(s->get_state(), all_acceptance_conditions());
}
bdd_dict*
bdd_dict_ptr
taa_tgba::get_dict() const
{
return dict_;

View file

@ -35,7 +35,7 @@ namespace spot
class SPOT_API taa_tgba : public tgba
{
public:
taa_tgba(bdd_dict* dict);
taa_tgba(bdd_dict_ptr dict);
struct transition;
typedef std::list<transition*> state;
@ -55,7 +55,7 @@ namespace spot
virtual ~taa_tgba();
virtual spot::state* get_init_state() const;
virtual tgba_succ_iterator* succ_iter(const spot::state* state) const;
virtual bdd_dict* get_dict() const;
virtual bdd_dict_ptr get_dict() const;
virtual std::string format_state(const spot::state* state) const = 0;
virtual bdd all_acceptance_conditions() const;
virtual bdd neg_acceptance_conditions() const;
@ -65,7 +65,7 @@ namespace spot
typedef std::vector<taa_tgba::state_set*> ss_vec;
bdd_dict* dict_;
bdd_dict_ptr dict_;
mutable bdd all_acceptance_conditions_;
mutable bool all_acceptance_conditions_computed_;
bdd neg_acceptance_conditions_;
@ -151,7 +151,7 @@ namespace spot
class SPOT_API taa_tgba_labelled : public taa_tgba
{
public:
taa_tgba_labelled(bdd_dict* dict) : taa_tgba(dict) {};
taa_tgba_labelled(bdd_dict_ptr dict) : taa_tgba(dict) {};
void set_init_state(const label& s)
{
@ -322,7 +322,7 @@ namespace spot
public taa_tgba_labelled<std::string, string_hash>
{
public:
taa_tgba_string(bdd_dict* dict) :
taa_tgba_string(bdd_dict_ptr dict) :
taa_tgba_labelled<std::string, string_hash>(dict) {};
~taa_tgba_string();
protected:
@ -334,7 +334,7 @@ namespace spot
public taa_tgba_labelled<const ltl::formula*, ltl::formula_ptr_hash>
{
public:
taa_tgba_formula(bdd_dict* dict) :
taa_tgba_formula(bdd_dict_ptr dict) :
taa_tgba_labelled<const ltl::formula*, ltl::formula_ptr_hash>(dict) {};
~taa_tgba_formula();
protected:

View file

@ -175,7 +175,7 @@ namespace spot
/// formulae, and vice versa. This is useful when dealing with
/// several automata (which may use the same BDD variable for
/// different formula), or simply when printing.
virtual bdd_dict* get_dict() const = 0;
virtual bdd_dict_ptr get_dict() const = 0;
/// \brief Format the state as a string for printing.
///

View file

@ -160,13 +160,13 @@ namespace spot
protected:
graph_t g_;
bdd_dict* dict_;
bdd_dict_ptr dict_;
bdd all_acceptance_conditions_;
bdd neg_acceptance_conditions_;
mutable unsigned init_number_;
public:
tgba_digraph(bdd_dict* dict)
tgba_digraph(bdd_dict_ptr dict)
: dict_(dict),
all_acceptance_conditions_(bddfalse),
neg_acceptance_conditions_(bddtrue),
@ -211,7 +211,7 @@ namespace spot
return g_;
}
virtual bdd_dict* get_dict() const
virtual bdd_dict_ptr get_dict() const
{
return this->dict_;
}

View file

@ -627,7 +627,7 @@ namespace spot
acc_list_, s);
}
bdd_dict*
bdd_dict_ptr
tgba_kv_complement::get_dict() const
{
return automaton_->get_dict();

View file

@ -93,7 +93,7 @@ namespace spot
virtual state* get_init_state() const;
virtual tgba_succ_iterator* succ_iter(const state* state) const;
virtual bdd_dict* get_dict() const;
virtual bdd_dict_ptr get_dict() const;
virtual std::string format_state(const state* state) const;
virtual bdd all_acceptance_conditions() const;
virtual bdd neg_acceptance_conditions() const;

View file

@ -411,7 +411,7 @@ namespace spot
return lsc & rsc;
}
bdd_dict*
bdd_dict_ptr
tgba_product::get_dict() const
{
return dict_;

View file

@ -94,7 +94,7 @@ namespace spot
virtual tgba_succ_iterator*
succ_iter(const state* state) const;
virtual bdd_dict* get_dict() const;
virtual bdd_dict_ptr get_dict() const;
virtual std::string format_state(const state* state) const;
@ -110,7 +110,7 @@ namespace spot
virtual bdd compute_support_conditions(const state* state) const;
protected:
bdd_dict* dict_;
bdd_dict_ptr dict_;
const tgba* left_;
const tgba* right_;
bool left_kripke_;

View file

@ -48,7 +48,7 @@ namespace spot
return original_->succ_iter(state);
}
bdd_dict*
bdd_dict_ptr
tgba_proxy::get_dict() const
{
return original_->get_dict();

View file

@ -46,7 +46,7 @@ namespace spot
virtual tgba_succ_iterator*
succ_iter(const state* state) const;
virtual bdd_dict* get_dict() const;
virtual bdd_dict_ptr get_dict() const;
virtual std::string format_state(const state* state) const;

View file

@ -1249,7 +1249,7 @@ namespace spot
return new tgba_safra_complement_succ_iterator(succ_list, condition);
}
bdd_dict*
bdd_dict_ptr
tgba_safra_complement::get_dict() const
{
return automaton_->get_dict();

View file

@ -57,7 +57,7 @@ namespace spot
virtual state* get_init_state() const;
virtual tgba_succ_iterator* succ_iter(const state* state) const;
virtual bdd_dict* get_dict() const;
virtual bdd_dict_ptr get_dict() const;
virtual std::string format_state(const state* state) const;
virtual bdd all_acceptance_conditions() const;
virtual bdd neg_acceptance_conditions() const;

View file

@ -56,7 +56,7 @@ namespace spot
return aut_->succ_iter(state);
}
bdd_dict*
bdd_dict_ptr
tgba_scc::get_dict() const
{
return aut_->get_dict();

View file

@ -58,7 +58,7 @@ namespace spot
virtual state* get_init_state() const;
virtual tgba_succ_iterator* succ_iter(const state* state) const;
virtual bdd_dict* get_dict() const;
virtual bdd_dict_ptr get_dict() const;
virtual std::string
transition_annotation(const tgba_succ_iterator* t) const;

View file

@ -199,7 +199,7 @@ namespace spot
return new tgba_sgba_proxy_succ_iterator(it);
}
bdd_dict*
bdd_dict_ptr
tgba_sgba_proxy::get_dict() const
{
return a_->get_dict();

View file

@ -44,7 +44,7 @@ namespace spot
virtual tgba_succ_iterator* succ_iter(const state* state) const;
virtual bdd_dict* get_dict() const;
virtual bdd_dict_ptr get_dict() const;
virtual std::string format_state(const state* state) const;

View file

@ -372,7 +372,7 @@ namespace spot
return right_->support_conditions(s->right());
}
bdd_dict*
bdd_dict_ptr
tgba_union::get_dict() const
{
return dict_;

View file

@ -126,7 +126,7 @@ namespace spot
virtual tgba_succ_iterator_union*
succ_iter(const state* state) const;
virtual bdd_dict* get_dict() const;
virtual bdd_dict_ptr get_dict() const;
virtual std::string format_state(const state* state) const;
@ -139,7 +139,7 @@ namespace spot
virtual bdd compute_support_conditions(const state* state) const;
private:
bdd_dict* dict_;
bdd_dict_ptr dict_;
const tgba* left_;
const tgba* right_;
bdd left_acc_missing_;

View file

@ -227,7 +227,7 @@ namespace spot
return new tgba_wdba_comp_proxy_succ_iterator(it, the_acceptance_cond_);
}
virtual bdd_dict*
virtual bdd_dict_ptr
get_dict() const
{
return a_->get_dict();