00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef VCSN_AUTOMATA_IMPLEMENTATION_AUTOMATON_VIEW_HXX
00018 # define VCSN_AUTOMATA_IMPLEMENTATION_AUTOMATON_VIEW_HXX
00019
00020 # include <vaucanson/misc/contract.hh>
00021 # include <vaucanson/automata/implementation/automaton_view.hh>
00022
00023 #define AutoType(Type) \
00024 typename Element<S, IdentityView<T> >::Type
00025
00026 namespace vcsn {
00027
00028 template <class T>
00029 IdentityView<T>::IdentityView()
00030 {}
00031
00032 template <class T>
00033 IdentityView<T>::IdentityView(T& d):
00034 object_(&d),
00035 const_object_(0)
00036 {}
00037
00038 template <class T>
00039 IdentityView<T>::IdentityView(const T& d):
00040 object_(0),
00041 const_object_(&d)
00042 {}
00043
00044 template <class T>
00045 IdentityView<T>::IdentityView(const IdentityView& d):
00046 object_(0)
00047 {
00048 assertion(d.object_ != 0 || d.const_object_ != 0);
00049 const_object_ = d.const_object_ == 0 ? d.object_ : d.const_object_;
00050 }
00051
00052 template <class T>
00053 const T&
00054 IdentityView<T>::object() const
00055 {
00056 assertion(object_ != 0 || const_object_ != 0);
00057 return const_object_ == 0 ? *object_ : *const_object_;
00058 }
00059
00060 template <class T>
00061 T&
00062 IdentityView<T>::object()
00063 {
00064 assertion(object_ != 0);
00065 assertion(const_object_ == 0);
00066 return *object_;
00067 }
00068
00069 template <class T>
00070 IdentityView<T>::operator T&()
00071 {
00072 assertion(object_ != 0);
00073 assertion(const_object_ == 0);
00074 return *object_;
00075 }
00076
00077 template <class T>
00078 IdentityView<T>::operator const T&() const
00079 {
00080 assertion(object_ != 0 || const_object_ != 0);
00081 return const_object_ == 0 ? *object_ : *const_object_;
00082 }
00083
00084 template <class S, class T>
00085 const typename automaton_traits<T>::tag_t&
00086 op_get_tag(const AutomataBase<S>& s, const IdentityView<T>& v)
00087 {
00088 return op_get_tag(s, v.object());
00089 }
00090
00091 template <class S, class T>
00092 typename automaton_traits<T>::tag_t&
00093 op_get_tag(const AutomataBase<S>& s, IdentityView<T>& v)
00094 {
00095 return op_get_tag(s, v.object());
00096 }
00097
00098 template <class S, class T>
00099 const typename automaton_traits<T>::geometry_t&
00100 op_get_geometry(const AutomataBase<S>& s, const IdentityView<T>& v)
00101 {
00102 return op_get_geometry(s, v.object());
00103 }
00104
00105 template <class S, class T>
00106 typename automaton_traits<T>::geometry_t&
00107 op_get_geometry(const AutomataBase<S>& s, IdentityView<T>& v)
00108 {
00109 return op_get_geometry(s, v.object());
00110 }
00111
00112 template <class S, class T>
00113 bool
00114 op_exists(const AutomataBase<S>& s, const IdentityView<T>& v)
00115 {
00116 return op_exists(s, v.object());
00117 }
00118
00119 template <class S, class T>
00120 typename automaton_traits<T>::states_t
00121 op_states(const AutomataBase<S>& s, const IdentityView<T>& v)
00122 {
00123 return op_states(s, v.object());
00124 }
00125
00126 template <class S, class T>
00127 typename automaton_traits<T>::transitions_t
00128 op_transitions(const AutomataBase<S>& s, const IdentityView<T>& v)
00129 {
00130 return op_transitions(s, v.object());
00131 }
00132
00133 template <class S, class T>
00134 typename automaton_traits<T>::initial_support_t
00135 op_initial(const AutomataBase<S>& s, const IdentityView<T>& v)
00136 {
00137 return op_initial(s, v.object());
00138 }
00139
00140 template <class S, class T>
00141 typename automaton_traits<T>::final_support_t
00142 op_final(const AutomataBase<S>& s, const IdentityView<T>& v)
00143 {
00144 return op_final(s, v.object());
00145 }
00146
00147 template <class S, class T>
00148 void
00149 op_set_initial(const AutomataBase<S>& ss, IdentityView<T>& v,
00150 hstate_t state,
00151 const AutoType(series_set_elt_t)& s)
00152 {
00153 return op_set_initial(ss, v.object(), state, s);
00154 }
00155
00156 template <class S, class T>
00157 AutoType(series_set_elt_t)
00158 op_get_initial(const AutomataBase<S>& s,
00159 const IdentityView<T>& v,
00160 hstate_t state)
00161 {
00162 return op_get_initial(s, v.object(), state);
00163 }
00164
00165 template <class S, class T>
00166 void
00167 op_set_final(const AutomataBase<S>& ss, IdentityView<T>& v,
00168 hstate_t state,
00169 const typename Element<S, T>::series_set_elt_t& s)
00170 {
00171 op_set_final(ss, v.object, state, s);
00172 }
00173
00174 template <class S, class T>
00175 typename Element<S, T>::series_set_elt_t
00176 op_get_final(const AutomataBase<S>& s,
00177 const IdentityView<T>& v,
00178 hstate_t state)
00179 {
00180 return op_get_final(s, v.object, state);
00181 }
00182
00183 template <class S, class T>
00184 void
00185 op_clear_initial(const AutomataBase<S>& s, IdentityView<T>& v)
00186 {
00187 op_clear_initial(s, v.object);
00188 }
00189
00190 template <class S, class T>
00191 void
00192 op_clear_final(const AutomataBase<S>& s, IdentityView<T>& v)
00193 {
00194 op_clear_final(s, v.object());
00195 }
00196
00197 template <class S, class T>
00198 hstate_t
00199 op_add_state(const AutomataBase<S>& s, IdentityView<T>& v)
00200 {
00201 return op_add_state(s, v.object());
00202 }
00203
00204 template <class S, class T>
00205 hstate_t
00206 op_choose_state(const AutomataBase<S>& s, IdentityView<T>& v)
00207 {
00208 return op_choose_state(s, v.object());
00209 }
00210
00211 template <class S, class T>
00212 htransition_t
00213 op_add_transition(const AutomataBase<S>& s, IdentityView<T>& v,
00214 hstate_t from,
00215 hstate_t to,
00216 const typename Element<S, T>::label_t& label)
00217 {
00218 return op_add_transition(s, v.object(), from, to, label);
00219 }
00220
00221 template <class S, class T>
00222 htransition_t
00223 op_add_series_transition(const AutomataBase<S>& s,
00224 IdentityView<T>& v,
00225 hstate_t from,
00226 hstate_t to,
00227 const typename Element<S, T>::series_set_elt_t& se)
00228 {
00229 return op_add_series_transition(s, v.object(), from, to, se);
00230 }
00231
00232 template <class S, class T>
00233 htransition_t
00234 op_add_spontaneous(const AutomataBase<S>& s, IdentityView<T>& v,
00235 hstate_t from,
00236 hstate_t to)
00237 {
00238 return op_add_spontaneous(s, v.object(), from, to);
00239 }
00240
00241 template <class S, class T>
00242 htransition_t
00243 op_add_letter_transition(const AutomataBase<S>& s, IdentityView<T>& v,
00244 hstate_t from,
00245 hstate_t to,
00246 const typename Element<S, T>::letter_t& e)
00247 {
00248 return op_add_letter_transition(s, v.object(), from, to, e);
00249 }
00250
00251 template <class S, class T>
00252 void
00253 op_update(const AutomataBase<S>& s, IdentityView<T>& v,
00254 htransition_t e,
00255 const AutoType(label_t)& l)
00256 {
00257 op_update(s, v.object(), e, l);
00258 }
00259
00260 template <class S, class T>
00261 void
00262 op_del_state(const AutomataBase<S>& s, IdentityView<T>& v,
00263 hstate_t st)
00264 {
00265 op_del_state(s, v.object(), st);
00266 }
00267
00268 template <class S, class T>
00269 void
00270 op_del_transition(const AutomataBase<S>& s, IdentityView<T>& v,
00271 htransition_t e)
00272 {
00273 op_del_transition(s, v.object(), e);
00274 }
00275
00276 template <class S, class T>
00277 bool
00278 op_has_state(const AutomataBase<S>& s,
00279 const IdentityView<T>& v,
00280 hstate_t st)
00281 {
00282 return op_has_state(s, v.object(), st);
00283 }
00284
00285 template <class S, class T>
00286 bool
00287 op_has_transition(const AutomataBase<S>& s,
00288 const IdentityView<T>& v,
00289 htransition_t e)
00290 {
00291 return op_has_transition(s, v.object(), e);
00292 }
00293
00294 template <class S, class T>
00295 hstate_t
00296 op_src_of(const AutomataBase<S>& s,
00297 const IdentityView<T>& v,
00298 htransition_t e)
00299 {
00300 return op_src_of(s, v.object(), e);
00301 }
00302
00303 template <class S, class T>
00304 hstate_t
00305 op_dst_of(const AutomataBase<S>& s,
00306 const IdentityView<T>& v,
00307 htransition_t e)
00308 {
00309 return op_dst_of(s, v.object(), e);
00310 }
00311
00312 template <class S, class T>
00313 typename Element<S, T>::label_t
00314 op_label_of(const AutomataBase<S>& s,
00315 const IdentityView<T>& v,
00316 htransition_t e)
00317 {
00318 return op_label_of(s, v.object(), e);
00319 }
00320
00321 template <class S, class T>
00322 const typename Element<S, T>::series_set_elt_t
00323 op_series_of(const AutomataBase<S>& s,
00324 const IdentityView<T>& v,
00325 htransition_t e)
00326 {
00327 return op_series_of(s, v.object(), e);
00328 }
00329
00330 template <class S, class T>
00331 typename Element<S, T>::series_set_elt_value_t
00332 op_series_value_of(const AutomataBase<S>& s,
00333 const IdentityView<T>& v,
00334 htransition_t e)
00335 {
00336 return op_series_value_of(s, v.object(), e);
00337 }
00338
00339 template <class S, class T>
00340 typename Element<S, T>::monoid_elt_t
00341 op_word_of(const AutomataBase<S>& s,
00342 const IdentityView<T>& v,
00343 htransition_t e)
00344 {
00345 return op_word_of(s, v.object(), e);
00346 }
00347
00348 template <class S, class T>
00349 typename Element<S, T>::monoid_elt_value_t
00350 op_word_value_of(const AutomataBase<S>& s,
00351 const IdentityView<T>& v,
00352 htransition_t e)
00353 {
00354 return op_word_value_of(s, v.object(), e);
00355 }
00356
00357 template <class S, class T>
00358 typename Element<S, T>::letter_t
00359 op_letter_of(const AutomataBase<S>& s,
00360 const IdentityView<T>& v,
00361 htransition_t e)
00362 {
00363 return op_letter_of(s, v.object(), e);
00364 }
00365
00366 template <class S, class T>
00367 bool
00368 op_is_spontaneous(const AutomataBase<S>& s,
00369 const IdentityView<T>& v,
00370 htransition_t e)
00371 {
00372 return op_is_spontaneous(s, v.object(), e);
00373 }
00374
00375
00376
00377
00378
00379 template <class S, class T,
00380 typename OutputIterator>
00381 void op_delta(const AutomataBase<S>& s,
00382 const IdentityView<T>& v,
00383 OutputIterator res,
00384 hstate_t from,
00385 delta_kind::transitions k)
00386 {
00387 op_delta(s, v.object(), res, from, k);
00388 }
00389
00390 template <class S, class T,
00391 typename OutputIterator, typename L>
00392 void op_delta(const AutomataBase<S>& s,
00393 const IdentityView<T>& v,
00394 OutputIterator res,
00395 hstate_t from,
00396 const L& query,
00397 delta_kind::transitions k)
00398 {
00399 op_delta(s, v.object(), res, from, query, k);
00400 }
00401
00402 template <class S, class T,
00403 typename OutputIterator, typename L>
00404 void op_letter_delta(const AutomataBase<S>& s,
00405 const IdentityView<T>& v,
00406 OutputIterator res,
00407 hstate_t from,
00408 const L& letter,
00409 delta_kind::transitions k)
00410 {
00411 op_letter_delta(s, v.object(), res, from, letter, k);
00412 }
00413
00414 template <class S, class T,
00415 typename OutputIterator>
00416 void op_spontaneous_delta(const AutomataBase<S>& s,
00417 const IdentityView<T>& v,
00418 OutputIterator res,
00419 hstate_t from,
00420 delta_kind::transitions k)
00421 {
00422 op_spontaneous_delta(s, v.object(), res, from, k);
00423 }
00424
00425
00426
00427
00428
00429 template <class S, class T,
00430 typename Container>
00431 void op_deltac(const AutomataBase<S>& s,
00432 const IdentityView<T>& v,
00433 Container& res, hstate_t from, delta_kind::transitions k)
00434 {
00435 op_deltac(s, v.object(), res, from, k);
00436 }
00437
00438 template <class S, class T,
00439 typename Container, typename L>
00440 void op_deltac(const AutomataBase<S>& s,
00441 const IdentityView<T>& v,
00442 Container& res,
00443 hstate_t from,
00444 const L& query,
00445 delta_kind::transitions k)
00446 {
00447 op_deltac(s, v.object(), res, from, query, k);
00448 }
00449
00450 template <class S, class T,
00451 typename Container, typename L>
00452 void op_letter_deltac(const AutomataBase<S>& s,
00453 const IdentityView<T>& v,
00454 Container& res,
00455 hstate_t from,
00456 const L& letter,
00457 delta_kind::transitions k)
00458 {
00459 op_letter_deltac(s, v.object(), res, from, letter, k);
00460 }
00461
00462 template <class S, class T, class Container>
00463 void op_spontaneous_deltac(const AutomataBase<S>& s,
00464 const IdentityView<T>& v,
00465 Container& res,
00466 hstate_t from,
00467 delta_kind::transitions k)
00468 {
00469 op_spontaneous_deltac(s, v.object(), res, from, k);
00470 }
00471
00472
00473
00474
00475
00476 template<class S, class T, typename OutputIterator>
00477 void op_delta(const AutomataBase<S>& s,
00478 const IdentityView<T>& v,
00479 OutputIterator res,
00480 hstate_t from,
00481 delta_kind::states k)
00482 {
00483 op_delta(s, v.object(), res, from, k);
00484 }
00485
00486 template<class S, class T, typename OutputIterator, typename L>
00487 void op_delta(const AutomataBase<S>& s,
00488 const IdentityView<T>& v,
00489 OutputIterator res,
00490 hstate_t from,
00491 const L& query,
00492 delta_kind::states k)
00493 {
00494 op_delta(s, v.object(), res, from, query, k);
00495 }
00496
00497 template<class S, class T, typename OutputIterator, typename L>
00498 void op_letter_delta(const AutomataBase<S>& s,
00499 const IdentityView<T>& v,
00500 OutputIterator res,
00501 hstate_t from,
00502 const L& letter,
00503 delta_kind::states k)
00504 {
00505 op_letter_delta(s, v.object(), res, from, letter, k);
00506 }
00507
00508 template<class S, class T, typename OutputIterator>
00509 void op_spontaneous_delta(const AutomataBase<S>& s,
00510 const IdentityView<T>& v,
00511 OutputIterator res,
00512 hstate_t from,
00513 delta_kind::states k)
00514 {
00515 op_spontaneous_delta(s, v.object(), res, from, k);
00516 }
00517
00518
00519
00520
00521
00522 template<class S, class T, typename Container>
00523 void op_deltac(const AutomataBase<S>& s,
00524 const IdentityView<T>& v,
00525 Container& res, hstate_t from, delta_kind::states k)
00526 {
00527 op_delta(s, v.object(), res, from, k);
00528 }
00529
00530 template<class S, class T, typename Container, typename L>
00531 void op_deltac(const AutomataBase<S>& s,
00532 const IdentityView<T>& v,
00533 Container& res,
00534 hstate_t from,
00535 const L& query,
00536 delta_kind::states k)
00537 {
00538 op_deltac(s, v.object(), res, from, k);
00539 }
00540
00541 template<class S, class T, typename Container, typename L>
00542 void op_letter_deltac(const AutomataBase<S>& s,
00543 const IdentityView<T>& v,
00544 Container& res,
00545 hstate_t from,
00546 const L& letter,
00547 delta_kind::states k)
00548 {
00549 op_letter_deltac(s, v.object(), res, from, letter, k);
00550 }
00551
00552 template<class S, class T, typename Container>
00553 void op_spontaneous_deltac(const AutomataBase<S>& s,
00554 const IdentityView<T>& v,
00555 Container& res,
00556 hstate_t from,
00557 delta_kind::states k)
00558 {
00559 op_spontaneous_deltac(s, v.object(), res, from, k);
00560 }
00561
00562
00563
00564
00565
00566 template<class S, class T, typename OutputIterator>
00567 void op_rdelta(const AutomataBase<S>& s, const IdentityView<T>& v,
00568 OutputIterator res,
00569 hstate_t from,
00570 delta_kind::transitions k)
00571 {
00572 op_rdelta(s, v.object(), res, from, k);
00573 }
00574
00575 template<class S, class T, typename OutputIterator, typename L>
00576 void op_rdelta(const AutomataBase<S>& s, const IdentityView<T>& v,
00577 OutputIterator res,
00578 hstate_t from,
00579 const L& query,
00580 delta_kind::transitions k)
00581 {
00582 op_rdelta(s, v.object(), res, from, query, k);
00583 }
00584
00585 template<class S, class T, typename OutputIterator, typename L>
00586 void op_letter_rdelta(const AutomataBase<S>& s, const IdentityView<T>& v,
00587 OutputIterator res,
00588 hstate_t from,
00589 const L& letter,
00590 delta_kind::transitions k)
00591 {
00592 op_letter_rdelta(s, v.object(), res, from, letter, k);
00593 }
00594
00595 template<class S, class T, typename OutputIterator>
00596 void op_spontaneous_rdelta(const AutomataBase<S>& s,
00597 const IdentityView<T>& v,
00598 OutputIterator res,
00599 hstate_t from,
00600 delta_kind::transitions k)
00601 {
00602 op_spontaneous_rdelta(s, v.object(), res, from, k);
00603 }
00604
00605
00606
00607
00608
00609 template<class S, class T, typename Container>
00610 void op_rdeltac(const AutomataBase<S>& s, const IdentityView<T>& v,
00611 Container& res, hstate_t from, delta_kind::transitions k)
00612 {
00613 op_rdeltac(s, v.object(), res, from, k);
00614 }
00615
00616 template<class S, class T, typename Container, typename L>
00617 void op_rdeltac(const AutomataBase<S>& s, const IdentityView<T>& v,
00618 Container& res,
00619 hstate_t from,
00620 const L& query,
00621 delta_kind::transitions k)
00622 {
00623 op_rdeltac(s, v.object(), res, from, query, k);
00624 }
00625
00626 template<class S, class T, typename Container, typename L>
00627 void op_letter_rdeltac(const AutomataBase<S>& s, const IdentityView<T>& v,
00628 Container& res,
00629 hstate_t from,
00630 const L& letter,
00631 delta_kind::transitions k)
00632 {
00633 op_letter_rdeltac(s, v.object(), res, from, letter, k);
00634 }
00635
00636 template<class S, class T, typename Container>
00637 void op_spontaneous_rdeltac(const AutomataBase<S>& s,
00638 const IdentityView<T>& v,
00639 Container& res,
00640 hstate_t from,
00641 delta_kind::transitions k)
00642 {
00643 op_spontaneous_rdeltac(s, v.object(), res, from, k);
00644 }
00645
00646
00647
00648
00649
00650 template<class S, class T, typename OutputIterator>
00651 void op_rdelta(const AutomataBase<S>& s, const IdentityView<T>& v,
00652 OutputIterator res,
00653 hstate_t from,
00654 delta_kind::states k)
00655 {
00656 op_rdelta(s, v.object(), res, from, k);
00657 }
00658
00659 template<class S, class T, typename OutputIterator, typename L>
00660 void op_rdelta(const AutomataBase<S>& s, const IdentityView<T>& v,
00661 OutputIterator res,
00662 hstate_t from,
00663 const L& query,
00664 delta_kind::states k)
00665 {
00666 op_rdelta(s, v.object(), res, from, query, k);
00667 }
00668
00669 template<class S, class T, typename OutputIterator, typename L>
00670 void op_letter_rdelta(const AutomataBase<S>& s, const IdentityView<T>& v,
00671 OutputIterator res,
00672 hstate_t from,
00673 const L& letter,
00674 delta_kind::states k)
00675 {
00676 op_letter_rdelta(s, v.object(), res, from, letter, k);
00677 }
00678
00679 template<class S, class T, typename OutputIterator>
00680 void op_spontaneous_rdelta(const AutomataBase<S>& s,
00681 const IdentityView<T>& v,
00682 OutputIterator res,
00683 hstate_t from,
00684 delta_kind::states k)
00685 {
00686 op_spontaneous_rdelta(s, v.object(), res, from, k);
00687 }
00688
00689
00690
00691
00692
00693 template<class S, class T, typename Container>
00694 void op_rdeltac(const AutomataBase<S>& s, const IdentityView<T>& v,
00695 Container& res, hstate_t from, delta_kind::states k)
00696 {
00697 op_rdeltac(s, v.object(), res, from, k);
00698 }
00699
00700 template<class S, class T, typename Container, typename L>
00701 void op_rdeltac(const AutomataBase<S>& s, const IdentityView<T>& v,
00702 Container& res,
00703 hstate_t from,
00704 const L& query,
00705 delta_kind::states k)
00706 {
00707 op_rdeltac(s, v.object(), res, from, query, k);
00708 }
00709
00710 template<class S, class T, typename Container, typename L>
00711 void op_letter_rdeltac(const AutomataBase<S>& s, const IdentityView<T>& v,
00712 Container& res,
00713 hstate_t from,
00714 const L& letter,
00715 delta_kind::states k)
00716 {
00717 op_letter_rdeltac(s, v.object(), res, from, letter, k);
00718 }
00719
00720 template<class S, class T, typename Container>
00721 void op_spontaneous_rdeltac(const AutomataBase<S>& s,
00722 const IdentityView<T>& v,
00723 Container& res,
00724 hstate_t from,
00725 delta_kind::states k)
00726 {
00727 op_spontaneous_rldeltac(s, v.object(), res, from, k);
00728 }
00729
00730 }
00731
00732 # undef AutoType
00733
00734 #endif // ! VCSN_AUTOMATA_IMPLEMENTATION_AUTOMATON_VIEW_HXX