Commit ab9a570b authored by Florent D'Halluin's avatar Florent D'Halluin
Browse files

Add TransitionIteratorBase and DeltaTransitionIterator.

* include/vaucanson/automata/implementation/iterators/transition_iterator_base.hh,
* include/vaucanson/automata/implementation/iterators/transition_iterator_base.hxx,
* include/vaucanson/automata/implementation/iterators/delta_transition_iterator.hh,
* include/vaucanson/automata/implementation/iterators/delta_transition_iterator.hxx:
New.  Interface and some implementation.
parent 6817d793
2009-09-15 d-halluin <d-halluin@lrde.epita.fr>
Add TransitionIteratorBase and DeltaTransitionIterator.
* include/vaucanson/automata/implementation/iterators/transition_iterator_base.hh,
* include/vaucanson/automata/implementation/iterators/transition_iterator_base.hxx,
* include/vaucanson/automata/implementation/iterators/delta_transition_iterator.hh,
* include/vaucanson/automata/implementation/iterators/delta_transition_iterator.hxx:
New. Interface and some implementation.
2009-09-15 d-halluin <d-halluin@lrde.epita.fr>
 
Change IteratorBase::operator*() to return a copy, not a ref.
......
// delta_transition_iterator.hh: this file is part of the Vaucanson project.
//
// Vaucanson, a generic library for finite state machines.
//
// Copyright (C) 2009 The Vaucanson Group.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// The complete GNU General Public Licence Notice can be found as the
// `COPYING' file in the root directory.
//
// The Vaucanson Group consists of people listed in the `AUTHORS' file.
//
#ifndef VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_DELTA_TRANSITION_ITERATOR_HH
# define VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_DELTA_TRANSITION_ITERATOR_HH
# include <vaucanson/automata/implementation/iterators/transition_iterator_base.hh>
namespace vcsn
{
template <typename T>
struct DeltaTransitionIterator;
/**
* Iterator traits.
*/
template <typename T>
struct iterator_traits_<DeltaTransitionIterator<T> >
{
typedef T graph_t;
typedef typename graph_t::htransition_t value_type;
};
/**
* Class for iterators on the successors of a given state.
*/
template <typename T>
struct DeltaTransitionIterator
: TransitionIteratorBase<DeltaTransitionIterator<T> >
{
/// Self type definition.
typedef DeltaTransitionIterator<T> self_t;
typedef typename TransitionIteratorBase<self_t>::graph_t graph_t;
DeltaTransitionIterator(graph_t graph,
graph_t::hstate_t state);
~DeltaTransitionIterator();
void op_next();
bool op_done();
graph_t::htransition_t op_operator_star() const;
graph_t::hstate_t op_src() const;
graph_t::hstate_t op_dst() const;
graph_t::semiring_elt_t op_weight() const;
graph_t::label_t op_label() const;
private:
hstate_t state_;
graph_t::delta_iterator i_;
};
} // ! vcsn
# if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
# include <vaucanson/automata/implementation/iterators/delta_transition_iterator.hxx>
# endif
#endif // ! VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_DELTA_TRANSITION_ITERATOR_HH
// delta_transition_iterator.hxx: this file is part of the Vaucanson project.
//
// Vaucanson, a generic library for finite state machines.
//
// Copyright (C) 2009 The Vaucanson Group.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// The complete GNU General Public Licence Notice can be found as the
// `COPYING' file in the root directory.
//
// The Vaucanson Group consists of people listed in the `AUTHORS' file.
//
#ifndef VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_DELTA_TRANSITION_ITERATOR_HXX
# define VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_DELTA_TRANSITION_ITERATOR_HXX
# include <vaucanson/automata/implementation/iterators/delta_transition_iterator.hh>
namespace vcsn
{
template <typename T>
DeltaTransitionIterator<T>::DeltaTransitionIterator(graph_t graph,
graph_t::hstate_t state)
: TransitionIteratorBase<self_t>(graph),
state_(state),
i_(graph, state)
{
}
template <typename T>
DeltaTransitionIterator<T>::~DeltaTransitionIterator()
{}
template <typename T>
DeltaTransitionIterator<T>::graph_t::hstate_t
DeltaTransitionIterator<T>::op_src() const
{
return graph_.src_of(*i_);
}
template <typename T>
DeltaTransitionIterator<>::graph_t::hstate_t
DeltaTransitionIterator<T>::op_dst() const
{
return graph_.dst_of(*i_);
}
template <typename T>
DeltaTransitionIterator<T>::graph_t::semiring_elt_t
DeltaTransitionIterator<T>::op_weight() const
{
// FIXME: Extract weight from graph::label_t.
}
template <typename T>
DeltaTransitionIterator<T>::graph_t::label_t
DeltaTransitionIterator<T>::op_label() const
{
// Note: Should not include the weight.
return graph_.label_of(*i_);
}
template <typename T>
void
DeltaTransitionIterator<T>::op_next()
{
return i_.next();
}
template <typename T>
bool
DeltaTransitionIterator<T>::op_done()
{
return i_.done();
}
template <typename T>
DeltaTransitionIterator<T>::graph_t::htransition_t
DeltaTransitionIterator<T>::op_operator_star() const
{
return *i_;
}
} // ! vcsn
#endif // ! VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_DELTA_TRANSITION_ITERATOR_HXX
// transition_iterator_base.hh: this file is part of the Vaucanson project.
//
// Vaucanson, a generic library for finite state machines.
//
// Copyright (C) 2009 The Vaucanson Group.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// The complete GNU General Public Licence Notice can be found as the
// `COPYING' file in the root directory.
//
// The Vaucanson Group consists of people listed in the `AUTHORS' file.
//
#ifndef VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_TRANSITION_ITERATOR_BASE_HH
# define VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_TRANSITION_ITERATOR_BASE_HH
# include <vaucanson/automata/implementation/iterators/iterator_base.hh>
namespace vcsn
{
/**
* Base class for automaton iterators on transitions.
*/
template <typename S>
struct TransitionIteratorBase : IteratorBase<S>
{
/// Self type definition.
typedef TransitionIteratorBase<S> self_t;
typedef typename IteratorBase<self_t>::graph_t graph_t;
TransitionIteratorBase(graph_t graph);
~TransitionIteratorBase();
graph_t::hstate_t src() const;
graph_t::hstate_t dst() const;
graph_t::semiring_elt_t weight() const;
graph_t::label_t label() const;
};
} // ! vcsn
# if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
# include <vaucanson/automata/implementation/iterators/transition_iterator_base.hxx>
# endif
#endif // ! VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_TRANSITION_ITERATOR_BASE_HH
// transition_iterator_base.hxx: this file is part of the Vaucanson project.
//
// Vaucanson, a generic library for finite state machines.
//
// Copyright (C) 2009 The Vaucanson Group.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// The complete GNU General Public Licence Notice can be found as the
// `COPYING' file in the root directory.
//
// The Vaucanson Group consists of people listed in the `AUTHORS' file.
//
#ifndef VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_TRANSITION_ITERATOR_BASE_HXX
# define VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_TRANSITION_ITERATOR_BASE_HXX
# include <vaucanson/automata/implementation/iterators/transition_iterator_base.hh>
namespace vcsn
{
template <typename S>
TransitionIteratorBase<S>::TransitionIteratorBase(graph_t graph)
: IteratorBase<S>(graph)
{}
template <typename S>
TransitionIteratorBase<S>::~TransitionIteratorBase()
{}
template <typename S>
typename TransitionIteratorBase<S>::graph_t::hstate_t
TransitionIteratorBase<S>::src() const
{
return static_cast<const S*>(this)->op_src();
}
template <typename S>
typename TransitionIteratorBase<S>::graph_t::hstate_t
TransitionIteratorBase<S>::dst() const
{
return static_cast<const S*>(this)->op_dst();
}
template <typename S>
typename TransitionIteratorBase<S>::graph_t::semiring_elt_t
TransitionIteratorBase<S>::weight() const
{
return static_cast<const S*>(this)->op_weight();
}
template <typename S>
typename TransitionIteratorBase<S>::graph_t::label_t
TransitionIteratorBase<S>::label() const
{
return static_cast<const S*>(this)->op_label();
}
} // ! vcsn
#endif // ! VCSN_AUTOMATA_IMPLEMENTATION_ITERATORS_TRANSITION_ITERATOR_BASE_HXX
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment