Commit cc105970 authored by Jérôme Galtier's avatar Jérôme Galtier
Browse files

Improve the specifications coverage.

* include/vaucanson/algorithms/complement.hxx (complement_here): Use
new_set_final instead of set_final.
* include/vaucanson/algorithms/complete.hxx (do_complete_here): Use
new_set_initial instead of set_initial.
* include/vaucanson/algorithms/determinize.hxx
(do_subset_construction): Use new_set_intial (resp. set_initial) instead of
new_set_final (resp. set_final).
* include/vaucanson/automata/concept/automata_base.hh (set_initial)
(set_final): Remove.
(new_add_transition): New method.
(new_add_transition, new_add_to_transition, new_set_transition)
(new_set_initial, new_set_final): Remove default arguments, and add
overloaded functions, because we do not know the dynamic value of an
automaton at compile time.
(new_set_initial, new_set_final): Rename the overloaded versions for
entries to new_set_initial_entry and new_set_final_entry to prevent
ambiguous calls.
* include/vaucanson/automata/concept/automata_base.hxx (set_initial)
(set_final): Remove the implementation.
(unset_initial, unset_final): Use op_new_set_initial and
op_new_set_final.
(new_add_transition, new_add_to_transition, new_set_transition)
(new_set_initial, new_set_final): Compute the default arguments for
overloaded methods.
* include/vaucanson/automata/implementation/automata_impl.hh,
include/vaucanson/automata/implementation/automata_impl.hxx
(VertexToLabel::set): Remove.
* include/vaucanson/automata/implementation/automata_ops.hh
(op_set_initial, op_set_final): Remove.
Add overloaded operators for new methods from automata_base.hh.
* include/vaucanson/automata/implementation/automata_ops.hxx
(op_convert): Disable.
Add overloaded operators implementations for new methods from
automata_base.hh. Fix the calculation of the zero element.
* include/vaucanson/automata/implementation/iterators/transition_iterator.hxx
(TransitionIterator<>::op_weight),
include/vaucanson/automata/implementation/iterators/rdelta_transition_iterator.hxx
(RDeltaTransitionIterator<>::op_weight): Use the underlying graph
method weight_of to access the weight.
parent f568f254
2010-02-26 Jrme Galtier <jerome.galtier@lrde.epita.fr>
Improve the specifications coverage.
* include/vaucanson/algorithms/complement.hxx (complement_here): Use
new_set_final instead of set_final.
* include/vaucanson/algorithms/complete.hxx (do_complete_here): Use
new_set_initial instead of set_initial.
* include/vaucanson/algorithms/determinize.hxx
(do_subset_construction): Use new_set_intial (resp. set_initial) instead of
new_set_final (resp. set_final).
* include/vaucanson/automata/concept/automata_base.hh (set_initial)
(set_final): Remove.
(new_add_transition): New method.
(new_add_transition, new_add_to_transition, new_set_transition)
(new_set_initial, new_set_final): Remove default arguments, and add
overloaded functions, because we do not know the dynamic value of an
automaton at compile time.
(new_set_initial, new_set_final): Rename the overloaded versions for
entries to new_set_initial_entry and new_set_final_entry to prevent
ambiguous calls.
* include/vaucanson/automata/concept/automata_base.hxx (set_initial)
(set_final): Remove the implementation.
(unset_initial, unset_final): Use op_new_set_initial and
op_new_set_final.
(new_add_transition, new_add_to_transition, new_set_transition)
(new_set_initial, new_set_final): Compute the default arguments for
overloaded methods.
* include/vaucanson/automata/implementation/automata_impl.hh,
include/vaucanson/automata/implementation/automata_impl.hxx
(VertexToLabel::set): Remove.
* include/vaucanson/automata/implementation/automata_ops.hh
(op_set_initial, op_set_final): Remove.
Add overloaded operators for new methods from automata_base.hh.
* include/vaucanson/automata/implementation/automata_ops.hxx
(op_convert): Disable.
Add overloaded operators implementations for new methods from
automata_base.hh. Fix the calculation of the zero element.
* include/vaucanson/automata/implementation/iterators/transition_iterator.hxx
(TransitionIterator<>::op_weight),
include/vaucanson/automata/implementation/iterators/rdelta_transition_iterator.hxx
(RDeltaTransitionIterator<>::op_weight): Use the underlying graph
method weight_of to access the weight.
2010-02-25 Jrme Galtier <jerome.galtier@lrde.epita.fr>
 
