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/automata_base.hh>
00021 # include <vaucanson/automata/concept/automata_ops.hh>
00022
00023 namespace vcsn {
00024
00025 template <typename Self>
00026 AutomataBase<Self>::AutomataBase()
00027 {}
00028
00029 template <typename Self>
00030 AutomataBase<Self>::AutomataBase(const AutomataBase& other) :
00031 Structure<Self>(other)
00032 {}
00033
00034 template <typename Self>
00035 const typename AutomataBase<Self>::series_set_t&
00036 AutomataBase<Self>::series() const
00037 {
00038 return this->self().series();
00039 }
00040
00041
00043 template <typename Self, typename T>
00044 MetaElement<AutomataBase<Self>, T>::MetaElement()
00045 {}
00046
00048 template <typename Self, typename T>
00049 MetaElement<AutomataBase<Self>, T>::MetaElement(const MetaElement& a):
00050 MetaElement<Structure<Self>, T>::MetaElement(a)
00051 {}
00052
00054 template <typename Self, typename T>
00055 typename MetaElement<AutomataBase<Self>, T>::tag_t&
00056 MetaElement<AutomataBase<Self>, T>::tag()
00057 {
00058 return op_tag(this->structure(), this->value());
00059 }
00060
00062 template <typename Self, typename T>
00063 const typename MetaElement<AutomataBase<Self>, T>::tag_t&
00064 MetaElement<AutomataBase<Self>, T>:: tag() const
00065 {
00066 return op_tag(this->structure(), this->value());
00067 }
00068
00070 template <typename Self, typename T>
00071 typename MetaElement<AutomataBase<Self>, T>::geometry_t&
00072 MetaElement<AutomataBase<Self>, T>::geometry()
00073 {
00074 return op_geometry(this->structure(), this->value());
00075 }
00076
00078 template <typename Self, typename T>
00079 const typename MetaElement<AutomataBase<Self>, T>::geometry_t&
00080 MetaElement<AutomataBase<Self>, T>::geometry() const
00081 {
00082 return op_geometry(this->structure(), this->value());
00083 }
00084
00086 template <typename Self, typename T>
00087 bool
00088 MetaElement<AutomataBase<Self>, T>::exists() const
00089 {
00090 return op_exists(this->structure(), this->value());
00091 }
00092
00094 template <typename Self, typename T>
00095 typename automaton_traits<T>::states_t
00096 MetaElement<AutomataBase<Self>, T>::states() const
00097 {
00098 return op_states(this->structure(), this->value());
00099 }
00100
00102 template <typename Self, typename T>
00103 typename automaton_traits<T>::transitions_t
00104 MetaElement<AutomataBase<Self>, T>::transitions() const
00105 {
00106 return op_transitions(this->structure(), this->value());
00107 }
00108
00110 template <typename Self, typename T>
00111 const typename MetaElement<AutomataBase<Self>, T>::series_set_t&
00112 MetaElement<AutomataBase<Self>, T>::series() const
00113 {
00114 return this->structure().series();
00115 }
00116
00118 template <typename Self, typename T>
00119 typename automaton_traits<T>::initial_support_t
00120 MetaElement<AutomataBase<Self>, T>::initial() const
00121 {
00122 return op_initial(this->structure(), this->value());
00123 }
00124
00126 template <typename Self, typename T>
00127 typename automaton_traits<T>::final_support_t
00128
00129 MetaElement<AutomataBase<Self>, T>::final() const
00130 {
00131 return op_final(this->structure(), this->value());
00132 }
00133
00136 template <typename Self, typename T>
00137 bool
00138 MetaElement<AutomataBase<Self>, T>::is_initial(hstate_t state) const
00139 {
00140 return (op_get_initial(this->structure(), this->value(), state) !=
00141 this->structure().series().zero(SELECT(series_set_elt_value_t)));
00142 }
00143
00145 template <typename Self, typename T>
00146 bool
00147 MetaElement<AutomataBase<Self>, T>::is_final(hstate_t state) const
00148 {
00149 return
00150 op_get_final(this->structure(), this->value(), state) !=
00151 algebra::zero_as<series_set_elt_value_t>::
00152 of(this->structure().series());
00153 }
00154
00156 template <typename Self, typename T>
00157 void
00158 MetaElement<AutomataBase<Self>, T>::set_initial(hstate_t state)
00159 {
00160 op_set_initial(this->structure(),
00161 this->value(),
00162 state,
00163 this->structure().series().
00164 identity(SELECT(series_set_elt_value_t)));
00165 }
00166
00168 template <typename Self, typename T>
00169 void
00170 MetaElement<AutomataBase<Self>, T>::
00171 set_initial(hstate_t state, const series_set_elt_t& s)
00172 {
00173 op_set_initial(this->structure(), this->value(), state, s);
00174 }
00175
00177 template <typename Self, typename T>
00178 void
00179 MetaElement<AutomataBase<Self>, T>::set_final(hstate_t state)
00180 {
00181 op_set_final(this->structure(),
00182 this->value(),
00183 state,
00184 this->structure().series().
00185 identity(SELECT(series_set_elt_value_t)));
00186 }
00187
00189 template <typename Self, typename T>
00190 void
00191 MetaElement<AutomataBase<Self>, T>::
00192 set_final(hstate_t state, const series_set_elt_t& s)
00193 {
00194 op_set_final(this->structure(), this->value(), state, s);
00195 }
00196
00198 template <typename Self, typename T>
00199 void
00200 MetaElement<AutomataBase<Self>, T>::unset_initial(hstate_t state)
00201 {
00202 op_set_initial(this->structure(),
00203 this->value(),
00204 state,
00205 algebra::zero_as<series_set_elt_value_t>::
00206 of(this->structure().series()));
00207 }
00208
00210 template <typename Self, typename T>
00211 void
00212 MetaElement<AutomataBase<Self>, T>::unset_final(hstate_t state)
00213 {
00214 op_set_final(this->structure(),
00215 this->value(),
00216 state,
00217 algebra::zero_as<series_set_elt_value_t>::
00218 of(this->structure().series()));
00219 }
00220
00222 template <typename Self, typename T>
00223 void
00224 MetaElement<AutomataBase<Self>, T>::clear_initial()
00225 {
00226 return op_clear_initial(this->structure(), this->value());
00227 }
00228
00230 template <typename Self, typename T>
00231 void
00232 MetaElement<AutomataBase<Self>, T>::clear_final()
00233 {
00234 return op_clear_final(this->structure(), this->value());
00235 }
00236
00238 template <typename Self, typename T>
00239 typename MetaElement<AutomataBase<Self>, T>::series_set_elt_t
00240 MetaElement<AutomataBase<Self>, T>::get_initial(hstate_t state) const
00241 {
00242 return op_get_initial(this->structure(), this->value(), state);
00243 }
00244
00246 template <typename Self, typename T>
00247 typename MetaElement<AutomataBase<Self>, T>::series_set_elt_t
00248 MetaElement<AutomataBase<Self>, T>::get_final(hstate_t what) const
00249 {
00250 return op_get_final(this->structure(), this->value(), what);
00251 }
00252
00254 template <typename Self, typename T>
00255 hstate_t
00256 MetaElement<AutomataBase<Self>, T>::add_state()
00257 {
00258 return op_add_state(this->structure(), this->value());
00259 }
00260
00263 template <typename Self, typename T>
00264 hstate_t
00265 MetaElement<AutomataBase<Self>, T>::choose_state() const
00266 {
00267 return op_choose_state(this->structure(), this->value());
00268 }
00269
00271 template <typename Self, typename T>
00272 htransition_t
00273 MetaElement<AutomataBase<Self>, T>::add_transition(hstate_t from,
00274 hstate_t to,
00275 const label_t& label)
00276 {
00277 return op_add_transition(this->structure(), this->value(),
00278 from, to, label);
00279 }
00280
00282 template <typename Self, typename T>
00283 htransition_t
00284 MetaElement<AutomataBase<Self>, T>::
00285 add_weighted_transition(hstate_t from,
00286 hstate_t to,
00287 const semiring_elt_t& w,
00288 const monoid_elt_value_t& m)
00289 {
00290 return op_add_weighted_transition(this->structure(), this->value(),
00291 from, to, w, m);
00292 }
00293
00297 template <typename Self, typename T>
00298 htransition_t
00299 MetaElement<AutomataBase<Self>, T>::add_series_transition(hstate_t from,
00300 hstate_t to,
00301 const series_set_elt_t& e)
00302 {
00303 return op_add_series_transition(this->structure(), this->value(),
00304 from, to, e);
00305 }
00306
00308 template <typename Self, typename T>
00309 htransition_t
00310 MetaElement<AutomataBase<Self>, T>::add_spontaneous(hstate_t from,
00311 hstate_t to)
00312 {
00313 semiring_elt_t w(this->structure().series().semiring());
00314 w = algebra::identity_as<semiring_elt_value_t>
00315 ::of(this->structure().series().semiring());
00316 return op_add_spontaneous(this->structure(), this->value(), from, to, w);
00317 }
00318
00319 template <typename Self, typename T>
00320 htransition_t
00321 MetaElement<AutomataBase<Self>, T>::add_spontaneous(hstate_t from,
00322 hstate_t to,
00323 const semiring_elt_t& w)
00324 {
00325 return op_add_spontaneous(this->structure(), this->value(), from, to, w);
00326 }
00327
00329 template <typename Self, typename T>
00330 htransition_t
00331 MetaElement<AutomataBase<Self>, T>::add_letter_transition(hstate_t from,
00332 hstate_t to,
00333 const letter_t& l)
00334 {
00335 return op_add_letter_transition(this->structure(), this->value(), from, to, l);
00336 }
00337
00339 template <typename Self, typename T>
00340 void
00341 MetaElement<AutomataBase<Self>, T>::update(htransition_t e, const label_t& l)
00342 {
00343 op_update(this->structure(), this->value(), e, l);
00344 }
00345
00347 template <typename Self, typename T>
00348 void
00349 MetaElement<AutomataBase<Self>, T>::del_state(hstate_t s)
00350 {
00351 return op_del_state(this->structure(), this->value(), s);
00352 }
00353
00355 template <typename Self, typename T>
00356 void
00357 MetaElement<AutomataBase<Self>, T>::del_transition(htransition_t e)
00358 {
00359 return op_del_transition(this->structure(), this->value(), e);
00360 }
00361
00363 template <typename Self, typename T>
00364 bool
00365 MetaElement<AutomataBase<Self>, T>::has_state(hstate_t s) const
00366 {
00367 return op_has_state(this->structure(), this->value(), s);
00368 }
00369
00371 template <typename Self, typename T>
00372 bool
00373 MetaElement<AutomataBase<Self>, T>::has_transition(htransition_t e) const
00374 {
00375 return op_has_transition(this->structure(), this->value(), e);
00376 }
00377
00379 template <typename Self, typename T>
00380 hstate_t
00381 MetaElement<AutomataBase<Self>, T>::src_of(htransition_t e) const
00382 {
00383 return op_src_of(this->structure(), this->value(), e);
00384 }
00385
00387 template <typename Self, typename T>
00388 hstate_t
00389 MetaElement<AutomataBase<Self>, T>::dst_of(htransition_t e) const
00390 {
00391 return op_dst_of(this->structure(), this->value(), e);
00392 }
00393
00395 template <typename Self, typename T>
00396 typename automaton_traits<T>::label_t
00397 MetaElement<AutomataBase<Self>, T>::label_of(htransition_t e) const
00398 {
00399 return op_label_of(this->structure(), this->value(), e);
00400 }
00401
00403 template <typename Self, typename T>
00404 typename MetaElement<AutomataBase<Self>, T>::series_set_elt_t
00405 MetaElement<AutomataBase<Self>, T>::series_of(htransition_t e) const
00406 {
00407 return op_series_of(this->structure(), this->value(), e);
00408 }
00409
00411 template <typename Self, typename T>
00412 typename MetaElement<AutomataBase<Self>, T>::series_set_elt_value_t
00413 MetaElement<AutomataBase<Self>, T>::series_value_of(htransition_t e) const
00414 {
00415 return op_series_value_of(this->structure(), this->value(), e);
00416 }
00417
00419 template <typename Self, typename T>
00420 bool
00421 MetaElement<AutomataBase<Self>, T>::is_spontaneous(htransition_t e) const
00422 {
00423 return op_is_spontaneous(this->structure(), this->value(), e);
00424 }
00425
00427 template <typename Self, typename T>
00428 typename MetaElement<AutomataBase<Self>, T>::monoid_elt_t
00429 MetaElement<AutomataBase<Self>, T>::word_of(htransition_t e) const
00430 {
00431 return op_word_of(this->structure(), this->value(), e);
00432 }
00433
00435 template <typename Self, typename T>
00436 typename MetaElement<AutomataBase<Self>, T>::semiring_elt_t
00437 MetaElement<AutomataBase<Self>, T>::weight_of(htransition_t e) const
00438 {
00439 return op_weight_of(this->structure(), this->value(), e);
00440 }
00441
00443 template <typename Self, typename T>
00444 typename MetaElement<AutomataBase<Self>, T>::monoid_elt_value_t
00445 MetaElement<AutomataBase<Self>, T>::word_value_of(htransition_t e) const
00446 {
00447 return op_word_value_of(this->structure(), this->value(), e);
00448 }
00449
00453 template <typename Self, typename T>
00454 typename MetaElement<AutomataBase<Self>, T>::letter_t
00455 MetaElement<AutomataBase<Self>, T>::letter_of(htransition_t e) const
00456 {
00457 return op_letter_of(this->structure(), this->value(), e);
00458 }
00459
00460
00461
00462
00463
00464 template <typename Self, typename T>
00465 template <typename OutputIterator, typename Kind>
00466 void
00467 MetaElement<AutomataBase<Self>, T>::delta(OutputIterator res,
00468 hstate_t from,
00469 delta_kind::kind<Kind> k) const
00470 {
00471 op_delta(this->structure(), this->value(), res, from, k);
00472 }
00473
00474 template <typename Self, typename T>
00475 template <typename OutputIterator, typename L, typename Kind>
00476 void
00477 MetaElement<AutomataBase<Self>, T>::delta(OutputIterator res,
00478 hstate_t from,
00479 const L& query,
00480 delta_kind::kind<Kind> k) const
00481 {
00482 op_delta(this->structure(), this->value(), res, from, query, k);
00483 }
00484
00485 template <typename Self, typename T>
00486 template <typename OutputIterator, typename L, typename Kind>
00487 void
00488 MetaElement<AutomataBase<Self>, T>::letter_delta(OutputIterator res,
00489 hstate_t from,
00490 const L& letter,
00491 delta_kind::kind<Kind> k) const
00492 {
00493 op_letter_delta(this->structure(), this->value(), res, from, letter, k);
00494 }
00495
00496 template <typename Self, typename T>
00497 template <typename OutputIterator, typename Kind>
00498 void
00499 MetaElement<AutomataBase<Self>, T>
00500 ::spontaneous_delta(OutputIterator res,
00501 hstate_t from,
00502 delta_kind::kind<Kind> k) const
00503 {
00504 return op_spontaneous_delta(this->structure(), this->value(), res, from, k);
00505 }
00506
00507
00508
00509
00510
00511 template <typename Self, typename T>
00512 template <typename Container, typename Kind>
00513 void
00514 MetaElement<AutomataBase<Self>, T>::deltac(Container& res, hstate_t from,
00515 delta_kind::kind<Kind> k) const
00516 {
00517 op_deltac(this->structure(), this->value(), res, from, k);
00518 }
00519
00520 template <typename Self, typename T>
00521 template <typename Container, typename L, typename Kind>
00522 void
00523 MetaElement<AutomataBase<Self>, T>::deltac(Container& res,
00524 hstate_t from,
00525 const L& query,
00526 delta_kind::kind<Kind> k) const
00527 {
00528 op_deltac(this->structure(), this->value(), res, from, query, k);
00529 }
00530
00531 template <typename Self, typename T>
00532 template <typename Container, typename L, typename Kind>
00533 void
00534 MetaElement<AutomataBase<Self>, T>::letter_deltac(Container& res,
00535 hstate_t from,
00536 const L& letter,
00537 delta_kind::kind<Kind> k) const
00538 {
00539 op_letter_deltac(this->structure(), this->value(), res, from, letter, k);
00540 }
00541
00542 template <typename Self, typename T>
00543 template <typename Container, typename Kind>
00544 void
00545 MetaElement<AutomataBase<Self>, T>
00546 ::spontaneous_deltac(Container& res,
00547 hstate_t from,
00548 delta_kind::kind<Kind> k) const
00549 {
00550 op_spontaneous_deltac(this->structure(), this->value(), res, from, k);
00551 }
00552
00553
00554
00555
00556
00557 template <typename Self, typename T>
00558 template <typename Functor, typename Kind>
00559 void
00560 MetaElement<AutomataBase<Self>, T>::deltaf(Functor& fun, hstate_t from,
00561 delta_kind::kind<Kind> k) const
00562 {
00563 op_deltaf(this->structure(), this->value(), fun, from, k);
00564 }
00565
00566 template <typename Self, typename T>
00567 template <typename Functor, typename L, typename Kind>
00568 void
00569 MetaElement<AutomataBase<Self>, T>::deltaf(Functor& fun,
00570 hstate_t from,
00571 const L& query,
00572 delta_kind::kind<Kind> k) const
00573 {
00574 op_deltaf(this->structure(), this->value(), fun, from, query, k);
00575 }
00576
00577 template <typename Self, typename T>
00578 template <typename Functor, typename L, typename Kind>
00579 void
00580 MetaElement<AutomataBase<Self>, T>::letter_deltaf(Functor& fun,
00581 hstate_t from,
00582 const L& letter,
00583 delta_kind::kind<Kind> k) const
00584 {
00585 op_letter_deltaf(this->structure(), this->value(), fun, from, letter, k);
00586 }
00587
00588 template <typename Self, typename T>
00589 template <typename Functor, typename Kind>
00590 void
00591 MetaElement<AutomataBase<Self>, T>
00592 ::spontaneous_deltaf(Functor& fun,
00593 hstate_t from,
00594 delta_kind::kind<Kind> k) const
00595 {
00596 op_spontaneous_deltaf(this->structure(), this->value(), fun, from, k);
00597 }
00598
00599
00600
00601
00602
00603 template <typename Self, typename T>
00604 template <typename OutputIterator, typename Kind>
00605 void
00606 MetaElement<AutomataBase<Self>, T>::rdelta(OutputIterator res,
00607 hstate_t from,
00608 delta_kind::kind<Kind> k) const
00609 {
00610 op_rdelta(this->structure(), this->value(), res, from, k);
00611 }
00612
00613 template <typename Self, typename T>
00614 template <typename OutputIterator, typename L, typename Kind>
00615 void
00616 MetaElement<AutomataBase<Self>, T>::rdelta(OutputIterator res,
00617 hstate_t from,
00618 const L& query,
00619 delta_kind::kind<Kind> k) const
00620 {
00621 op_rdelta(this->structure(), this->value(), res, from, query, k);
00622 }
00623
00624 template <typename Self, typename T>
00625 template <typename OutputIterator, typename L, typename Kind>
00626 void
00627 MetaElement<AutomataBase<Self>, T>::letter_rdelta(OutputIterator res,
00628 hstate_t from,
00629 const L& letter,
00630 delta_kind::kind<Kind> k) const
00631 {
00632 op_letter_rdelta(this->structure(), this->value(), res, from, letter, k);
00633 }
00634
00635 template <typename Self, typename T>
00636 template <typename OutputIterator, typename Kind>
00637 void
00638 MetaElement<AutomataBase<Self>, T>
00639 ::spontaneous_rdelta(OutputIterator res,
00640 hstate_t from,
00641 delta_kind::kind<Kind> k) const
00642 {
00643 return op_spontaneous_rdelta(this->structure(), this->value(), res, from, k);
00644 }
00645
00646
00647
00648
00649
00650 template <typename Self, typename T>
00651 template <typename Container, typename Kind>
00652 void
00653 MetaElement<AutomataBase<Self>, T>::rdeltac(Container& res, hstate_t from,
00654 delta_kind::kind<Kind> k) const
00655 {
00656 op_rdeltac(this->structure(), this->value(), res, from, k);
00657 }
00658
00659 template <typename Self, typename T>
00660 template <typename Container, typename L, typename Kind>
00661 void
00662 MetaElement<AutomataBase<Self>, T>::rdeltac(Container& res,
00663 hstate_t from,
00664 const L& query,
00665 delta_kind::kind<Kind> k) const
00666 {
00667 op_rdeltac(this->structure(), this->value(), res, from, query, k);
00668 }
00669
00670 template <typename Self, typename T>
00671 template <typename Container, typename L, typename Kind>
00672 void
00673 MetaElement<AutomataBase<Self>, T>::letter_rdeltac(Container& res,
00674 hstate_t from,
00675 const L& letter,
00676 delta_kind::kind<Kind> k) const
00677 {
00678 op_letter_rdeltac(this->structure(), this->value(), res, from, letter, k);
00679 }
00680
00681 template <typename Self, typename T>
00682 template <typename Container, typename Kind>
00683 void
00684 MetaElement<AutomataBase<Self>, T>
00685 ::spontaneous_rdeltac(Container& res,
00686 hstate_t from,
00687 delta_kind::kind<Kind> k) const
00688 {
00689 op_spontaneous_rdeltac(this->structure(), this->value(), res, from, k);
00690 }
00691
00692
00693
00694
00695
00696 template <typename Self, typename T>
00697 template <typename Functor, typename Kind>
00698 void
00699 MetaElement<AutomataBase<Self>, T>::rdeltaf(Functor& fun, hstate_t from,
00700 delta_kind::kind<Kind> k) const
00701 {
00702 op_rdeltaf(this->structure(), this->value(), fun, from, k);
00703 }
00704
00705 template <typename Self, typename T>
00706 template <typename Functor, typename L, typename Kind>
00707 void
00708 MetaElement<AutomataBase<Self>, T>::rdeltaf(Functor& fun,
00709 hstate_t from,
00710 const L& query,
00711 delta_kind::kind<Kind> k) const
00712 {
00713 op_rdeltaf(this->structure(), this->value(), fun, from, query, k);
00714 }
00715
00716 template <typename Self, typename T>
00717 template <typename Functor, typename L, typename Kind>
00718 void
00719 MetaElement<AutomataBase<Self>, T>::letter_rdeltaf(Functor& fun,
00720 hstate_t from,
00721 const L& letter,
00722 delta_kind::kind<Kind> k) const
00723 {
00724 op_letter_rdeltaf(this->structure(), this->value(), fun, from, letter, k);
00725 }
00726
00727 template <typename Self, typename T>
00728 template <typename Functor, typename Kind>
00729 void
00730 MetaElement<AutomataBase<Self>, T>
00731 ::spontaneous_rdeltaf(Functor& fun,
00732 hstate_t from,
00733 delta_kind::kind<Kind> k) const
00734 {
00735 op_spontaneous_rdeltaf(this->structure(), this->value(), fun, from, k);
00736 }
00737
00738
00739
00740 template<typename S, typename St, typename T>
00741 St& op_rout(const AutomataBase<S>& s, St& st, const T& v)
00742 {
00743 Element<S, T> r(s.self(), v);
00744 st << "{ "
00745 << r.states().size() << " states, "
00746 << r.transitions().size() << " transitions, "
00747 << "#I = " << r.initial().size() << ", "
00748 << "#T = " << r.final().size()
00749 << " }";
00750 return st;
00751 }
00752
00753
00754 }
00755
00756 #endif // ! VCSN_AUTOMATA_CONCEPT_AUTOMATA_BASE_HXX