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 src,
00274 hstate_t dst,
00275 const label_t& label)
00276 {
00277 return op_add_transition(this->structure(), this->value(),
00278 src, dst, label);
00279 }
00280
00282 template <typename Self, typename T>
00283 htransition_t
00284 MetaElement<AutomataBase<Self>, T>::
00285 add_weighted_transition(hstate_t src,
00286 hstate_t dst,
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 src, dst, w, m);
00292 }
00293
00297 template <typename Self, typename T>
00298 htransition_t
00299 MetaElement<AutomataBase<Self>, T>::add_series_transition(hstate_t src,
00300 hstate_t dst,
00301 const series_set_elt_t& e)
00302 {
00303 return op_add_series_transition(this->structure(), this->value(),
00304 src, dst, e);
00305 }
00306
00308 template <typename Self, typename T>
00309 htransition_t
00310 MetaElement<AutomataBase<Self>, T>::add_spontaneous(hstate_t src,
00311 hstate_t dst)
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(), src, dst, w);
00317 }
00318
00319 template <typename Self, typename T>
00320 htransition_t
00321 MetaElement<AutomataBase<Self>, T>::add_spontaneous(hstate_t src,
00322 hstate_t dst,
00323 const semiring_elt_t& w)
00324 {
00325 return op_add_spontaneous(this->structure(), this->value(), src, dst, w);
00326 }
00327
00329 template <typename Self, typename T>
00330 htransition_t
00331 MetaElement<AutomataBase<Self>, T>::add_letter_transition(hstate_t src,
00332 hstate_t dst,
00333 const letter_t& l)
00334 {
00335 return op_add_letter_transition(this->structure(), this->value(),
00336 src, dst, l);
00337 }
00338
00340 template <typename Self, typename T>
00341 void
00342 MetaElement<AutomataBase<Self>, T>::update(htransition_t e, const label_t& l)
00343 {
00344 op_update(this->structure(), this->value(), e, l);
00345 }
00346
00348 template <typename Self, typename T>
00349 void
00350 MetaElement<AutomataBase<Self>, T>::del_state(hstate_t s)
00351 {
00352 return op_del_state(this->structure(), this->value(), s);
00353 }
00354
00356 template <typename Self, typename T>
00357 void
00358 MetaElement<AutomataBase<Self>, T>::del_transition(htransition_t e)
00359 {
00360 return op_del_transition(this->structure(), this->value(), e);
00361 }
00362
00364 template <typename Self, typename T>
00365 bool
00366 MetaElement<AutomataBase<Self>, T>::has_state(hstate_t s) const
00367 {
00368 return op_has_state(this->structure(), this->value(), s);
00369 }
00370
00372 template <typename Self, typename T>
00373 bool
00374 MetaElement<AutomataBase<Self>, T>::has_transition(htransition_t e) const
00375 {
00376 return op_has_transition(this->structure(), this->value(), e);
00377 }
00378
00380 template <typename Self, typename T>
00381 hstate_t
00382 MetaElement<AutomataBase<Self>, T>::src_of(htransition_t e) const
00383 {
00384 return op_src_of(this->structure(), this->value(), e);
00385 }
00386
00388 template <typename Self, typename T>
00389 hstate_t
00390 MetaElement<AutomataBase<Self>, T>::dst_of(htransition_t e) const
00391 {
00392 return op_dst_of(this->structure(), this->value(), e);
00393 }
00394
00396 template <typename Self, typename T>
00397 typename automaton_traits<T>::label_t
00398 MetaElement<AutomataBase<Self>, T>::label_of(htransition_t e) const
00399 {
00400 return op_label_of(this->structure(), this->value(), e);
00401 }
00402
00404 template <typename Self, typename T>
00405 typename MetaElement<AutomataBase<Self>, T>::series_set_elt_t
00406 MetaElement<AutomataBase<Self>, T>::series_of(htransition_t e) const
00407 {
00408 return op_series_of(this->structure(), this->value(), e);
00409 }
00410
00412 template <typename Self, typename T>
00413 typename MetaElement<AutomataBase<Self>, T>::series_set_elt_value_t
00414 MetaElement<AutomataBase<Self>, T>::series_value_of(htransition_t e) const
00415 {
00416 return op_series_value_of(this->structure(), this->value(), e);
00417 }
00418
00420 template <typename Self, typename T>
00421 bool
00422 MetaElement<AutomataBase<Self>, T>::is_spontaneous(htransition_t e) const
00423 {
00424 return op_is_spontaneous(this->structure(), this->value(), e);
00425 }
00426
00428 template <typename Self, typename T>
00429 typename MetaElement<AutomataBase<Self>, T>::monoid_elt_t
00430 MetaElement<AutomataBase<Self>, T>::word_of(htransition_t e) const
00431 {
00432 return op_word_of(this->structure(), this->value(), e);
00433 }
00434
00436 template <typename Self, typename T>
00437 typename MetaElement<AutomataBase<Self>, T>::semiring_elt_t
00438 MetaElement<AutomataBase<Self>, T>::weight_of(htransition_t e) const
00439 {
00440 return op_weight_of(this->structure(), this->value(), e);
00441 }
00442
00444 template <typename Self, typename T>
00445 typename MetaElement<AutomataBase<Self>, T>::monoid_elt_value_t
00446 MetaElement<AutomataBase<Self>, T>::word_value_of(htransition_t e) const
00447 {
00448 return op_word_value_of(this->structure(), this->value(), e);
00449 }
00450
00454 template <typename Self, typename T>
00455 typename MetaElement<AutomataBase<Self>, T>::letter_t
00456 MetaElement<AutomataBase<Self>, T>::letter_of(htransition_t e) const
00457 {
00458 return op_letter_of(this->structure(), this->value(), e);
00459 }
00460
00461
00462
00463
00464
00465 template <typename Self, typename T>
00466 template <typename OutputIterator, typename Kind>
00467 void
00468 MetaElement<AutomataBase<Self>, T>::delta(OutputIterator res,
00469 hstate_t src,
00470 delta_kind::kind<Kind> k) const
00471 {
00472 op_delta(this->structure(), this->value(), res, src, k);
00473 }
00474
00475 template <typename Self, typename T>
00476 template <typename OutputIterator, typename L, typename Kind>
00477 void
00478 MetaElement<AutomataBase<Self>, T>::delta(OutputIterator res,
00479 hstate_t src,
00480 const L& query,
00481 delta_kind::kind<Kind> k) const
00482 {
00483 op_delta(this->structure(), this->value(), res, src, query, k);
00484 }
00485
00486 template <typename Self, typename T>
00487 template <typename OutputIterator, typename L, typename Kind>
00488 void
00489 MetaElement<AutomataBase<Self>, T>::letter_delta(OutputIterator res,
00490 hstate_t src,
00491 const L& letter,
00492 delta_kind::kind<Kind> k) const
00493 {
00494 op_letter_delta(this->structure(), this->value(), res, src, letter, k);
00495 }
00496
00497 template <typename Self, typename T>
00498 template <typename OutputIterator, typename Kind>
00499 void
00500 MetaElement<AutomataBase<Self>, T>
00501 ::spontaneous_delta(OutputIterator res,
00502 hstate_t src,
00503 delta_kind::kind<Kind> k) const
00504 {
00505 return op_spontaneous_delta(this->structure(), this->value(), res, src, k);
00506 }
00507
00508
00509
00510
00511
00512 template <typename Self, typename T>
00513 template <typename Container, typename Kind>
00514 void
00515 MetaElement<AutomataBase<Self>, T>::deltac(Container& res, hstate_t src,
00516 delta_kind::kind<Kind> k) const
00517 {
00518 op_deltac(this->structure(), this->value(), res, src, k);
00519 }
00520
00521 template <typename Self, typename T>
00522 template <typename Container, typename L, typename Kind>
00523 void
00524 MetaElement<AutomataBase<Self>, T>::deltac(Container& res,
00525 hstate_t src,
00526 const L& query,
00527 delta_kind::kind<Kind> k) const
00528 {
00529 op_deltac(this->structure(), this->value(), res, src, query, k);
00530 }
00531
00532 template <typename Self, typename T>
00533 template <typename Container, typename L, typename Kind>
00534 void
00535 MetaElement<AutomataBase<Self>, T>::letter_deltac(Container& res,
00536 hstate_t src,
00537 const L& letter,
00538 delta_kind::kind<Kind> k) const
00539 {
00540 op_letter_deltac(this->structure(), this->value(), res, src, letter, k);
00541 }
00542
00543 template <typename Self, typename T>
00544 template <typename Container, typename Kind>
00545 void
00546 MetaElement<AutomataBase<Self>, T>
00547 ::spontaneous_deltac(Container& res,
00548 hstate_t src,
00549 delta_kind::kind<Kind> k) const
00550 {
00551 op_spontaneous_deltac(this->structure(), this->value(), res, src, k);
00552 }
00553
00554
00555
00556
00557
00558 template <typename Self, typename T>
00559 template <typename Functor, typename Kind>
00560 void
00561 MetaElement<AutomataBase<Self>, T>::deltaf(Functor& fun, hstate_t src,
00562 delta_kind::kind<Kind> k) const
00563 {
00564 op_deltaf(this->structure(), this->value(), fun, src, k);
00565 }
00566
00567 template <typename Self, typename T>
00568 template <typename Functor, typename L, typename Kind>
00569 void
00570 MetaElement<AutomataBase<Self>, T>::deltaf(Functor& fun,
00571 hstate_t src,
00572 const L& query,
00573 delta_kind::kind<Kind> k) const
00574 {
00575 op_deltaf(this->structure(), this->value(), fun, src, query, k);
00576 }
00577
00578 template <typename Self, typename T>
00579 template <typename Functor, typename L, typename Kind>
00580 void
00581 MetaElement<AutomataBase<Self>, T>::letter_deltaf(Functor& fun,
00582 hstate_t src,
00583 const L& letter,
00584 delta_kind::kind<Kind> k) const
00585 {
00586 op_letter_deltaf(this->structure(), this->value(), fun, src, letter, k);
00587 }
00588
00589 template <typename Self, typename T>
00590 template <typename Functor, typename Kind>
00591 void
00592 MetaElement<AutomataBase<Self>, T>
00593 ::spontaneous_deltaf(Functor& fun,
00594 hstate_t src,
00595 delta_kind::kind<Kind> k) const
00596 {
00597 op_spontaneous_deltaf(this->structure(), this->value(), fun, src, k);
00598 }
00599
00600
00601
00602
00603
00604 template <typename Self, typename T>
00605 template <typename OutputIterator, typename Kind>
00606 void
00607 MetaElement<AutomataBase<Self>, T>::rdelta(OutputIterator res,
00608 hstate_t src,
00609 delta_kind::kind<Kind> k) const
00610 {
00611 op_rdelta(this->structure(), this->value(), res, src, k);
00612 }
00613
00614 template <typename Self, typename T>
00615 template <typename OutputIterator, typename L, typename Kind>
00616 void
00617 MetaElement<AutomataBase<Self>, T>::rdelta(OutputIterator res,
00618 hstate_t src,
00619 const L& query,
00620 delta_kind::kind<Kind> k) const
00621 {
00622 op_rdelta(this->structure(), this->value(), res, src, query, k);
00623 }
00624
00625 template <typename Self, typename T>
00626 template <typename OutputIterator, typename L, typename Kind>
00627 void
00628 MetaElement<AutomataBase<Self>, T>::letter_rdelta(OutputIterator res,
00629 hstate_t src,
00630 const L& letter,
00631 delta_kind::kind<Kind> k) const
00632 {
00633 op_letter_rdelta(this->structure(), this->value(), res, src, letter, k);
00634 }
00635
00636 template <typename Self, typename T>
00637 template <typename OutputIterator, typename Kind>
00638 void
00639 MetaElement<AutomataBase<Self>, T>
00640 ::spontaneous_rdelta(OutputIterator res,
00641 hstate_t src,
00642 delta_kind::kind<Kind> k) const
00643 {
00644 return op_spontaneous_rdelta(this->structure(), this->value(), res, src, k);
00645 }
00646
00647
00648
00649
00650
00651 template <typename Self, typename T>
00652 template <typename Container, typename Kind>
00653 void
00654 MetaElement<AutomataBase<Self>, T>::rdeltac(Container& res, hstate_t src,
00655 delta_kind::kind<Kind> k) const
00656 {
00657 op_rdeltac(this->structure(), this->value(), res, src, k);
00658 }
00659
00660 template <typename Self, typename T>
00661 template <typename Container, typename L, typename Kind>
00662 void
00663 MetaElement<AutomataBase<Self>, T>::rdeltac(Container& res,
00664 hstate_t src,
00665 const L& query,
00666 delta_kind::kind<Kind> k) const
00667 {
00668 op_rdeltac(this->structure(), this->value(), res, src, query, k);
00669 }
00670
00671 template <typename Self, typename T>
00672 template <typename Container, typename L, typename Kind>
00673 void
00674 MetaElement<AutomataBase<Self>, T>::letter_rdeltac(Container& res,
00675 hstate_t src,
00676 const L& letter,
00677 delta_kind::kind<Kind> k) const
00678 {
00679 op_letter_rdeltac(this->structure(), this->value(), res, src, letter, k);
00680 }
00681
00682 template <typename Self, typename T>
00683 template <typename Container, typename Kind>
00684 void
00685 MetaElement<AutomataBase<Self>, T>
00686 ::spontaneous_rdeltac(Container& res,
00687 hstate_t src,
00688 delta_kind::kind<Kind> k) const
00689 {
00690 op_spontaneous_rdeltac(this->structure(), this->value(), res, src, k);
00691 }
00692
00693
00694
00695
00696
00697 template <typename Self, typename T>
00698 template <typename Functor, typename Kind>
00699 void
00700 MetaElement<AutomataBase<Self>, T>::rdeltaf(Functor& fun, hstate_t src,
00701 delta_kind::kind<Kind> k) const
00702 {
00703 op_rdeltaf(this->structure(), this->value(), fun, src, k);
00704 }
00705
00706 template <typename Self, typename T>
00707 template <typename Functor, typename L, typename Kind>
00708 void
00709 MetaElement<AutomataBase<Self>, T>::rdeltaf(Functor& fun,
00710 hstate_t src,
00711 const L& query,
00712 delta_kind::kind<Kind> k) const
00713 {
00714 op_rdeltaf(this->structure(), this->value(), fun, src, query, k);
00715 }
00716
00717 template <typename Self, typename T>
00718 template <typename Functor, typename L, typename Kind>
00719 void
00720 MetaElement<AutomataBase<Self>, T>::letter_rdeltaf(Functor& fun,
00721 hstate_t src,
00722 const L& letter,
00723 delta_kind::kind<Kind> k) const
00724 {
00725 op_letter_rdeltaf(this->structure(), this->value(), fun, src, letter, k);
00726 }
00727
00728 template <typename Self, typename T>
00729 template <typename Functor, typename Kind>
00730 void
00731 MetaElement<AutomataBase<Self>, T>
00732 ::spontaneous_rdeltaf(Functor& fun,
00733 hstate_t src,
00734 delta_kind::kind<Kind> k) const
00735 {
00736 op_spontaneous_rdeltaf(this->structure(), this->value(), fun, src, k);
00737 }
00738
00739
00740
00741 template<typename S, typename St, typename T>
00742 St& op_rout(const AutomataBase<S>& s, St& st, const T& v)
00743 {
00744 Element<S, T> r(s.self(), v);
00745 st << "{ "
00746 << r.states().size() << " states, "
00747 << r.transitions().size() << " transitions, "
00748 << "#I = " << r.initial().size() << ", "
00749 << "#T = " << r.final().size()
00750 << " }";
00751 return st;
00752 }
00753
00754
00755 }
00756
00757 #endif // ! VCSN_AUTOMATA_CONCEPT_AUTOMATA_BASE_HXX