Fix a bug in op_weight_of for BMIGraph.
......
......@@ -47,7 +47,7 @@ namespace vcsn {
if (a.is_final(*i))
a.unset_final(*i);
else
a.set_final(*i);
a.new_set_final(*i);
}
/*-------------.
......
......@@ -58,7 +58,7 @@ namespace vcsn {
if (work.states().size() == 1)
{
sink_needed = true;
work.set_initial(sink_state);
work.new_set_initial(sink_state);
}
const alphabet_t& alphabet = work.structure().series().monoid().alphabet();
......
......@@ -72,10 +72,10 @@ namespace vcsn {
qi.insert(*i);
is_final |= input.is_final(*i);
}
output.set_initial(qi_hstate);
output.new_set_initial(qi_hstate);
if (is_final)
output.set_final(qi_hstate);
output.new_set_final(qi_hstate);
subset_set_t subset_set;
subset_set[qi] = qi_hstate;
......@@ -126,7 +126,7 @@ namespace vcsn {
state_map[qs] = q; // FIXME: Check cost.
if (is_final)
output.set_final(current->second);
output.new_set_final(current->second);
path.push(q);
}
output.add_transition(s_hstate, (*current).second, *e);
......
......@@ -657,22 +657,6 @@ namespace vcsn {
*/
letter_t letter_of(const htransition_t& e) const;
/// Set the state to be initial.
void set_initial(const hstate_t& state);
void set_initial(unsigned state);
/// Set an initial multiplicity to the state.
void set_initial(const hstate_t& state, const series_set_elt_t& m);
void set_initial(unsigned state, const series_set_elt_t& m);
/// Set the state to be final.
void set_final(const hstate_t& state);
void set_final(unsigned state);
/// Set a final multiplicity to the state.
void set_final(const hstate_t& state, const label_t& s);
void set_final(unsigned state, const label_t& s);
/// Set the state not to be initial.
void unset_initial(const hstate_t& state);
void unset_initial(unsigned state);
......@@ -795,6 +779,24 @@ namespace vcsn {
/** @{ */
/**
* @brief Add a transition.
*
* Create a transition between @c src and @c trg labeled by @c w
* with a weight @c k and returns the weight of the updated transition.
* - If there already exists a transition from @c src to @c trg with
* label @c w, @c k is added to the current weight.
*
* @param[in] src The source state.
* @param[in] trg The target state.
* @param[in] w The label value.
* @param[in] k The weight value.
*/
std::pair<htransition_t, weight_t> new_add_transition(const hstate_t& src, const hstate_t& trg,
const label_t& w, const weight_t& k);
std::pair<htransition_t, weight_t> new_add_transition(const hstate_t& src, const hstate_t& trg, const label_t& w);
std::pair<htransition_t, weight_t> new_add_transition(const hstate_t& src, const hstate_t& trg);
/**
* @brief Add a weight to a transition.
*
......@@ -806,7 +808,8 @@ namespace vcsn {
* @param[in] t The transition.
* @param[in] k The weight value.
*/
weight_t new_add_to_transition(const htransition_t& t, const weight_t& w = weight_t(1));
weight_t new_add_to_transition(const htransition_t& t, const weight_t& k);
weight_t new_add_to_transition(const htransition_t& t);
/**
* @brief Tells if there is a (non zero) transition with source @c src,
......@@ -886,7 +889,9 @@ namespace vcsn {
* - @c rdelta_entry_iterator.
*/
htransition_t new_set_transition(const hstate_t& src, const hstate_t& trg,
const label_t& w, const weight_t& k = weight_t(1));
const label_t& w, const weight_t& k);
htransition_t new_set_transition(const hstate_t& src, const hstate_t& trg,
const label_t& w);
/**
* @brief Add an initial transition to a state.
......@@ -975,9 +980,9 @@ namespace vcsn {
*
* @see new_set_initial
*/
void new_set_initial(const hstate_t& state,
const weight_t& w = weight_t(1),
const label_t& l = label_t());
void new_set_initial(const hstate_t& state, const weight_t& w, const label_t& l);
void new_set_initial(const hstate_t& state, const weight_t& w);
void new_set_initial(const hstate_t& state);
/**
* @brief Add a final transition to a state.
......@@ -1064,9 +1069,9 @@ namespace vcsn {
*
* @see new_set_final
*/
void new_set_final(const hstate_t& state,
const weight_t& w = weight_t(1),
const label_t& l = label_t());
void new_set_final(const hstate_t& state, const weight_t& w, const label_t& l);
void new_set_final(const hstate_t& state, const weight_t& w);
void new_set_final(const hstate_t& state);
/** @} */
......@@ -1186,12 +1191,6 @@ namespace vcsn {
void new_set_entry(const hstate_t& src, const hstate_t& dst,
const entry_value_t& e);
// FIXME: add documentation
void new_set_initial_entry(const hstate_t& state, const entry_value_t& e);
// FIXME: add documentation
void new_set_final_entry(const hstate_t& state, const entry_value_t& e);
/**
* @brief Get an entry.
*
......@@ -1260,8 +1259,7 @@ namespace vcsn {
* following iterators:
*
*/
void new_set_initial(const hstate_t& state,
const entry_value_t& e);
void new_set_initial_entry(const hstate_t& state, const entry_value_t& e);
/**
* @brief Add a final entry to a state.
......@@ -1316,8 +1314,7 @@ namespace vcsn {
* following iterators:
*
*/
void new_set_final(const hstate_t& state,
const entry_value_t& e);
void new_set_final_entry(const hstate_t& state, const entry_value_t& e);
/** @} */
......
......@@ -221,70 +221,31 @@ namespace vcsn {
return op_is_final(this->structure(), this->value(), state);
}
/** Set the state to be initial. */
template <typename Self, typename T>
void
MetaElement<AutomataBase<Self>, T>::set_initial(const typename automaton_traits<AutomataBase<Self>, T>::hstate_t& state)
{
precondition(has_state(state));
// FIXME: labels_are_series
/*
op_set_initial(this->structure(),
this->value(),
state,
this->structure().series().
identity(SELECT(series_set_elt_value_t)));
*/
// FIXME: labels_are_letters
op_set_initial(this->structure(),
this->value(),
state);
}
template <typename Self, typename T>
void
MetaElement<AutomataBase<Self>, T>::set_initial(unsigned state)
{
// FIXME: labels_are_series
/*
op_set_initial(this->structure(),
this->value(),
state,
this->structure().series().
identity(SELECT(series_set_elt_value_t)));
*/
// FIXME: labels_are_letters
op_set_initial(this->structure(),
this->value(),
state);
}
/** Set an initial multiplicity to the state. */
template <typename Self, typename T>
void
MetaElement<AutomataBase<Self>, T>::
set_initial(const typename automaton_traits<AutomataBase<Self>, T>::hstate_t& state, const series_set_elt_t& s)
new_set_initial(const typename automaton_traits<AutomataBase<Self>, T>::hstate_t& state,
const weight_t& w,
const label_t& l)
{
op_set_initial(this->structure(), this->value(), state, s);
op_new_set_initial(this->structure(), this->value(), state, w, l);
}
template <typename Self, typename T>
void
MetaElement<AutomataBase<Self>, T>::
new_set_initial(const typename automaton_traits<AutomataBase<Self>, T>::hstate_t& state,
const entry_value_t& e)
const weight_t& w)
{
op_set_initial(this->structure(), this->value(), state, e);
op_new_set_initial(this->structure(), this->value(), state, w);
}
template <typename Self, typename T>
void
MetaElement<AutomataBase<Self>, T>::
new_set_initial(const typename automaton_traits<AutomataBase<Self>, T>::hstate_t& state,
const weight_t& w,
const label_t& l)
new_set_initial(const typename automaton_traits<AutomataBase<Self>, T>::hstate_t& state)
{
op_new_set_initial(this->structure(), this->value(), state, w, l);
op_new_set_initial(this->structure(), this->value(), state);
}
template <typename Self, typename T>
......@@ -296,7 +257,7 @@ namespace vcsn {
// first, retrieve the current entry value
entry_value_t f = get_initial(state);
op_set_initial(this->structure(), this->value(), state, f + e);
op_new_set_initial(this->structure(), this->value(), state, f + e);
}
template <typename Self, typename T>
......@@ -313,84 +274,28 @@ namespace vcsn {
template <typename Self, typename T>
void
MetaElement<AutomataBase<Self>, T>::
set_initial(unsigned state, const series_set_elt_t& s)
{
op_set_initial(this->structure(), this->value(), state, s);
}
/** Set the state to be final. */
template <typename Self, typename T>
void
MetaElement<AutomataBase<Self>, T>::set_final(const typename automaton_traits<AutomataBase<Self>, T>::hstate_t& state)
{
precondition(has_state(state));
// FIXME: labels_are_series
/*
op_set_final(this->structure(),
this->value(),
state,
this->structure().series().
identity(SELECT(series_set_elt_value_t)));
*/
// FIXME: labels_are_letters
op_set_final(this->structure(),
this->value(),
state);
}
template <typename Self, typename T>
void
MetaElement<AutomataBase<Self>, T>::set_final(unsigned state)
{
// FIXME: labels_are_series
/*
op_set_final(this->structure(),
this->value(),
state,
this->structure().series().
identity(SELECT(series_set_elt_value_t)));
*/
// FIXME: labels_are_letters
op_set_final(this->structure(),
this->value(),
state);
}
/** Set a final multiplicity to the state. */
template <typename Self, typename T>
void
MetaElement<AutomataBase<Self>, T>::
set_final(const typename automaton_traits<AutomataBase<Self>, T>::hstate_t& state, const label_t& s)
{
precondition(has_state(state));
op_set_final(this->structure(), this->value(), state, s);
}
template <typename Self, typename T>
void
MetaElement<AutomataBase<Self>, T>::
set_final(unsigned state, const label_t& s)
new_set_final(const typename automaton_traits<AutomataBase<Self>, T>::hstate_t& state,
const weight_t& w,
const label_t& l)
{
op_set_final(this->structure(), this->value(), state, s);
op_new_set_final(this->structure(), this->value(), state, w, l);
}
template <typename Self, typename T>
void
MetaElement<AutomataBase<Self>, T>::
new_set_final(const typename automaton_traits<AutomataBase<Self>, T>::hstate_t& state,
const entry_value_t& e)
const weight_t& w)
{
op_set_final(this->structure(), this->value(), state, e);
op_new_set_final(this->structure(), this->value(), state, w);
}
template <typename Self, typename T>
void
MetaElement<AutomataBase<Self>, T>::
new_set_final(const typename automaton_traits<AutomataBase<Self>, T>::hstate_t& state,
const weight_t& w,
const label_t& l)
new_set_final(const typename automaton_traits<AutomataBase<Self>, T>::hstate_t& state)
{
op_new_set_final(this->structure(), this->value(), state, w, l);
op_new_set_final(this->structure(), this->value(), state);
}
template <typename Self, typename T>
......@@ -402,7 +307,7 @@ namespace vcsn {
// first, retrieve the current entry value
entry_value_t f = get_final(state);
op_set_final(this->structure(), this->value(), state, f + e);
op_new_set_final(this->structure(), this->value(), state, f + e);
}
template <typename Self, typename T>
......@@ -448,11 +353,11 @@ namespace vcsn {
void
MetaElement<AutomataBase<Self>, T>::unset_initial(unsigned state)
{
op_set_initial(this->structure(),
this->value(),
state,
algebra::zero_as<series_set_elt_value_t>::
of(this->structure().series()));
op_new_set_initial(this->structure(),
this->value(),
state,
algebra::zero_as<series_set_elt_value_t>::
of(this->structure().series()));
}
/** Set the set not to be final. */
......@@ -485,11 +390,11 @@ namespace vcsn {
void
MetaElement<AutomataBase<Self>, T>::unset_final(unsigned state)
{
op_set_final(this->structure(),
this->value(),
state,
algebra::zero_as<series_set_elt_value_t>::
of(this->structure().series()));
op_new_set_final(this->structure(),
this->value(),
state,
algebra::zero_as<series_set_elt_value_t>::
of(this->structure().series()));
}
/** Make the support of the initial application to be empty. */
......@@ -577,6 +482,36 @@ namespace vcsn {
src, dst, label);
}
template <typename Self, typename T>
std::pair<typename automaton_traits<AutomataBase<Self>, T>::htransition_t,
typename automaton_traits<AutomataBase<Self>, T>::series_set_elt_t::semiring_elt_t>
MetaElement<AutomataBase<Self>, T>::new_add_transition(const typename automaton_traits<AutomataBase<Self>, T>::hstate_t& src,
const typename automaton_traits<AutomataBase<Self>, T>::hstate_t& trg,
const label_t& w,
const weight_t& k)
{
return op_new_add_transition(this->structure(), this->value(), src, trg, w, k);
}
template <typename Self, typename T>
std::pair<typename automaton_traits<AutomataBase<Self>, T>::htransition_t,
typename automaton_traits<AutomataBase<Self>, T>::series_set_elt_t::semiring_elt_t>
MetaElement<AutomataBase<Self>, T>::new_add_transition(const typename automaton_traits<AutomataBase<Self>, T>::hstate_t& src,
const typename automaton_traits<AutomataBase<Self>, T>::hstate_t& trg,
const label_t& w)
{
return op_new_add_transition(this->structure(), this->value(), src, trg, w);
}
template <typename Self, typename T>
std::pair<typename automaton_traits<AutomataBase<Self>, T>::htransition_t,
typename automaton_traits<AutomataBase<Self>, T>::series_set_elt_t::semiring_elt_t>
MetaElement<AutomataBase<Self>, T>::new_add_transition(const typename automaton_traits<AutomataBase<Self>, T>::hstate_t& src,
const typename automaton_traits<AutomataBase<Self>, T>::hstate_t& trg)
{
return op_new_add_transition(this->structure(), this->value(), src, trg);
}
template <typename Self, typename T>
typename automaton_traits<AutomataBase<Self>, T>::series_set_elt_t::semiring_elt_t
MetaElement<AutomataBase<Self>, T>::new_add_to_transition(const typename automaton_traits<AutomataBase<Self>, T>::htransition_t& t,
......@@ -585,6 +520,13 @@ namespace vcsn {
return op_new_add_to_transition(this->structure(), this->value(), t, k);
}
template <typename Self, typename T>
typename automaton_traits<AutomataBase<Self>, T>::series_set_elt_t::semiring_elt_t
MetaElement<AutomataBase<Self>, T>::new_add_to_transition(const typename automaton_traits<AutomataBase<Self>, T>::htransition_t& t)
{
return op_new_add_to_transition(this->structure(), this->value(), t);
}
template <typename Self, typename T>
bool
MetaElement<AutomataBase<Self>, T>::new_exist_transition(const hstate_t& src,
......@@ -613,6 +555,15 @@ namespace vcsn {
return op_new_set_transition(this->structure(), this->value(), src, trg, w, k);
}
template <typename Self, typename T>
typename automaton_traits<AutomataBase<Self>, T>::htransition_t
MetaElement<AutomataBase<Self>, T>::new_set_transition(const typename automaton_traits<AutomataBase<Self>, T>::hstate_t& src,
const typename automaton_traits<AutomataBase<Self>, T>::hstate_t& trg,
const label_t& w)
{
return op_new_set_transition(this->structure(), this->value(), src, trg, w);
}
template <typename Self, typename T>
typename automaton_traits<AutomataBase<Self>, T>::htransition_t
MetaElement<AutomataBase<Self>, T>::add_transition(unsigned src,
......
......@@ -36,9 +36,6 @@ namespace vcsn
void set(const hvertex_t&, const weight_t&);
// FIXME: it should only be in the lal interface
void set(const hvertex_t&);
void unset(const hvertex_t&);
const weight_t& get(const hvertex_t&) const;
bool contains(const hvertex_t& s) const;
......
......@@ -36,14 +36,6 @@ namespace vcsn
value_[n] = v;
}
// FIXME: it should only be in the lal interface
template <typename G>
void
VertexToLabel<G>::set(const hvertex_t& n)
{
value_[n] = weight_t(1);
}
template <typename G>
void
VertexToLabel<G>::unset(const hvertex_t& n)
......
......@@ -82,17 +82,6 @@ namespace vcsn
typename automaton_traits<AutomataBase<S>, T>::final_support_t
op_final(const AutomataBase<S>&, const T&);
template <class S, class T>
void
op_set_initial(const AutomataBase<S>&, T&,
const typename automaton_traits<AutomataBase<S>, T>::hstate_t& state,
const typename automaton_traits<AutomataBase<S>, T>::label_t& s);
template <class S, class T>
void
op_set_initial(const AutomataBase<S>&, T&,
const typename automaton_traits<AutomataBase<S>, T>::hstate_t& state);
template <class S, class T>
void
op_unset_initial(const AutomataBase<S>&, T&,
......@@ -110,17 +99,6 @@ namespace vcsn
const T&,
const typename automaton_traits<AutomataBase<S>, T>::hstate_t& state);
template <class S, class T>
void
op_set_final(const AutomataBase<S>&, T&,
const typename automaton_traits<AutomataBase<S>, T>::hstate_t& state,
const typename automaton_traits<AutomataBase<S>, T>::label_t& s);
template <class S, class T>
void
op_set_final(const AutomataBase<S>&, T&,
const typename automaton_traits<AutomataBase<S>, T>::hstate_t& state);
template <class S, class T>
void
op_unset_final(const AutomataBase<S>&, T&,
......@@ -166,17 +144,6 @@ namespace vcsn
const T&,
int state);
template <class S, class T>
void
op_set_final(const AutomataBase<S>&, T&,
int state,
const typename automaton_traits<AutomataBase<S>, T>::label_t& s);
template <class S, class T>
void
op_set_final(const AutomataBase<S>&, T&,
int state);
template <class S, class T>
void
op_unset_final(const AutomataBase<S>&, T&,
......@@ -378,15 +345,26 @@ namespace vcsn
void
op_new_set_initial(const Automata<S, K>& ss, T& v,
const typename automaton_traits<Automata<S, K>, T>::hstate_t& s,