18 #ifndef VCSN_AUTOMATA_CONCEPT_AUTOMATA_BASE_HH
19 # define VCSN_AUTOMATA_CONCEPT_AUTOMATA_BASE_HH
22 # include <vaucanson/design_pattern/design_pattern.hh>
23 # include <vaucanson/automata/concept/handlers.hh>
24 # include <vaucanson/automata/concept/delta_kind.hh>
25 # include <vaucanson/algebra/concept/series_base.hh>
40 template <
typename Self>
48 typedef typename virtual_types<Self>::kind_t
kind_t;
65 struct automaton_traits
67 typedef undefined_type label_t;
68 typedef undefined_type series_set_elt_value_t;
69 typedef undefined_type word_value_t;
70 typedef undefined_type semiring_elt_value_t;
71 typedef undefined_type letter_t;
72 typedef undefined_type tag_t;
73 typedef undefined_type states_t;
74 typedef undefined_type state_iterator;
75 typedef undefined_type transitions_t;
76 typedef undefined_type transition_iterator;
77 typedef undefined_type initial_iterator;
78 typedef undefined_type initial_t;
79 typedef undefined_type initial_support_t;
80 typedef undefined_type final_iterator;
81 typedef undefined_type final_t;
82 typedef undefined_type final_support_t;
83 typedef undefined_type geometry_t;
84 typedef undefined_type hstate_t;
85 typedef undefined_type htransition_t;
86 typedef undefined_type delta_iterator;
87 typedef undefined_type rdelta_iterator;
90 # define VCSN_MAKE_AUTOMATON_TRAITS(Type) \
91 template <typename Kind, \
93 typename WeightValue, \
94 typename SeriesValue, \
97 typename GeometryCoords> \
98 struct automaton_traits<Type<Kind, WordValue, WeightValue, SeriesValue, \
99 Letter, Tag, GeometryCoords> > \
101 typedef Type<Kind, WordValue, WeightValue, SeriesValue, \
102 Letter, Tag, GeometryCoords> graph_t; \
103 typedef typename graph_t::semiring_elt_value_t semiring_elt_value_t; \
104 typedef typename graph_t::monoid_elt_value_t monoid_elt_value_t; \
105 typedef typename graph_t::word_value_t word_value_t; \
106 typedef typename graph_t::series_set_elt_value_t series_set_elt_value_t; \
107 typedef typename graph_t::letter_t letter_t; \
108 typedef typename graph_t::tag_t tag_t; \
109 typedef typename graph_t::geometry_t geometry_t; \
110 typedef typename graph_t::label_t label_t; \
111 typedef typename graph_t::states_t states_t; \
112 typedef typename states_t::iterator state_iterator; \
113 typedef typename graph_t::hstate_t hstate_t; \
114 typedef typename graph_t::edges_t transitions_t; \
115 typedef typename transitions_t::iterator transition_iterator; \
116 typedef typename graph_t::htransition_t htransition_t; \
117 typedef typename graph_t::initial_t initial_t; \
118 typedef typename graph_t::initial_support_t initial_support_t; \
119 typedef typename initial_support_t::iterator initial_iterator; \
120 typedef typename graph_t::final_t final_t; \
121 typedef typename graph_t::final_support_t final_support_t; \
122 typedef typename final_support_t::iterator final_iterator; \
123 typedef typename graph_t::delta_iterator delta_iterator; \
124 typedef typename graph_t::rdelta_iterator rdelta_iterator; \
128 template <
typename Auto>
129 struct generalized_traits
131 typedef undefined_type automaton_t;
134 # define VCSN_MAKE_GENERALIZED_AUTOMATON_TRAITS(Type) \
135 template <typename Struct, \
137 typename WordValue, \
138 typename WeightValue, \
139 typename SeriesValue, \
142 typename GeometryCoords> \
143 struct generalized_traits<Element<Struct, Type<Kind, WordValue, \
144 WeightValue, SeriesValue, Letter, \
145 Tag, GeometryCoords> > > \
147 typedef Element<Struct, Type<Kind, WordValue, WeightValue, SeriesValue, \
148 Letter, Tag, GeometryCoords> > Auto_; \
149 typedef typename Auto_::series_set_t series_set_t; \
150 typedef typename Auto_::kind_t kind_t; \
151 typedef typename series_set_t::monoid_t monoid_t; \
152 typedef typename Auto_::series_set_elt_t series_set_elt_t; \
153 typedef typename series_set_elt_t::monoid_elt_t monoid_elt_t; \
154 typedef typename monoid_elt_t::value_t monoid_elt_value_t; \
155 typedef typename series_set_elt_t::semiring_elt_t semiring_elt_t; \
156 typedef typename semiring_elt_t::value_t semiring_elt_value_t; \
157 typedef typename Auto_::value_t::geometry_t geometry_t; \
158 typedef vcsn::Element<vcsn::Automata<series_set_t, Kind>, \
159 Type<labels_are_series, \
160 monoid_elt_value_t, \
161 semiring_elt_value_t, \
162 rat::exp<monoid_elt_value_t, semiring_elt_value_t>, \
163 typename monoid_t::letter_t, \
165 typename geometry_t::coords_t> \
167 typedef typename automaton_t::hstate_t hstate_t; \
168 typedef typename automaton_t::htransition_t htransition_t; \
177 template <
typename Struct,
typename Ratexp>
178 struct standard_of_traits
180 typedef undefined_type automaton_t;
183 # define VCSN_MAKE_STANDARD_OF_TRAITS(Type) \
184 template <typename W, \
188 struct standard_of_traits<algebra::Series<W, M>, rat::exp<Tm, Tw> > \
190 typedef typename algebra::Series<W, M> series_set_t; \
191 typedef typename algebra::polynom<Tm, Tw> \
192 series_set_elt_value_t; \
193 typedef typename M::letter_t letter_t; \
194 typedef typename Type<labels_are_series, Tm, Tw, \
195 series_set_elt_value_t, letter_t, \
196 NoTag, std::pair<double, double> > \
198 typedef Element<Automata<series_set_t, labels_are_series>, automaton_impl_t> \
204 template <
typename S,
typename T>
205 struct projection_traits
208 typedef undefined_type first_projection_t;
211 typedef undefined_type second_projection_t;
217 template <
typename T,
typename TT>
218 struct mute_graph_impl_traits
221 typedef undefined_type first_projection_t;
224 typedef undefined_type second_projection_t;
227 # define VCSN_MAKE_MUTE_GRAPH_IMPL_TRAITS(Type) \
228 template <typename Kind, \
229 typename WordValue, \
230 typename WeightValue, \
231 typename SeriesValue, \
234 typename GeometryCoords, \
236 struct mute_graph_impl_traits<Type<Kind, \
242 GeometryCoords>, TT> \
244 typedef Type<Kind, WordValue, WeightValue, SeriesValue, \
245 Letter, Tag, GeometryCoords> graph_t; \
246 typedef typename algebra::letter_traits<Letter>:: \
247 first_projection_t first_letter_t; \
248 typedef typename algebra::letter_traits<Letter>:: \
249 second_projection_t second_letter_t; \
250 typedef typename TT::first_projection_t::value_t \
251 first_monoid_elt_value_t; \
252 typedef typename TT::second_projection_t::value_t \
253 second_monoid_elt_value_t; \
254 typedef typename algebra::mute_series_impl<SeriesValue, WeightValue, \
255 first_monoid_elt_value_t>::ret \
256 first_series_impl_t; \
257 typedef typename algebra::mute_series_impl<SeriesValue, WeightValue, \
258 second_monoid_elt_value_t>::ret \
259 second_series_impl_t; \
260 typedef Type<Kind, first_monoid_elt_value_t, \
261 WeightValue, first_series_impl_t, \
262 first_letter_t, Tag, GeometryCoords> first_projection_t; \
263 typedef Type<Kind, second_monoid_elt_value_t, \
264 WeightValue, second_series_impl_t, \
265 second_letter_t, Tag, GeometryCoords> second_projection_t; \
271 template <
typename G,
typename W,
typename L>
272 struct mute_graph_impl_monoid_traits
275 typedef undefined_type ret;
278 # define VCSN_MAKE_MUTE_GRAPH_IMPL_MONOID_TRAITS(Type) \
279 template <typename Kind, \
280 typename WordValue, \
281 typename WeightValue, \
282 typename SeriesValue, \
285 typename GeometryCoords, \
288 struct mute_graph_impl_monoid_traits<Type<Kind, \
294 GeometryCoords>, W, L> \
296 typedef Type<Kind, WordValue, WeightValue, SeriesValue, \
297 Letter, Tag, GeometryCoords> graph_t; \
298 typedef typename algebra::mute_series_impl<SeriesValue, WeightValue, \
301 typedef Type<Kind, W, \
302 WeightValue, series_impl_t, \
303 L, Tag, GeometryCoords> ret; \
311 struct virtual_types<AutomataBase<S> >
312 : virtual_types<Structure<S> >
319 struct dynamic_traits<AutomataBase<S> >
320 : dynamic_traits<Structure<S> >
341 template <
typename Self,
typename T>
355 typedef typename automaton_traits<T>::series_set_elt_value_t
380 typedef typename series_set_elt_t::semiring_elt_value_t
384 typedef typename automaton_traits<T>::tag_t
tag_t;
387 typedef typename automaton_traits<T>::label_t
label_t;
390 typedef typename automaton_traits<T>::states_t
states_t;
420 typedef typename automaton_traits<T>::hstate_t
hstate_t;
421 typedef typename automaton_traits<T>::htransition_t htransition_t;
425 typedef typename automaton_traits<T>::rdelta_iterator rdelta_iterator;
434 const tag_t& tag()
const;
461 bool is_initial(
const hstate_t& state)
const;
462 bool is_initial(
unsigned state)
const;
465 bool is_final(
const hstate_t& state)
const;
466 bool is_final(
unsigned state)
const;
469 void set_initial(
const hstate_t& state);
470 void set_initial(
unsigned state);
477 void set_final(
const hstate_t& state);
478 void set_final(
unsigned state);
485 void unset_initial(
const hstate_t& state);
486 void unset_initial(
unsigned state);
489 void unset_final(
const hstate_t& state);
490 void unset_final(
unsigned state);
493 void clear_initial();
500 get_initial(
const hstate_t& state)
const;
502 get_initial(
unsigned state)
const;
506 get_final(
const hstate_t& state)
const;
508 get_final(
unsigned state)
const;
514 hstate_t get_state(
unsigned state)
const;
523 htransition_t add_transition(
unsigned src,
unsigned dst,
528 htransition_t add_weighted_transition(
const hstate_t& src,
const hstate_t& dst,
531 htransition_t add_weighted_transition(
unsigned src,
unsigned dst,
539 htransition_t add_series_transition(
const hstate_t& src,
const hstate_t& dst,
541 htransition_t add_series_transition(
unsigned src,
unsigned dst,
550 htransition_t add_spontaneous(
unsigned src,
unsigned dst,
553 htransition_t add_spontaneous(
unsigned src,
unsigned dst);
556 htransition_t add_letter_transition(
const hstate_t& src,
const hstate_t& dst,
558 htransition_t add_letter_transition(
unsigned src,
unsigned dst,
563 htransition_t add_letter_transition(
const hstate_t& src,
const hstate_t& dst,
564 const std::string& l);
565 htransition_t add_letter_transition(
unsigned src,
unsigned dst,
566 const std::string& l);
569 void update(
const htransition_t& e,
const label_t& l);
572 void del_state(
const hstate_t& state);
573 void del_state(
unsigned state);
576 void del_transition(
const htransition_t& e);
579 bool has_state(
const hstate_t& state)
const;
580 bool has_state(
unsigned state)
const;
583 bool has_transition(
const htransition_t& e)
const;
586 hstate_t src_of(
const htransition_t& e)
const;
589 hstate_t dst_of(
const htransition_t& e)
const;
592 typename automaton_traits<T>::label_t label_of(
const htransition_t& e)
const;
601 bool is_spontaneous(
const htransition_t& e)
const;
616 letter_t letter_of(
const htransition_t& e)
const;
627 template <
typename S,
typename St,
typename T>
630 template <
typename Auto_>
631 typename generalized_traits<Auto_>::automaton_t
632 generalized(
const Auto_& from);
635 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
636 # include <vaucanson/automata/concept/automata_base.hxx>
637 # endif // VCSN_USE_INTERFACE_ONLY
639 #endif // ! VCSN_AUTOMATA_CONCEPT_AUTOMATA_BASE_HH