automata.hh

00001 // automata.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, 2007, 2008 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_HH
00018 # define VCSN_AUTOMATA_CONCEPT_AUTOMATA_HH
00019 
00020 # include <vaucanson/automata/concept/automata_base.hh>
00021 # include <vaucanson/design_pattern/slots.hh>
00022 
00023 namespace vcsn
00024 {
00025 
00026   template <class Series>
00027   struct Automata;
00028 
00030   template <class Series>
00031   struct dynamic_traits<Automata<Series> >
00032     : dynamic_traits<AutomataBase<Automata<Series> > >
00033   {
00034       static const bool ret = dynamic_traits<Series>::ret;
00035   };
00036 
00038   template <class Series, typename T>
00039   struct MetaElement<Automata<Series>, T>
00040     : MetaElement<AutomataBase<Automata<Series> >, T>
00041   {};
00042 
00044   template <class Series>
00045   struct virtual_types<Automata<Series> >
00046     : virtual_types<AutomataBase<Automata<Series> > >
00047   {
00048       typedef Series series_set_t;
00049   };
00050 
00051 
00053   template <class Series>
00054   class Automata
00055     : public AutomataBase<Automata<Series> >,
00056       private SetSlot<Series>
00057   {
00058     public:
00059       typedef Automata<Series> self_t;
00060       typedef Series series_set_t;
00061 
00062       Automata(const series_set_t&);
00063 
00064       const series_set_t&       series() const;
00065   };
00066 
00067   template <typename S, typename T>
00068   struct projection_traits<Automata<S>, T>
00069   {
00070     typedef Automata<S> structure_t;
00071     typedef T impl_t;
00072 
00073     typedef Element<structure_t, impl_t> automaton_t;
00074 
00075     typedef typename automaton_t::series_set_elt_t series_set_elt_t;
00076 
00077     typedef typename structure_t::series_set_t series_set_t;
00078 
00079     typedef typename structure_t::series_set_t::semiring_t semiring_t;
00080 
00081     typedef typename structure_t::series_set_t::monoid_t monoid_t;
00082 
00083     typedef typename impl_t::monoid_elt_value_t monoid_elt_value_t;
00084 
00085     typedef typename monoid_t::alphabet_t alphabet_t;
00086 
00087     typedef typename algebra::alphabet_traits<typename alphabet_t::set_t,
00088                                               typename alphabet_t::value_t>
00089                                               alphabet_traits_t;
00090 
00091     typedef typename algebra::word_traits<monoid_t, monoid_elt_value_t>
00092                                           word_traits_t;
00093 
00094     typedef typename word_traits_t::first_monoid_t first_monoid_t;
00095 
00096     typedef typename word_traits_t::second_monoid_t second_monoid_t;
00097 
00098     typedef typename algebra::mute_series_traits<series_set_t,
00099                                                  semiring_t,
00100                                                  first_monoid_t>::ret
00101                                                  first_series_t;
00102 
00103     typedef typename algebra::mute_series_traits<series_set_t,
00104                                                  semiring_t,
00105                                                  second_monoid_t>::ret
00106                                                  second_series_t;
00107 
00108     typedef typename mute_graph_impl_traits<impl_t, word_traits_t>::
00109 	first_projection_t first_impl_t;
00110 
00111     typedef typename mute_graph_impl_traits<impl_t, word_traits_t>::
00112 	second_projection_t second_impl_t;
00113 
00114     typedef Element<Automata<first_series_t>, first_impl_t>
00115         first_projection_t;
00116 
00117     typedef Element<Automata<second_series_t>, second_impl_t>
00118         second_projection_t;
00119 
00120     // These are only "makers". Ie they will not contruct the projection.
00121     // See the relevant algorithms.
00122     static first_projection_t first_projection(const automaton_t&);
00123     static second_projection_t second_projection(const automaton_t&);
00124 
00125     typedef automaton_traits<first_impl_t> first_series_traits_t;
00126 
00127     typedef automaton_traits<second_impl_t> second_series_traits_t;
00128 
00129     typedef Element<first_series_t,
00130                     typename first_series_traits_t::series_set_elt_value_t>
00131         series_first_projection_t;
00132 
00133     typedef Element<second_series_t,
00134                     typename second_series_traits_t::series_set_elt_value_t>
00135         series_second_projection_t;
00136 
00137     // FIXME: As for now we limit series projection here. In the future,
00138     // we will move it in series_traits.
00139     static series_first_projection_t
00140         series_first_projection(const first_series_t&,
00141                                 const series_set_elt_t&);
00142     static series_second_projection_t
00143         series_second_projection(const second_series_t&,
00144                                  const series_set_elt_t&);
00145   };
00146 
00147 // Some usefull types to manipulate pair letters automaton.
00148 # define AUTOMATON_PROJECTION_TYPES()                                           \
00149       typedef algebra::alphabet_traits<alphabet_t::set_t,                       \
00150               alphabet_t::value_t> alphabet_traits_t;                           \
00151       typedef alphabet_traits_t::first_projection_t                             \
00152               first_projection_alphabet_t;                                      \
00153       typedef alphabet_traits_t::second_projection_t                            \
00154               second_projection_alphabet_t;                                     \
00155                                                                                 \
00156       typedef algebra::word_traits<monoid_elt_t::set_t,                         \
00157               monoid_elt_t::value_t> word_traits_t;                             \
00158       typedef word_traits_t::first_monoid_t first_monoid_t;                     \
00159       typedef word_traits_t::second_monoid_t second_monoid_t;                   \
00160       typedef word_traits_t::first_projection_t first_projection_word_t;        \
00161       typedef word_traits_t::second_projection_t second_projection_word_t;      \
00162                                                                                 \
00163       typedef projection_traits<automata_set_t, automaton_impl_t>               \
00164               projection_traits_t;                                              \
00165       typedef projection_traits_t::first_projection_t                           \
00166               first_projection_automaton_t;                                     \
00167       typedef projection_traits_t::second_projection_t                          \
00168               second_projection_automaton_t
00169 
00170   template <class Series>
00171   bool
00172   operator==(const Automata<Series>&, const Automata<Series>&);
00173 
00174 } // ! vcsn
00175 
00176 
00177 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
00178 #  include <vaucanson/automata/concept/automata.hxx>
00179 # endif // VCSN_USE_INTERFACE_ONLY
00180 
00181 
00182 #endif // ! VCSN_AUTOMATA_CONCEPT_AUTOMATA_HH

Generated on Thu Oct 9 20:22:33 2008 for Vaucanson by  doxygen 1.5.1