automata_base.hh

00001 // automata_base.hh: this file is part of the Vaucanson project.
00002 //
00003 // Vaucanson, a generic library for finite state machines.
00004 //
00005 // Copyright (C) 2001, 2002, 2003, 2004, 2005 The Vaucanson Group.
00006 //
00007 // This program is free software; you can redistribute it and/or
00008 // modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2
00010 // of the License, or (at your option) any later version.
00011 //
00012 // The complete GNU General Public Licence Notice can be found as the
00013 // `COPYING' file in the root directory.
00014 //
00015 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
00016 //
00017 #ifndef VCSN_AUTOMATA_CONCEPT_AUTOMATA_BASE_HH
00018 # define VCSN_AUTOMATA_CONCEPT_AUTOMATA_BASE_HH
00019 
00020 # include <iterator>
00021 # include <vaucanson/design_pattern/design_pattern.hh>
00022 # include <vaucanson/automata/concept/handlers.hh>
00023 # include <vaucanson/automata/concept/delta_kind.hh>
00024 # include <vaucanson/algebra/concept/series_base.hh>
00025 
00026 namespace vcsn {
00027     
00031   /*-------------------.
00032   | AutomataBase<Self> |
00033   `-------------------*/
00035 
00039   template <typename Self>
00040   struct AutomataBase
00041     : Structure<Self>
00042   {
00043     public:
00045       typedef typename virtual_types<Self>::series_set_t  series_set_t;
00046 
00047     protected:
00049       AutomataBase();
00050 
00052       AutomataBase(const AutomataBase& other);
00053 
00054     public:
00056       const series_set_t& series() const;
00057   };
00058 
00059   // traits for automaton implementation.
00060   template <typename T>
00061   struct automaton_traits {
00062       typedef undefined_type label_t;
00063       typedef undefined_type series_set_elt_value_t;
00064       typedef undefined_type word_value_t;
00065       typedef undefined_type semiring_elt_value_t;
00066       typedef undefined_type letter_t;
00067       typedef undefined_type tag_t;
00068       typedef undefined_type states_t;
00069       typedef undefined_type state_data_t;
00070       typedef undefined_type state_iterator;
00071       typedef undefined_type transitions_t;
00072       typedef undefined_type transition_data_t;
00073       typedef undefined_type transition_iterator;
00074       typedef undefined_type initial_t;
00075       typedef undefined_type initial_iterator;
00076       typedef undefined_type initial_support_t;
00077       typedef undefined_type final_t;
00078       typedef undefined_type final_iterator;
00079       typedef undefined_type final_support_t;
00080       typedef undefined_type geometry_t;
00081   };
00082 
00083   /*-----------------------------------.
00084   | virtual_types<AutomataBase<Self> > |
00085   `-----------------------------------*/
00086   template <class S>
00087   struct virtual_types<AutomataBase<S> >
00088     : virtual_types<Structure<S> >
00089   { };
00090 
00091   /*------------------------------------.
00092   | dynamic_traits<AutomataBase<Self> > |
00093   `------------------------------------*/
00094   template <class S>
00095   struct dynamic_traits<AutomataBase<S> >
00096     : dynamic_traits<Structure<S> >
00097   { };
00098 
00099   /*-----------------------------------.
00100   | MetaElement<AutomataBase<Self>, T> |
00101   `-----------------------------------*/
00103 
00116   template <typename Self, typename T>
00117   struct MetaElement<AutomataBase<Self>, T>
00118     : MetaElement<Structure<Self>, T>
00119   {
00121       typedef MetaElement<AutomataBase<Self>, T>        self_t;
00122 
00124       typedef typename AutomataBase<Self>::series_set_t series_set_t;
00125 
00127       typedef typename automaton_traits<T>::series_set_elt_value_t
00128       series_set_elt_value_t;
00129 
00131       typedef Element<series_set_t, series_set_elt_value_t> series_set_elt_t;
00132 
00134       typedef typename series_set_t::monoid_t           monoid_t;
00135 
00137       typedef typename series_set_elt_t::monoid_elt_t   monoid_elt_t;
00138 
00140       typedef typename monoid_elt_t::value_t            monoid_elt_value_t;
00141 
00143       typedef typename monoid_t::letter_t               letter_t;
00144 
00146       typedef typename series_set_t::semiring_t         semiring_t;
00147 
00149       typedef typename series_set_elt_t::semiring_elt_t semiring_elt_t;
00150 
00152       typedef typename series_set_elt_t::semiring_elt_value_t
00153       semiring_elt_value_t;
00154 
00156       typedef typename automaton_traits<T>::tag_t               tag_t;
00157 
00159       typedef typename automaton_traits<T>::label_t     label_t;
00160 
00162       typedef typename automaton_traits<T>::states_t    states_t;
00163 
00165       typedef typename automaton_traits<T>::state_iterator state_iterator;
00166 
00168       typedef typename automaton_traits<T>::transitions_t transitions_t;
00169 
00171       typedef typename automaton_traits<T>::transition_iterator transition_iterator;
00172 
00174       typedef typename automaton_traits<T>::initial_t   initial_t;
00175 
00177       typedef typename automaton_traits<T>::initial_support_t initial_support_t;
00178 
00180       typedef typename automaton_traits<T>::initial_iterator initial_iterator;
00181 
00183       typedef typename automaton_traits<T>::final_t     final_t;
00184 
00186       typedef typename automaton_traits<T>::final_iterator final_iterator;
00187 
00189       typedef typename automaton_traits<T>::geometry_t  geometry_t;
00190 
00192       const series_set_t& series() const;
00193 
00195       tag_t& tag();
00196 
00198       const tag_t& tag() const;
00199 
00201       geometry_t& geometry();
00202 
00204       const geometry_t& geometry() const;
00205 
00207       bool exists() const;
00208 
00210       typename automaton_traits<T>::states_t
00211       states() const;
00212 
00214       typename automaton_traits<T>::transitions_t
00215       transitions() const;
00216 
00218       typename automaton_traits<T>::initial_support_t
00219       initial() const;
00220 
00222       typename automaton_traits<T>::final_support_t
00223       final() const;
00224 
00227       bool is_initial(hstate_t state) const;
00228 
00230       bool is_final(hstate_t state) const;
00231 
00233       void set_initial(hstate_t state);
00234 
00236       void set_initial(hstate_t state, const series_set_elt_t& m);
00237 
00239       void set_final(hstate_t state);
00240 
00242       void set_final(hstate_t state, const series_set_elt_t& m);
00243 
00245       void unset_initial(hstate_t state);
00246 
00248       void unset_final(hstate_t state);
00249 
00251       void clear_initial();
00252 
00254       void clear_final();
00255 
00257       Element<series_set_t, series_set_elt_value_t>
00258       get_initial(hstate_t state) const;
00259 
00261       Element<series_set_t, series_set_elt_value_t>
00262       get_final(hstate_t what) const;
00263 
00265       hstate_t add_state();
00266 
00269       hstate_t choose_state() const;
00270 
00272       htransition_t add_transition(hstate_t from, hstate_t to, const label_t& label);
00273 
00276       htransition_t add_weighted_transition(hstate_t from, hstate_t to,
00277                                             const semiring_elt_t& w,
00278                                             const monoid_elt_value_t& m);
00279 
00284       htransition_t add_series_transition(hstate_t from, hstate_t to,
00285                                           const series_set_elt_t& e);
00286 
00288       htransition_t add_spontaneous(hstate_t from, hstate_t to,
00289                                     const semiring_elt_t& w);
00290 
00291       htransition_t add_spontaneous(hstate_t from, hstate_t to);
00292 
00294       htransition_t add_letter_transition(hstate_t from, hstate_t to,
00295                                           const letter_t& l);
00296 
00298       void update(htransition_t e, const label_t& l);
00299 
00301       void del_state(hstate_t s);
00302 
00304       void del_transition(htransition_t e);
00305 
00307       bool has_state(hstate_t s) const;
00308 
00310       bool has_transition(htransition_t e) const;
00311 
00313       hstate_t src_of(htransition_t e) const;
00314 
00316       hstate_t dst_of(htransition_t e) const;
00317 
00319       typename automaton_traits<T>::label_t
00320       label_of(htransition_t e) const;
00321 
00323       series_set_elt_t series_of(htransition_t e) const;
00324 
00326       series_set_elt_value_t series_value_of(htransition_t e) const;
00327 
00329       bool is_spontaneous(htransition_t e) const;
00330 
00332       monoid_elt_t word_of(htransition_t e) const;
00333 
00335       semiring_elt_t weight_of(htransition_t e) const;
00336 
00338       monoid_elt_value_t word_value_of(htransition_t e) const;
00339 
00344       letter_t letter_of(htransition_t e) const;
00345 
00346       // output_return_type = OutputIterator
00347       // output_type        = htransition_t
00348       // direction        = output
00349 
00351       template <typename OutputIterator>
00352       void delta(OutputIterator res,
00353                  hstate_t from,
00354                  delta_kind::transitions k) const;
00355 
00358       template <typename OutputIterator, typename L>
00359       void delta(OutputIterator res,
00360                  hstate_t from,
00361                  const L& query,
00362                  delta_kind::transitions k) const;
00363 
00366       template <typename OutputIterator, typename L>
00367       void letter_delta(OutputIterator res,
00368                         hstate_t from,
00369                         const L& letter,
00370                         delta_kind::transitions k) const;
00371 
00373       template <typename OutputIterator>
00374       void spontaneous_delta(OutputIterator res,
00375                              hstate_t from,
00376                              delta_kind::transitions k) const;
00377 
00378       // output_return_type = Container
00379       // output_type        = htransition_t
00380       // direction        = output
00381 
00384       template <typename Container>
00385       void deltac(Container& res, hstate_t from, delta_kind::transitions k) const;
00386 
00389       template <typename Container, typename L>
00390       void deltac(Container& res,
00391                   hstate_t from,
00392                   const L& query,
00393                   delta_kind::transitions k) const;
00394 
00397       template <typename Container, typename L>
00398       void letter_deltac(Container& res,
00399                          hstate_t from,
00400                          const L& letter,
00401                          delta_kind::transitions k) const;
00402 
00404       template <typename Container>
00405       void spontaneous_deltac(Container& res,
00406                               hstate_t from,
00407                               delta_kind::transitions k) const;
00408 
00409       // output_return_type = OutputIterator
00410       // output_type        = hstate_t
00411       // direction        = output
00412 
00414       template <typename OutputIterator>
00415       void delta(OutputIterator res,
00416                  hstate_t from,
00417                  delta_kind::states k) const;
00418 
00421       template <typename OutputIterator, typename L>
00422       void delta(OutputIterator res,
00423                  hstate_t from,
00424                  const L& query,
00425                  delta_kind::states k) const;
00426 
00429       template <typename OutputIterator, typename L>
00430       void letter_delta(OutputIterator res,
00431                         hstate_t from,
00432                         const L& letter,
00433                         delta_kind::states k) const;
00434 
00436       template <typename OutputIterator>
00437       void spontaneous_delta(OutputIterator res,
00438                              hstate_t from,
00439                              delta_kind::states k) const;
00440 
00441       // output_return_type = Container
00442       // output_type        = hstate_t
00443       // direction        = output
00444 
00447       template <typename Container>
00448       void deltac(Container& res, hstate_t from, delta_kind::states k) const;
00449 
00452       template <typename Container, typename L>
00453       void deltac(Container& res,
00454                   hstate_t from,
00455                   const L& query,
00456                   delta_kind::states k) const;
00457 
00460       template <typename Container, typename L>
00461       void letter_deltac(Container& res,
00462                          hstate_t from,
00463                          const L& letter,
00464                          delta_kind::states k) const;
00465 
00467       template <typename Container>
00468       void spontaneous_deltac(Container& res,
00469                               hstate_t from,
00470                               delta_kind::states k) const;
00471 
00472       // output_return_type = OutputIterator
00473       // output_type        = htransition_t
00474       // direction        = input
00475 
00477       template <typename OutputIterator>
00478       void rdelta(OutputIterator res,
00479                   hstate_t from,
00480                   delta_kind::transitions k) const;
00481 
00484       template <typename OutputIterator, typename L>
00485       void rdelta(OutputIterator res,
00486                   hstate_t from,
00487                   const L& query,
00488                   delta_kind::transitions k) const;
00489 
00492       template <typename OutputIterator, typename L>
00493       void letter_rdelta(OutputIterator res,
00494                          hstate_t from,
00495                          const L& letter,
00496                          delta_kind::transitions k) const;
00497 
00499       template <typename OutputIterator>
00500       void spontaneous_rdelta(OutputIterator res,
00501                               hstate_t from,
00502                               delta_kind::transitions k) const;
00503 
00504       // output_return_type = Container
00505       // output_type        = htransition_t
00506       // direction        = input
00507 
00510       template <typename Container>
00511       void rdeltac(Container& res, hstate_t from, delta_kind::transitions k) const;
00512 
00515       template <typename Container, typename L>
00516       void rdeltac(Container& res,
00517                    hstate_t from,
00518                    const L& query,
00519                    delta_kind::transitions k) const;
00520 
00523       template <typename Container, typename L>
00524       void letter_rdeltac(Container& res,
00525                           hstate_t from,
00526                           const L& letter,
00527                           delta_kind::transitions k) const;
00528 
00530       template <typename Container>
00531       void spontaneous_rdeltac(Container& res,
00532                                hstate_t from,
00533                                delta_kind::transitions k) const;
00534 
00535 
00536       // output_return_type = OutputIterator
00537       // output_type        = hstate_t
00538       // direction        = input
00539 
00541       template <typename OutputIterator>
00542       void rdelta(OutputIterator res,
00543                   hstate_t from,
00544                   delta_kind::states k) const;
00545 
00548       template <typename OutputIterator, typename L>
00549       void rdelta(OutputIterator res,
00550                   hstate_t from,
00551                   const L& query,
00552                   delta_kind::states k) const;
00553 
00556       template <typename OutputIterator, typename L>
00557       void letter_rdelta(OutputIterator res,
00558                          hstate_t from,
00559                          const L& letter,
00560                          delta_kind::states k) const;
00561 
00563       template <typename OutputIterator>
00564       void spontaneous_rdelta(OutputIterator res,
00565                               hstate_t from,
00566                               delta_kind::states k) const;
00567 
00568       // output_return_type = Container
00569       // output_type        = hstate_t
00570       // direction        = input
00571 
00574       template <typename Container>
00575       void rdeltac(Container& res, hstate_t from, delta_kind::states k) const;
00576 
00579       template <typename Container, typename L>
00580       void rdeltac(Container& res,
00581                    hstate_t from,
00582                    const L& query,
00583                    delta_kind::states k) const;
00584 
00587       template <typename Container, typename L>
00588       void letter_rdeltac(Container& res,
00589                           hstate_t from,
00590                           const L& letter,
00591                           delta_kind::states k) const;
00592 
00594       template <typename Container>
00595       void spontaneous_rdeltac(Container& res,
00596                                hstate_t from,
00597                                delta_kind::states k) const;
00598 
00599     protected:
00600       MetaElement();
00601       MetaElement(const MetaElement& other);
00602   };
00603 
00606   template <typename S, typename St, typename T>
00607   St& op_rout(const AutomataBase<S>& s, St& st, const T& r);
00608 
00609 } // vcsn
00610 
00611 # ifndef VCSN_USE_INTERFACE_ONLY
00612 #  include <vaucanson/automata/concept/automata_base.hxx>
00613 # endif // VCSN_USE_INTERFACE_ONLY
00614 
00615 #endif // ! VCSN_AUTOMATA_CONCEPT_AUTOMATA_BASE_HH

Generated on Fri Jul 28 12:18:29 2006 for Vaucanson by  doxygen 1.4.6