Homogenize passing of automata as pointers, not references.

Disallow copy for security.

* src/tgba/tgbabddconcrete.hh (tgba_bdd_concrete): Disallow copy.
* src/tgba/tgbaexplicit.hh (tgba_explicit): Likewise.
* src/tgba/tgbaexplicit.cc (tgba_explicit::operator=,
tgba_explicit::tgba_explicit(tgba_explicit)): Remove.
* src/tgba/tgbabddconcreteproduct.cc
(tgba_bdd_concrete_product_factory::tgba_bdd_concrete_product_factory,
product): Take operand automata as pointers.
* src/tgba/tgbabddconcreteproduct.hh (product): Likewise.
* src/tgba/tgbaproduct.cc, src/tgba/tgbaproduct.hh:
(tgba_product): Disallow copy.
(tgba_product::tgba_product): Take operand automata as pointers.
* src/tgbaalgos/dotty.cc (dotty_state, dotty_rec, dotty_reachable):
Take tgba arguments as pointer.
* src/tgbaalgos/dotty.hh (dotty_reachable): Likewise.
* src/tgbaalgos/lbtt.cc (fill_todo, lbtt_reachable): Likewise.
* src/tgbaalgos/lbtt.hh (lbtt_reachable): Likewise.
* src/tgbaalgos/ltl2tgba.cc, src/tgbaalgos/ltl2tgba.hh (ltl_to_tgba):
Likewise.
* src/tgbaalgos/save.cc (save_rec, tgba_save_reachable): Likewise.
* src/tgbaalgos/save.hh (save): Likewise.
* src/tgbatest/explicit.cc, src/tgbatest/explprod.cc,
src/tgbatest/ltl2tgba.cc, src/tgbatest/ltlprod.cc,
src/tgbatest/mixprod.cc, src/tgbatest/readsave.cc,
src/tgbatest/spotlbtt.cc, src/tgbatest/tgbaread.cc,
src/tgbatest/tripprod.cc: Likewise.
This commit is contained in:
Alexandre Duret-Lutz 2003-07-14 22:20:35 +00:00
parent cab3be9795
commit 66b1630c31
25 changed files with 123 additions and 104 deletions

View file

@ -58,6 +58,10 @@ namespace spot
protected:
tgba_bdd_core_data data_; ///< Core data associated to the automaton.
bdd init_; ///< Initial state.
private:
// Disallow copy.
tgba_bdd_concrete(const tgba_bdd_concrete&);
tgba_bdd_concrete& tgba_bdd_concrete::operator=(const tgba_bdd_concrete&);
};
}

View file

@ -11,15 +11,15 @@ namespace spot
class tgba_bdd_product_factory: public tgba_bdd_factory
{
public:
tgba_bdd_product_factory(const tgba_bdd_concrete& left,
const tgba_bdd_concrete& right)
: dict_(left.get_dict()),
tgba_bdd_product_factory(const tgba_bdd_concrete* left,
const tgba_bdd_concrete* right)
: dict_(left->get_dict()),
left_(left),
right_(right),
data_(left_.get_core_data(), right_.get_core_data()),
init_(left_.get_init_bdd() & right_.get_init_bdd())
data_(left_->get_core_data(), right_->get_core_data()),
init_(left_->get_init_bdd() & right_->get_init_bdd())
{
assert(dict_ == right.get_dict());
assert(dict_ == right->get_dict());
}
virtual
@ -47,16 +47,16 @@ namespace spot
private:
bdd_dict* dict_;
const tgba_bdd_concrete& left_;
const tgba_bdd_concrete& right_;
const tgba_bdd_concrete* left_;
const tgba_bdd_concrete* right_;
tgba_bdd_core_data data_;
bdd init_;
};
tgba_bdd_concrete
product(const tgba_bdd_concrete& left, const tgba_bdd_concrete& right)
tgba_bdd_concrete*
product(const tgba_bdd_concrete* left, const tgba_bdd_concrete* right)
{
tgba_bdd_product_factory p(left, right);
return tgba_bdd_concrete(p, p.get_init_state());
return new tgba_bdd_concrete(p, p.get_init_state());
}
}

View file

@ -9,8 +9,8 @@ namespace spot
///
/// This function build the resulting product, as another
/// tgba::tgba_bdd_concrete automaton.
tgba_bdd_concrete
product(const tgba_bdd_concrete& left, const tgba_bdd_concrete& right);
tgba_bdd_concrete*
product(const tgba_bdd_concrete* left, const tgba_bdd_concrete* right);
}
#endif // SPOT_TGBA_TGBABDDCONCRETEPRODUCT_HH

View file

@ -87,31 +87,6 @@ namespace spot
{
}
tgba_explicit::tgba_explicit(const tgba_explicit& other)
: tgba(),
name_state_map_(other.name_state_map_),
state_name_map_(other.state_name_map_),
dict_(other.dict_),
init_(other.init_),
all_accepting_conditions_(other.all_accepting_conditions_),
neg_accepting_conditions_(other.neg_accepting_conditions_),
all_accepting_conditions_computed_(other.
all_accepting_conditions_computed_)
{
dict_->register_all_variables_of(&other, this);
}
tgba_explicit&
tgba_explicit::operator=(const tgba_explicit& other)
{
if (&other != this)
{
this->~tgba_explicit();
new (this) tgba_explicit(other);
}
return *this;
}
tgba_explicit::~tgba_explicit()
{
ns_map::iterator i;

View file

@ -17,8 +17,6 @@ namespace spot
{
public:
tgba_explicit(bdd_dict* dict);
tgba_explicit(const tgba_explicit& other);
tgba_explicit& tgba_explicit::operator=(const tgba_explicit& other);
struct transition;
typedef std::list<transition*> state;
@ -65,6 +63,11 @@ namespace spot
mutable bdd all_accepting_conditions_;
bdd neg_accepting_conditions_;
mutable bool all_accepting_conditions_computed_;
private:
// Disallow copy.
tgba_explicit(const tgba_explicit& other);
tgba_explicit& tgba_explicit::operator=(const tgba_explicit& other);
};

View file

@ -143,10 +143,10 @@ namespace spot
////////////////////////////////////////////////////////////
// tgba_product
tgba_product::tgba_product(const tgba& left, const tgba& right)
: dict_(left.get_dict()), left_(&left), right_(&right)
tgba_product::tgba_product(const tgba* left, const tgba* right)
: dict_(left->get_dict()), left_(left), right_(right)
{
assert(dict_ == right.get_dict());
assert(dict_ == right->get_dict());
all_accepting_conditions_ = ((left_->all_accepting_conditions()
& right_->neg_accepting_conditions())

View file

@ -87,14 +87,14 @@ namespace spot
};
/// \brief A lazy product. (States are computed on the fly.)
class tgba_product : public tgba
class tgba_product: public tgba
{
public:
/// \brief Constructor.
/// \param left The left automata in the product.
/// \param right The right automata in the product.
/// Do not be fooled by these arguments: a product is commutative.
tgba_product(const tgba& left, const tgba& right);
tgba_product(const tgba* left, const tgba* right);
virtual ~tgba_product();
@ -116,6 +116,9 @@ namespace spot
const tgba* right_;
bdd all_accepting_conditions_;
bdd neg_accepting_conditions_;
// Disallow copy.
tgba_product(const tgba_product&);
tgba_product& tgba_product::operator=(const tgba_product&);
};
}