transducer.hh

00001 // transducer.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, 2006, 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_TRANSDUCER_HH
00018 # define VCSN_AUTOMATA_CONCEPT_TRANSDUCER_HH
00019 
00020 # include <vaucanson/design_pattern/design_pattern.hh>
00021 # include <vaucanson/automata/concept/automata.hh>
00022 # include <vaucanson/automata/concept/automata_base.hh>
00023 # include <vaucanson/automata/concept/transducer_base.hh>
00024 
00025 namespace vcsn {
00026 
00027   template <class Series>
00028   struct Transducer;
00029 
00031   template <class Series>
00032   struct dynamic_traits<Transducer<Series> >
00033     : dynamic_traits<TransducerBase<Series> >
00034   {
00035     static const bool ret = dynamic_traits<Series>::ret;
00036   };
00037 
00039   template <class Series, typename T>
00040   struct MetaElement<Transducer<Series>, T>
00041     : MetaElement<TransducerBase<Transducer<Series> >, T>
00042   {};
00043 
00045   template <class Series>
00046   struct virtual_types<Transducer<Series> >
00047   {
00048     typedef Series              series_set_t;
00049   };
00050 
00052   template <class Series>
00053   class Transducer
00054     : public TransducerBase<Transducer<Series> >,
00055       private SetSlot<Series>
00056   {
00057   public:
00058     typedef Transducer<Series>                               self_t;
00059     typedef typename virtual_types<self_t>::series_set_t     series_set_t;
00060 
00061     Transducer(const series_set_t&);
00062 
00063     const series_set_t& series() const;
00064 
00065   };
00066 
00067 
00068   /*------------------------.
00069   | INPUT PROJECTION TRAITS |
00070   `------------------------*/
00071 
00072   template <class S, class T>
00073   struct input_projection_helper
00074   { };
00075 
00076   template <class S, class T>
00077   struct input_projection_helper<Transducer<S>, T>
00078   {
00079     typedef Transducer<S> structure_t;
00080 
00081     typedef Element<structure_t, T> automaton_t;
00082 
00083     typedef typename structure_t::series_set_t::semiring_t
00084     typeof_auto_series_set_t;
00085 
00086     typedef typename structure_t::series_set_t::monoid_t auto_monoid_t;
00087 
00088     typedef typename typeof_auto_series_set_t::semiring_t auto_semiring_t;
00089     typedef typename algebra::mute_series_traits<typeof_auto_series_set_t,
00090                                                  auto_semiring_t,
00091                                                  auto_monoid_t>::ret
00092     auto_series_set_t;
00093 
00094     typedef typename input_projection_traits<T>::ret auto_impl_t;
00095     typedef Element<Automata<auto_series_set_t>, auto_impl_t> ret;
00096 
00097     static ret make_input_projection_automaton(const automaton_t& t);
00098   };
00099 
00100   template <class S, class T>
00101   struct input_projection_helper<Automata<S>, T>
00102   {
00103     typedef Automata<S> structure_t;
00104 
00105     typedef Element<structure_t, T> automaton_t;
00106 
00107     typedef typename structure_t::series_set_t typeof_auto_series_set_t;
00108 
00109     typedef typename structure_t::series_set_t::semiring_t auto_semiring_t;
00110 
00111     typedef typename structure_t::series_set_t::monoid_t::first_monoid_t
00112     auto_monoid_t;
00113 
00114     typedef typename algebra::mute_series_traits<typeof_auto_series_set_t,
00115                                                  auto_semiring_t,
00116                                                  auto_monoid_t>::ret
00117     auto_series_set_t;
00118 
00119     typedef typename fmp_input_projection_traits<T>::ret auto_impl_t;
00120     typedef Element<Automata<auto_series_set_t>, auto_impl_t> ret;
00121 
00122     static ret make_input_projection_automaton(const automaton_t& t);
00123   };
00124 
00125   /*-------------------------.
00126   | OUTPUT PROJECTION TRAITS |
00127   `-------------------------*/
00128 
00129   template <class S, class T>
00130   struct output_projection_helper
00131   { };
00132 
00133   // RW transducers
00134   template <class S, class T>
00135   struct output_projection_helper<Transducer<S>, T>
00136   {
00137     typedef Transducer<S> structure_t;
00138 
00139     typedef Element<structure_t, T> automaton_t;
00140 
00141     typedef typename structure_t::series_set_t::semiring_t
00142     typeof_auto_series_set_t;
00143 
00144     typedef typename structure_t::series_set_t::semiring_t::monoid_t
00145     auto_monoid_t;
00146 
00147     typedef typename typeof_auto_series_set_t::semiring_t auto_semiring_t;
00148     typedef typename algebra::mute_series_traits<typeof_auto_series_set_t,
00149                                                  auto_semiring_t,
00150                                                  auto_monoid_t>::ret
00151     auto_series_set_t;
00152 
00153     typedef typename output_projection_traits<T>::ret auto_impl_t;
00154     typedef Element<Automata<auto_series_set_t>, auto_impl_t> ret;
00155 
00156     static ret make_output_projection_automaton(const automaton_t& t);
00157   };
00158 
00159   // FMP Transducers
00160   // FIXME: it should be automata over a free monoid product
00161   // FIXME: we cannot use output_projection_traits, because
00162   // it constructs the type by assuming that the automaton is RW
00163   template <class S, class T>
00164   struct output_projection_helper<Automata<S>, T>
00165   {
00166     typedef Automata<S> structure_t;
00167 
00168     typedef Element<structure_t, T> automaton_t;
00169 
00170     typedef typename structure_t::series_set_t typeof_auto_series_set_t;
00171 
00172     typedef typename structure_t::series_set_t::monoid_t::second_monoid_t
00173     auto_monoid_t;
00174 
00175     typedef typename typeof_auto_series_set_t::semiring_t auto_semiring_t;
00176     typedef typename algebra::mute_series_traits<typeof_auto_series_set_t,
00177                                                  auto_semiring_t,
00178                                                  auto_monoid_t>::ret
00179     auto_series_set_t;
00180 
00181     typedef typename fmp_output_projection_traits<T>::ret auto_impl_t;
00182     typedef Element<Automata<auto_series_set_t>, auto_impl_t> ret;
00183 
00184     static ret make_output_projection_automaton(const automaton_t& t);
00185   };
00186 
00187   /*----------------.
00188   | IDENTITY TRAITS |
00189   `----------------*/
00190 
00191   template <class S, class T>
00192   struct identity_transducer_helper
00193   {
00194     typedef typename S::series_set_t     series_set_t;
00195     typedef typename series_set_t::monoid_t  monoid_t;
00196     typedef typename series_set_t::semiring_t semiring_t;
00197     typedef typename algebra::mute_series_traits<series_set_t, series_set_t, monoid_t>
00198     ::ret    tseries_set_t;
00199     typedef typename extension_traits<T>::ret impl_t;
00200     typedef Element<Transducer<tseries_set_t>, impl_t> ret;
00201   };
00202 
00203   template <class S, class T>
00204   typename identity_transducer_helper<S, T>::ret
00205   partial_identity(const Element<S, T>&);
00206 
00207   template <class Series>
00208   bool
00209   operator==(const Transducer<Series>&, const Transducer<Series>&);
00210 
00211 } // ! vcsn
00212 
00213 
00214 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
00215 # include <vaucanson/automata/concept/transducer.hxx>
00216 #endif // VCSN_USE_INTERFACE_ONLY
00217 
00218 
00219 #endif // ! VCSN_AUTOMATA_CONCEPT_TRANSDUCER_HH

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