18 #ifndef VCSN_AUTOMATA_IMPLEMENTATION_BMIG_GRAPH_IMPL_HH_
19 # define VCSN_AUTOMATA_IMPLEMENTATION_BMIG_GRAPH_IMPL_HH_
20 # include <boost/dynamic_bitset.hpp>
21 # include <boost/shared_ptr.hpp>
23 # include <vaucanson/algebra/implementation/series/rat/exp.hh>
24 # include <vaucanson/automata/implementation/bmig/vgraph_container.hh>
25 # include <vaucanson/automata/implementation/bmig/bmig_handlers.hh>
26 # include <vaucanson/automata/implementation/bmig/iterator.hh>
27 # include <vaucanson/automata/concept/automata_base.hh>
28 # include <vaucanson/automata/concept/automata.hh>
29 # include <vaucanson/automata/concept/automata_kind.hh>
30 # include <vaucanson/automata/implementation/bmig/bmig_support.hh>
31 # include <vaucanson/automata/concept/transducer_base.hh>
32 # include <vaucanson/automata/concept/smart_label.hh>
33 # include <vaucanson/automata/implementation/kind_adapter.hh>
34 # include <vaucanson/automata/implementation/geometry.hh>
35 # include <vaucanson/automata/concept/tags.hh>
36 # include <vaucanson/misc/hash.hh>
37 # include <vaucanson/automata/implementation/bmig/initial_value.hh>
38 # include <vaucanson/automata/implementation/bmig/graphcontainer.hh>
39 # include <vaucanson/automata/implementation/bmig/edge_value.hh>
40 # include <vaucanson/automata/implementation/bmig/bmig_functors.hh>
41 # include <vaucanson/automata/implementation/bmig/initial_container.hh>
49 template <
typename Kind,
typename WordValue,
typename WeightValue,
50 typename SeriesValue,
typename Letter,
typename Tag,
typename GeometryCoords>
59 typedef Graph<Kind, WordValue, WeightValue,
60 SeriesValue, Letter, Tag, GeometryCoords>
63 typedef WeightValue semiring_elt_value_t;
64 typedef WordValue monoid_elt_value_t;
65 typedef WordValue word_value_t;
66 typedef SeriesValue series_set_elt_value_t;
67 typedef Letter letter_t;
70 typedef typename LabelOf<Kind, WordValue, WeightValue,
71 SeriesValue, Letter>::ret label_t;
77 typedef boost::shared_ptr<std::size_t> state_t;
80 typedef handler<state_h, state_t> hstate_t;
82 typedef EdgeValue<state_t, label_t> edge_data_t;
85 typedef GraphContainer<state_t, label_t, edge_data_t> graph_data_t;
98 typedef typename graph_data_t::iterator
100 typedef handler<transition_h, edges_iterator> htransition_t;
101 typedef htransition_t hedge_t;
104 typedef VGraphContainer<edges_iterator, graph_data_t, htransition_t> edges_t;
105 typedef std::vector<state_t> states_data_t;
106 typedef misc::Support<states_data_t> states_t;
110 typedef InitialValue<state_t, series_set_elt_value_t>
112 typedef initial_value_t final_value_t;
113 typedef InitialContainer<initial_value_t, state_t>
116 typedef typename initial_container_t::Type initial_t;
117 typedef initial_t final_t;
119 typedef misc::Support<initial_container_t> initial_support_t;
120 typedef misc::Support<initial_container_t> final_support_t;
122 typedef GeometryCoords geometry_coords_t;
128 typedef typename graph_data_t::iterator iterator;
129 typedef typename graph_data_t::const_iterator const_iterator;
130 typedef iterator transition_iterator;
132 typedef typename index_iterator<graph_data_t, src>::type
134 typedef src_iterator src_const_iterator;
135 typedef typename index_iterator<graph_data_t, dst>::type
137 typedef dst_iterator dst_const_iterator;
138 typedef std::pair<src_iterator, src_iterator> src_range;
139 typedef std::pair<dst_iterator, dst_iterator> dst_range;
141 typedef typename index_iterator<graph_data_t, succ>::type
143 typedef succ_iterator succ_const_iterator;
144 typedef std::pair<succ_iterator, succ_iterator> succ_range;
146 typedef ::vcsn::bmig::DeltaConstIterator<self_t, src_iterator>
148 typedef ::vcsn::bmig::DeltaConstIterator<self_t, dst_iterator>
152 Graph (
unsigned int reserve_number_of_state,
153 unsigned int reserve_number_edge);
154 Graph (
const self_t&);
157 self_t& operator= (
const self_t&);
161 states_t states ()
const;
162 edges_t edges ()
const;
163 initial_support_t initial ()
const;
164 final_support_t
final ()
const;
167 bool has_state (
const hstate_t& h)
const;
168 hstate_t add_state ();
169 hstate_t get_state (
unsigned h)
const;
170 void del_state (
const hstate_t& h);
172 void set_initial(
const hstate_t& s,
173 const series_set_elt_value_t& v,
174 const series_set_elt_value_t& z);
175 const series_set_elt_value_t&
176 get_initial(
const hstate_t&,
177 const series_set_elt_value_t&)
const;
178 bool is_initial(
const hstate_t& s,
179 const series_set_elt_value_t&)
const;
180 void clear_initial();
182 void set_final(
const hstate_t&,
183 const series_set_elt_value_t&,
184 const series_set_elt_value_t&);
185 const series_set_elt_value_t&
186 get_final(
const hstate_t&,
187 const series_set_elt_value_t&)
const;
188 bool is_final(
const hstate_t& s,
189 const series_set_elt_value_t&)
const;
194 bool has_edge (
const hedge_t& h)
const;
195 hedge_t add_edge (
const hstate_t& from,
198 void del_edge (
const hedge_t& h);
200 hstate_t src_of (
const hedge_t& h)
const;
201 hstate_t dst_of (
const hedge_t& h)
const;
203 const label_t& label_of (
const hedge_t& h)
const;
204 void update(
const hedge_t& h,
const label_t& l);
208 bool exists (
const AutomataBase<S>& s)
const;
210 self_t& clone ()
const;
213 const tag_t& tag ()
const;
214 geometry_t& geometry ();
215 const geometry_t& geometry ()
const;
221 template <
typename I>
222 htransition_t get_htransition(
const I& i)
const;
226 # define DECLARE_DELTAI_FUNCTION(DeltaKind) \
227 std::pair<DeltaKind##_iterator, DeltaKind##_iterator> \
228 deltai(const hstate_t& s, DeltaKind##_iterator) const
229 DECLARE_DELTAI_FUNCTION(src);
230 DECLARE_DELTAI_FUNCTION(dst);
231 # undef DECLARE_DELTAI_FUNCTION
234 typename graph_data_t::const_iterator
235 find_edge(
const state_t&,
237 const hlabel_t&)
const;
239 geometry_t geometry_;
246 boost::dynamic_bitset<> initial_bitset_;
247 boost::dynamic_bitset<> final_bitset_;
248 unsigned number_of_epsilon_;
251 unsigned number_of_state_;
252 states_data_t states_;
254 SmartLabelContainer<label_t>
261 # define BMIGRAPH_TPARAM \
262 template <class S, class WordValue, class WeightValue, class SeriesValue, \
263 class Letter, class Tag, class GeometryCoords>
265 # define BMIGRAPH_SERIES \
266 Graph<labels_are_series, WordValue, WeightValue, SeriesValue, \
267 Letter, Tag, GeometryCoords>
270 ADAPT_ADD_LETTER_TRANSITION_TO_SERIES_LABEL(BMIGRAPH_SERIES);
273 ADAPT_LETTER_OF_TO_SERIES_LABEL(BMIGRAPH_SERIES);
276 ADAPT_WORD_OF_TO_SERIES_LABEL(BMIGRAPH_SERIES);
278 # undef BMIGRAPH_SERIES
279 # define BMIGRAPH_LETTERS \
280 Graph<labels_are_letters, WordValue, WeightValue, SeriesValue,\
281 Letter, Tag, GeometryCoords>
284 ADAPT_WORD_OF_TO_LETTERS_LABEL(BMIGRAPH_LETTERS);
287 ADAPT_SERIE_OF_TO_LETTERS_LABEL(BMIGRAPH_LETTERS);
290 ADAPT_ADD_SERIE_TRANSITION_TO_LETTERS_LABEL(BMIGRAPH_LETTERS);
292 # undef BMIGRAPH_LETTERS
295 Graph<Kind, WordValue, WeightValue, SerieValue, \
296 Letter, Tag, GeometryCoords>
298 template <
class Kind,
class WordValue,
class WeightValue,
class SerieValue,
299 class Letter,
class Tag,
class GeometryCoords,
class I>
300 Tag& op_tag(
const AutomataBase<I>&, BMIGRAPH&);
302 template <
class Kind,
class WordValue,
class WeightValue,
class SerieValue,
303 class Letter,
class Tag,
class GeometryCoords,
class I>
304 const Tag& op_tag(
const AutomataBase<I>&, BMIGRAPH&);
306 template <
class Kind,
class WordValue,
class WeightValue,
class SerieValue,
307 class Letter,
class Tag,
class GeometryCoords,
class I>
308 typename BMIGRAPH::geometry_t&
309 op_geometry(
const AutomataBase<I>&, BMIGRAPH&);
311 template <
class Kind,
class WordValue,
class WeightValue,
class SerieValue,
312 class Letter,
class Tag,
class GeometryCoords,
class I>
313 const typename BMIGRAPH::geometry_t&
314 op_geometry(
const AutomataBase<I>&,
const BMIGRAPH&);
317 # undef BMIGRAPH_TPARAM
322 VCSN_MAKE_AUTOMATON_TRAITS(bmig::Graph);
323 VCSN_MAKE_GENERALIZED_AUTOMATON_TRAITS(bmig::Graph);
324 VCSN_MAKE_MUTE_GRAPH_IMPL_TRAITS(bmig::Graph);
325 VCSN_MAKE_MUTE_GRAPH_IMPL_MONOID_TRAITS(bmig::Graph);
328 template <
class Kind,
334 class GeometryCoords>
335 struct transducer_traits<bmig::Graph<Kind,
343 typedef WordValue input_monoid_elt_value_t;
344 typedef typename algebra::series_traits<WeightValue>::monoid_elt_value_t
345 output_monoid_elt_value_t;
346 typedef typename algebra::series_traits<WeightValue>::semiring_elt_value_t
347 output_semiring_elt_value_t;
351 template <
class Kind,
357 class GeometryCoords>
358 struct input_projection_traits<bmig::Graph<Kind,
366 typedef bmig::Graph<Kind, WordValue, WeightValue, SeriesValue,
367 Letter, Tag, GeometryCoords>
369 typedef typename transducer_traits<self_t>::output_semiring_elt_value_t
370 semiring_elt_value_t;
371 typedef typename transducer_traits<self_t>::input_monoid_elt_value_t
373 typedef typename algebra::mute_series_impl<SeriesValue,
374 semiring_elt_value_t,
375 monoid_elt_value_t>::ret
376 series_set_elt_value_t;
381 semiring_elt_value_t,
382 series_set_elt_value_t,
390 template <
class Kind,
396 class GeometryCoords>
397 struct fmp_input_projection_traits<bmig::Graph<Kind,
405 typedef bmig::Graph<Kind, WordValue, WeightValue, SeriesValue,
406 Letter, Tag, GeometryCoords>
409 typedef typename automaton_traits<self_t>::semiring_elt_value_t
410 semiring_elt_value_t;
412 typedef typename WordValue::first_type monoid_elt_value_t;
413 typedef typename monoid_elt_value_t::value_type letter_t;
415 typedef typename algebra::mute_series_impl<SeriesValue,
416 semiring_elt_value_t,
417 monoid_elt_value_t>::ret
418 series_set_elt_value_t;
423 semiring_elt_value_t,
424 series_set_elt_value_t,
431 template <
class Kind,
437 class GeometryCoords>
438 struct output_projection_traits<bmig::Graph<Kind,
446 typedef bmig::Graph<Kind, WordValue, WeightValue, SeriesValue,
447 Letter, Tag, GeometryCoords>
450 typedef typename automaton_traits<self_t>::semiring_elt_value_t
451 series_set_elt_value_t;
454 algebra::series_traits<series_set_elt_value_t>::monoid_elt_value_t
458 algebra::series_traits<series_set_elt_value_t>::semiring_elt_value_t
459 semiring_elt_value_t;
464 semiring_elt_value_t,
465 series_set_elt_value_t,
473 template <
class Kind,
479 class GeometryCoords>
480 struct fmp_output_projection_traits<bmig::Graph<Kind,
488 typedef bmig::Graph<Kind, WordValue, WeightValue, SeriesValue,
489 Letter, Tag, GeometryCoords>
492 typedef typename WordValue::second_type monoid_elt_value_t;
493 typedef typename monoid_elt_value_t::value_type letter_t;
495 typedef typename automaton_traits<self_t>::semiring_elt_value_t
496 semiring_elt_value_t;
498 typedef typename algebra::mute_series_impl<SeriesValue,
499 semiring_elt_value_t,
500 monoid_elt_value_t>::ret series_set_elt_value_t;
505 semiring_elt_value_t,
506 series_set_elt_value_t,
514 template <
class Kind,
520 class GeometryCoords>
521 struct extension_traits<bmig::Graph<Kind,
529 typedef bmig::Graph<Kind, WordValue, WeightValue,
530 SeriesValue, Letter, Tag, GeometryCoords>
532 typedef typename automaton_traits<self_t>::monoid_elt_value_t
534 typedef typename algebra::mute_series_impl<SeriesValue,
536 monoid_elt_value_t>::ret
537 series_set_elt_value_t;
543 series_set_elt_value_t,
551 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
552 # include <vaucanson/automata/implementation/bmig_graph_impl.hxx>
553 # endif // !VCSN_USE_INTERFACE_ONLY || VCSN_USE_LIB
558 #endif // !VCSN_AUTOMATA_IMPLEMENTATION_BMIG_GRAPH_IMPL_HH_ //