00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef VCSN_AUTOMATA_CONCEPT_AUTOMATA_BASE_HXX
00018 # define VCSN_AUTOMATA_CONCEPT_AUTOMATA_BASE_HXX
00019
00020 # include <vaucanson/automata/concept/copy.hh>
00021 # include <vaucanson/automata/concept/automata_base.hh>
00022 # include <vaucanson/automata/concept/automata_ops.hh>
00023
00024 namespace vcsn {
00025
00026 template <typename Self>
00027 AutomataBase<Self>::AutomataBase()
00028 {}
00029
00030 template <typename Self>
00031 AutomataBase<Self>::AutomataBase(const AutomataBase& other) :
00032 Structure<Self>(other)
00033 {}
00034
00035 template <typename Self>
00036 const typename AutomataBase<Self>::series_set_t&
00037 AutomataBase<Self>::series() const
00038 {
00039 return this->self().series();
00040 }
00041
00042
00044 template <typename Self, typename T>
00045 MetaElement<AutomataBase<Self>, T>::MetaElement()
00046 {}
00047
00049 template <typename Self, typename T>
00050 MetaElement<AutomataBase<Self>, T>::MetaElement(const MetaElement& a):
00051 MetaElement<Structure<Self>, T>::MetaElement(a)
00052 {}
00053
00055 template <typename Self, typename T>
00056 typename MetaElement<AutomataBase<Self>, T>::tag_t&
00057 MetaElement<AutomataBase<Self>, T>::tag()
00058 {
00059 return op_tag(this->structure(), this->value());
00060 }
00061
00063 template <typename Self, typename T>
00064 const typename MetaElement<AutomataBase<Self>, T>::tag_t&
00065 MetaElement<AutomataBase<Self>, T>:: tag() const
00066 {
00067 return op_tag(this->structure(), this->value());
00068 }
00069
00071 template <typename Self, typename T>
00072 typename MetaElement<AutomataBase<Self>, T>::geometry_t&
00073 MetaElement<AutomataBase<Self>, T>::geometry()
00074 {
00075 return op_geometry(this->structure(), this->value());
00076 }
00077
00079 template <typename Self, typename T>
00080 const typename MetaElement<AutomataBase<Self>, T>::geometry_t&
00081 MetaElement<AutomataBase<Self>, T>::geometry() const
00082 {
00083 return op_geometry(this->structure(), this->value());
00084 }
00085
00087 template <typename Self, typename T>
00088 bool
00089 MetaElement<AutomataBase<Self>, T>::exists() const
00090 {
00091 return op_exists(this->structure(), this->value());
00092 }
00093
00095 template <typename Self, typename T>
00096 typename automaton_traits<T>::states_t
00097 MetaElement<AutomataBase<Self>, T>::states() const
00098 {
00099 return op_states(this->structure(), this->value());
00100 }
00101
00103 template <typename Self, typename T>
00104 typename automaton_traits<T>::transitions_t
00105 MetaElement<AutomataBase<Self>, T>::transitions() const
00106 {
00107 return op_transitions(this->structure(), this->value());
00108 }
00109
00111 template <typename Self, typename T>
00112 const typename MetaElement<AutomataBase<Self>, T>::series_set_t&
00113 MetaElement<AutomataBase<Self>, T>::series() const
00114 {
00115 return this->structure().series();
00116 }
00117
00119 template <typename Self, typename T>
00120 typename automaton_traits<T>::initial_support_t
00121 MetaElement<AutomataBase<Self>, T>::initial() const
00122 {
00123 return op_initial(this->structure(), this->value());
00124 }
00125
00127 template <typename Self, typename T>
00128 typename automaton_traits<T>::final_support_t
00129
00130 MetaElement<AutomataBase<Self>, T>::final() const
00131 {
00132 return op_final(this->structure(), this->value());
00133 }
00134
00137 template <typename Self, typename T>
00138 bool
00139 MetaElement<AutomataBase<Self>, T>::is_initial(const typename automaton_traits<T>::hstate_t& state) const
00140 {
00141 return op_is_initial(this->structure(), this->value(), state);
00142 }
00143
00144 template <typename Self, typename T>
00145 bool
00146 MetaElement<AutomataBase<Self>, T>::is_initial(unsigned state) const
00147 {
00148 return op_is_initial(this->structure(), this->value(), state);
00149 }
00150
00152 template <typename Self, typename T>
00153 bool
00154 MetaElement<AutomataBase<Self>, T>::is_final(const typename automaton_traits<T>::hstate_t& state) const
00155 {
00156 return op_is_final(this->structure(), this->value(), state);
00157 }
00158
00159 template <typename Self, typename T>
00160 bool
00161 MetaElement<AutomataBase<Self>, T>::is_final(unsigned state) const
00162 {
00163 return op_is_final(this->structure(), this->value(), state);
00164 }
00165
00167 template <typename Self, typename T>
00168 void
00169 MetaElement<AutomataBase<Self>, T>::set_initial(const typename automaton_traits<T>::hstate_t& state)
00170 {
00171 op_set_initial(this->structure(),
00172 this->value(),
00173 state,
00174 this->structure().series().
00175 identity(SELECT(series_set_elt_value_t)));
00176 }
00177
00178 template <typename Self, typename T>
00179 void
00180 MetaElement<AutomataBase<Self>, T>::set_initial(unsigned state)
00181 {
00182 op_set_initial(this->structure(),
00183 this->value(),
00184 state,
00185 this->structure().series().
00186 identity(SELECT(series_set_elt_value_t)));
00187 }
00188
00190 template <typename Self, typename T>
00191 void
00192 MetaElement<AutomataBase<Self>, T>::
00193 set_initial(const typename automaton_traits<T>::hstate_t& state, const series_set_elt_t& s)
00194 {
00195 op_set_initial(this->structure(), this->value(), state, s);
00196 }
00197
00198 template <typename Self, typename T>
00199 void
00200 MetaElement<AutomataBase<Self>, T>::
00201 set_initial(unsigned state, const series_set_elt_t& s)
00202 {
00203 op_set_initial(this->structure(), this->value(), state, s);
00204 }
00205
00207 template <typename Self, typename T>
00208 void
00209 MetaElement<AutomataBase<Self>, T>::set_final(const typename automaton_traits<T>::hstate_t& state)
00210 {
00211 op_set_final(this->structure(),
00212 this->value(),
00213 state,
00214 this->structure().series().
00215 identity(SELECT(series_set_elt_value_t)));
00216 }
00217
00218 template <typename Self, typename T>
00219 void
00220 MetaElement<AutomataBase<Self>, T>::set_final(unsigned state)
00221 {
00222 op_set_final(this->structure(),
00223 this->value(),
00224 state,
00225 this->structure().series().
00226 identity(SELECT(series_set_elt_value_t)));
00227 }
00228
00230 template <typename Self, typename T>
00231 void
00232 MetaElement<AutomataBase<Self>, T>::
00233 set_final(const typename automaton_traits<T>::hstate_t& state, const series_set_elt_t& s)
00234 {
00235 op_set_final(this->structure(), this->value(), state, s);
00236 }
00237
00238 template <typename Self, typename T>
00239 void
00240 MetaElement<AutomataBase<Self>, T>::
00241 set_final(unsigned state, const series_set_elt_t& s)
00242 {
00243 op_set_final(this->structure(), this->value(), state, s);
00244 }
00245
00247 template <typename Self, typename T>
00248 void
00249 MetaElement<AutomataBase<Self>, T>::unset_initial(const typename automaton_traits<T>::hstate_t& state)
00250 {
00251 op_set_initial(this->structure(),
00252 this->value(),
00253 state,
00254 algebra::zero_as<series_set_elt_value_t>::
00255 of(this->structure().series()));
00256 }
00257
00258 template <typename Self, typename T>
00259 void
00260 MetaElement<AutomataBase<Self>, T>::unset_initial(unsigned state)
00261 {
00262 op_set_initial(this->structure(),
00263 this->value(),
00264 state,
00265 algebra::zero_as<series_set_elt_value_t>::
00266 of(this->structure().series()));
00267 }
00268
00270 template <typename Self, typename T>
00271 void
00272 MetaElement<AutomataBase<Self>, T>::unset_final(const typename automaton_traits<T>::hstate_t& state)
00273 {
00274 op_set_final(this->structure(),
00275 this->value(),
00276 state,
00277 algebra::zero_as<series_set_elt_value_t>::
00278 of(this->structure().series()));
00279 }
00280
00281 template <typename Self, typename T>
00282 void
00283 MetaElement<AutomataBase<Self>, T>::unset_final(unsigned state)
00284 {
00285 op_set_final(this->structure(),
00286 this->value(),
00287 state,
00288 algebra::zero_as<series_set_elt_value_t>::
00289 of(this->structure().series()));
00290 }
00291
00293 template <typename Self, typename T>
00294 void
00295 MetaElement<AutomataBase<Self>, T>::clear_initial()
00296 {
00297 return op_clear_initial(this->structure(), this->value());
00298 }
00299
00301 template <typename Self, typename T>
00302 void
00303 MetaElement<AutomataBase<Self>, T>::clear_final()
00304 {
00305 return op_clear_final(this->structure(), this->value());
00306 }
00307
00309 template <typename Self, typename T>
00310 typename MetaElement<AutomataBase<Self>, T>::series_set_elt_t
00311 MetaElement<AutomataBase<Self>, T>::get_initial(const typename automaton_traits<T>::hstate_t& state) const
00312 {
00313 return op_get_initial(this->structure(), this->value(), state);
00314 }
00315
00316 template <typename Self, typename T>
00317 typename MetaElement<AutomataBase<Self>, T>::series_set_elt_t
00318 MetaElement<AutomataBase<Self>, T>::get_initial(unsigned state) const
00319 {
00320 return op_get_initial(this->structure(), this->value(), state);
00321 }
00322
00324 template <typename Self, typename T>
00325 typename MetaElement<AutomataBase<Self>, T>::series_set_elt_t
00326 MetaElement<AutomataBase<Self>, T>::get_final(const typename automaton_traits<T>::hstate_t& state) const
00327 {
00328 return op_get_final(this->structure(), this->value(), state);
00329 }
00330
00331 template <typename Self, typename T>
00332 typename MetaElement<AutomataBase<Self>, T>::series_set_elt_t
00333 MetaElement<AutomataBase<Self>, T>::get_final(unsigned state) const
00334 {
00335 return op_get_final(this->structure(), this->value(), state);
00336 }
00337
00339 template <typename Self, typename T>
00340 typename automaton_traits<T>::hstate_t
00341 MetaElement<AutomataBase<Self>, T>::add_state()
00342 {
00343 return op_add_state(this->structure(), this->value());
00344 }
00345
00347 template <typename Self, typename T>
00348 typename automaton_traits<T>::hstate_t
00349 MetaElement<AutomataBase<Self>, T>::get_state(unsigned state) const
00350 {
00351 return op_get_state(this->structure(), this->value(), state);
00352 }
00353
00356 template <typename Self, typename T>
00357 typename automaton_traits<T>::hstate_t
00358 MetaElement<AutomataBase<Self>, T>::choose_state() const
00359 {
00360 return op_choose_state(this->structure(), this->value());
00361 }
00362
00364 template <typename Self, typename T>
00365 typename automaton_traits<T>::htransition_t
00366 MetaElement<AutomataBase<Self>, T>::add_transition(const typename automaton_traits<T>::hstate_t& src,
00367 const typename automaton_traits<T>::hstate_t& dst,
00368 const label_t& label)
00369 {
00370 return op_add_transition(this->structure(), this->value(),
00371 src, dst, label);
00372 }
00373
00374 template <typename Self, typename T>
00375 typename automaton_traits<T>::htransition_t
00376 MetaElement<AutomataBase<Self>, T>::add_transition(unsigned src,
00377 unsigned dst,
00378 const label_t& label)
00379 {
00380 return op_add_transition(this->structure(), this->value(),
00381 src, dst, label);
00382 }
00383
00385 template <typename Self, typename T>
00386 typename automaton_traits<T>::htransition_t
00387 MetaElement<AutomataBase<Self>, T>::
00388 add_weighted_transition(const typename automaton_traits<T>::hstate_t& src,
00389 const typename automaton_traits<T>::hstate_t& dst,
00390 const semiring_elt_t& w,
00391 const monoid_elt_value_t& m)
00392 {
00393 return op_add_weighted_transition(this->structure(), this->value(),
00394 src, dst, w, m);
00395 }
00396
00397 template <typename Self, typename T>
00398 typename automaton_traits<T>::htransition_t
00399 MetaElement<AutomataBase<Self>, T>::
00400 add_weighted_transition(unsigned src,
00401 unsigned dst,
00402 const semiring_elt_t& w,
00403 const monoid_elt_value_t& m)
00404 {
00405 return op_add_weighted_transition(this->structure(), this->value(),
00406 src, dst, w, m);
00407 }
00408
00412 template <typename Self, typename T>
00413 typename automaton_traits<T>::htransition_t
00414 MetaElement<AutomataBase<Self>, T>::add_series_transition(const typename automaton_traits<T>::hstate_t& src,
00415 const typename automaton_traits<T>::hstate_t& dst,
00416 const series_set_elt_t& e)
00417 {
00418 return op_add_series_transition(this->structure(), this->value(),
00419 src, dst, e);
00420 }
00421
00422 template <typename Self, typename T>
00423 typename automaton_traits<T>::htransition_t
00424 MetaElement<AutomataBase<Self>, T>::add_series_transition(unsigned src,
00425 unsigned dst,
00426 const series_set_elt_t& e)
00427 {
00428 return op_add_series_transition(this->structure(), this->value(),
00429 src, dst, e);
00430 }
00431
00433 template <typename Self, typename T>
00434 typename automaton_traits<T>::htransition_t
00435 MetaElement<AutomataBase<Self>, T>::add_spontaneous(const typename automaton_traits<T>::hstate_t& src,
00436 const typename automaton_traits<T>::hstate_t& dst)
00437 {
00438 semiring_elt_t w(this->structure().series().semiring());
00439 w = algebra::identity_as<semiring_elt_value_t>
00440 ::of(this->structure().series().semiring());
00441 return op_add_spontaneous(this->structure(), this->value(), src, dst, w);
00442 }
00443
00444 template <typename Self, typename T>
00445 typename automaton_traits<T>::htransition_t
00446 MetaElement<AutomataBase<Self>, T>::add_spontaneous(unsigned src,
00447 unsigned dst)
00448 {
00449 semiring_elt_t w(this->structure().series().semiring());
00450 w = algebra::identity_as<semiring_elt_value_t>
00451 ::of(this->structure().series().semiring());
00452 return op_add_spontaneous(this->structure(), this->value(), src, dst, w);
00453 }
00454
00455 template <typename Self, typename T>
00456 typename automaton_traits<T>::htransition_t
00457 MetaElement<AutomataBase<Self>, T>::add_spontaneous(const typename automaton_traits<T>::hstate_t& src,
00458 const typename automaton_traits<T>::hstate_t& dst,
00459 const semiring_elt_t& w)
00460 {
00461 return op_add_spontaneous(this->structure(), this->value(), src, dst, w);
00462 }
00463
00464 template <typename Self, typename T>
00465 typename automaton_traits<T>::htransition_t
00466 MetaElement<AutomataBase<Self>, T>::add_spontaneous(unsigned src,
00467 unsigned dst,
00468 const semiring_elt_t& w)
00469 {
00470 return op_add_spontaneous(this->structure(), this->value(), src, dst, w);
00471 }
00472
00474 template <typename Self, typename T>
00475 typename automaton_traits<T>::htransition_t
00476 MetaElement<AutomataBase<Self>, T>::add_letter_transition(const typename automaton_traits<T>::hstate_t& src,
00477 const typename automaton_traits<T>::hstate_t& dst,
00478 const letter_t& l)
00479 {
00480 return op_add_letter_transition(this->structure(), this->value(),
00481 src, dst, l);
00482 }
00483
00484 template <typename Self, typename T>
00485 typename automaton_traits<T>::htransition_t
00486 MetaElement<AutomataBase<Self>, T>::add_letter_transition(unsigned src,
00487 unsigned dst,
00488 const letter_t& l)
00489 {
00490 return op_add_letter_transition(this->structure(), this->value(),
00491 src, dst, l);
00492 }
00493
00496 template <typename Self, typename T>
00497 typename automaton_traits<T>::htransition_t
00498 MetaElement<AutomataBase<Self>, T>::add_letter_transition(const typename automaton_traits<T>::hstate_t& src,
00499 const typename automaton_traits<T>::hstate_t& dst,
00500 const std::string& l)
00501 {
00502 return op_add_letter_transition(this->structure(), this->value(),
00503 src, dst, algebra::letter_traits<letter_t>::
00504 literal_to_letter(l).second);
00505 }
00506
00507 template <typename Self, typename T>
00508 typename automaton_traits<T>::htransition_t
00509 MetaElement<AutomataBase<Self>, T>::add_letter_transition(unsigned src,
00510 unsigned dst,
00511 const std::string& l)
00512 {
00513 return op_add_letter_transition(this->structure(), this->value(),
00514 src, dst, algebra::letter_traits<letter_t>::
00515 literal_to_letter(l).second);
00516 }
00517
00519 template <typename Self, typename T>
00520 void
00521 MetaElement<AutomataBase<Self>, T>::update(const typename automaton_traits<T>::htransition_t& e, const label_t& l)
00522 {
00523 op_update(this->structure(), this->value(), e, l);
00524 }
00525
00527 template <typename Self, typename T>
00528 void
00529 MetaElement<AutomataBase<Self>, T>::del_state(const typename automaton_traits<T>::hstate_t& s)
00530 {
00531 return op_del_state(this->structure(), this->value(), s);
00532 }
00533
00534 template <typename Self, typename T>
00535 void
00536 MetaElement<AutomataBase<Self>, T>::del_state(unsigned state)
00537 {
00538 return op_del_state(this->structure(), this->value(), state);
00539 }
00540
00542 template <typename Self, typename T>
00543 void
00544 MetaElement<AutomataBase<Self>, T>::del_transition(const typename automaton_traits<T>::htransition_t& e)
00545 {
00546 return op_del_transition(this->structure(), this->value(), e);
00547 }
00548
00550 template <typename Self, typename T>
00551 bool
00552 MetaElement<AutomataBase<Self>, T>::has_state(const typename automaton_traits<T>::hstate_t& s) const
00553 {
00554 return op_has_state(this->structure(), this->value(), s);
00555 }
00556
00557 template <typename Self, typename T>
00558 bool
00559 MetaElement<AutomataBase<Self>, T>::has_state(unsigned state) const
00560 {
00561 return op_has_state(this->structure(), this->value(), state);
00562 }
00563
00565 template <typename Self, typename T>
00566 bool
00567 MetaElement<AutomataBase<Self>, T>::has_transition(const typename automaton_traits<T>::htransition_t& e) const
00568 {
00569 return op_has_transition(this->structure(), this->value(), e);
00570 }
00571
00573 template <typename Self, typename T>
00574 typename automaton_traits<T>::hstate_t
00575 MetaElement<AutomataBase<Self>, T>::src_of(const typename automaton_traits<T>::htransition_t& e) const
00576 {
00577 return op_src_of(this->structure(), this->value(), e);
00578 }
00579
00581 template <typename Self, typename T>
00582 typename automaton_traits<T>::hstate_t
00583 MetaElement<AutomataBase<Self>, T>::dst_of(const typename automaton_traits<T>::htransition_t& e) const
00584 {
00585 return op_dst_of(this->structure(), this->value(), e);
00586 }
00587
00589 template <typename Self, typename T>
00590 typename automaton_traits<T>::label_t
00591 MetaElement<AutomataBase<Self>, T>::label_of(const typename automaton_traits<T>::htransition_t& e) const
00592 {
00593 return op_label_of(this->structure(), this->value(), e);
00594 }
00595
00597 template <typename Self, typename T>
00598 typename MetaElement<AutomataBase<Self>, T>::series_set_elt_t
00599 MetaElement<AutomataBase<Self>, T>::series_of(const typename automaton_traits<T>::htransition_t& e) const
00600 {
00601 return op_series_of(this->structure(), this->value(), e);
00602 }
00603
00605 template <typename Self, typename T>
00606 typename MetaElement<AutomataBase<Self>, T>::series_set_elt_value_t
00607 MetaElement<AutomataBase<Self>, T>::series_value_of(const typename automaton_traits<T>::htransition_t& e) const
00608 {
00609 return op_series_value_of(this->structure(), this->value(), e);
00610 }
00611
00613 template <typename Self, typename T>
00614 bool
00615 MetaElement<AutomataBase<Self>, T>::is_spontaneous(const typename automaton_traits<T>::htransition_t& e) const
00616 {
00617 return op_is_spontaneous(this->structure(), this->value(), e);
00618 }
00619
00621 template <typename Self, typename T>
00622 typename MetaElement<AutomataBase<Self>, T>::monoid_elt_t
00623 MetaElement<AutomataBase<Self>, T>::word_of(const typename automaton_traits<T>::htransition_t& e) const
00624 {
00625 return op_word_of(this->structure(), this->value(), e);
00626 }
00627
00629 template <typename Self, typename T>
00630 typename MetaElement<AutomataBase<Self>, T>::semiring_elt_t
00631 MetaElement<AutomataBase<Self>, T>::weight_of(const typename automaton_traits<T>::htransition_t& e) const
00632 {
00633 return op_weight_of(this->structure(), this->value(), e);
00634 }
00635
00637 template <typename Self, typename T>
00638 typename MetaElement<AutomataBase<Self>, T>::monoid_elt_value_t
00639 MetaElement<AutomataBase<Self>, T>::word_value_of(const typename automaton_traits<T>::htransition_t& e) const
00640 {
00641 return op_word_value_of(this->structure(), this->value(), e);
00642 }
00643
00647 template <typename Self, typename T>
00648 typename MetaElement<AutomataBase<Self>, T>::letter_t
00649 MetaElement<AutomataBase<Self>, T>::letter_of(const typename automaton_traits<T>::htransition_t& e) const
00650 {
00651 return op_letter_of(this->structure(), this->value(), e);
00652 }
00653
00654 template<typename S, typename St, typename T>
00655 St& op_rout(const AutomataBase<S>& s, St& st, const T& v)
00656 {
00657 Element<S, T> r(s.self(), v);
00658 st << "{ "
00659 << r.states().size() << " states, "
00660 << r.transitions().size() << " transitions, "
00661 << "#I = " << r.initial().size() << ", "
00662 << "#T = " << r.final().size()
00663 << " }";
00664 return st;
00665 }
00666
00667
00668
00669
00670
00671 template <typename Auto_>
00672 typename generalized_traits<Auto_>::automaton_t
00673 generalized(const Auto_& from)
00674 {
00675 typename generalized_traits<Auto_>::automaton_t to(from.structure());
00676 auto_copy(to, from);
00677 return to;
00678 }
00679
00680 }
00681
00682 #endif // ! VCSN_AUTOMATA_CONCEPT_AUTOMATA_BASE_HXX