00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 #ifndef VAUCANSON_AUTOMATA_IMPLEMENTATION_LISTG_ITERATOR_HXX
00018 # define VAUCANSON_AUTOMATA_IMPLEMENTATION_LISTG_ITERATOR_HXX
00019 
00020 # include <vaucanson/automata/implementation/listg/iterator.hh>
00021 
00022 namespace vcsn
00023 {
00024   namespace listg
00025   {
00026 
00027     
00028 # define LISTG_ITERATOR_TPARAM template <typename Graph, typename Handler, typename Direction>
00029 # define LISTG_ITERATOR DeltaConstIterator<Graph, Handler, Direction>
00030 
00031     LISTG_ITERATOR_TPARAM
00032     LISTG_ITERATOR::DeltaConstIterator(const graph_type& g, typename graph_type::hstate_t s)
00033       : graph_(g), s_(s)
00034     {
00035       initialize(direction());
00036     }
00037 
00038     LISTG_ITERATOR_TPARAM
00039     LISTG_ITERATOR::~DeltaConstIterator()
00040     { }
00041 
00042     LISTG_ITERATOR_TPARAM
00043     void
00044     LISTG_ITERATOR::next()
00045     {
00046       ++i_;
00047     }
00048 
00049     LISTG_ITERATOR_TPARAM
00050     bool
00051     LISTG_ITERATOR::done() const
00052     {
00053       return i_ == end_;
00054     }
00055 
00056     LISTG_ITERATOR_TPARAM
00057     void
00058     LISTG_ITERATOR::initialize(const backward_iterator&)
00059     {
00060       i_ = graph_.states_[s_].input_edges.begin();
00061       end_ = graph_.states_[s_].input_edges.end();
00062     }
00063 
00064     LISTG_ITERATOR_TPARAM
00065     void
00066     LISTG_ITERATOR::initialize(const forward_iterator&)
00067     {
00068       i_ = graph_.states_[s_].output_edges.begin();
00069       end_ = graph_.states_[s_].output_edges.end();
00070     }
00071 
00072     
00073 
00074 
00075 
00076 
00077     template <typename IteratorType>
00078     typename IteratorType::data_type
00079     op_get_delta_iterator_value(const IteratorType&,
00080                                 typename IteratorType::iterator_type i,
00081                                 const typename IteratorType::graph_type&);
00082 # define LISTG_DCI(Handler, Dir) DeltaConstIterator<Graph, typename Graph::Handler, Dir>
00083 
00084 # define LISTG_OP_DELTAI(Dir, H, GetData, GraphName)                        \
00085     template <typename Graph>                                               \
00086     typename LISTG_DCI(H, Dir)::data_type                                   \
00087     op_get_delta_iterator_value(const LISTG_DCI(H, Dir)&,                   \
00088                                 typename LISTG_DCI(H,Dir)::iterator_type i, \
00089                                 const Graph& GraphName)                     \
00090     {                                                                       \
00091       return GetData;                                                       \
00092     }
00093     LISTG_OP_DELTAI(backward_iterator, hstate_t, g.edges_[*i].from, g);
00094     LISTG_OP_DELTAI(forward_iterator, hstate_t, g.edges_[*i].to, g);
00095     LISTG_OP_DELTAI(backward_iterator, htransition_t, *i,);
00096     LISTG_OP_DELTAI(forward_iterator, htransition_t, *i,);
00097 # undef LISTG_OP_DELTAI
00098 # undef LISTG_DCI
00099 
00100 
00101     LISTG_ITERATOR_TPARAM
00102     typename LISTG_ITERATOR::data_type
00103     LISTG_ITERATOR::operator*() const
00104     {
00105       return op_get_delta_iterator_value(*this, i_, graph_);
00106     }
00107 
00108 # undef LISTG_ITERATOR_TPARAM
00109 # undef LISTG_ITERATOR
00110 
00111   } 
00112 
00113 } 
00114 
00115 
00116 #endif // ! VAUCANSON_AUTOMATA_IMPLEMENTATION_LISTG_ITERATOR_HXX