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 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     typedef typename S::series_set_t::semiring_t
00076     typeof_auto_series_set_t;
00077 
00079     typedef typename S::series_set_t::monoid_t auto_monoid_t;
00080 
00081     typedef typename typeof_auto_series_set_t::semiring_t auto_semiring_t;
00082     typedef typename algebra::mute_series_traits<typeof_auto_series_set_t,
00083                                                  auto_semiring_t,
00084                                                  auto_monoid_t>::ret
00085     auto_series_set_t;
00086 
00087     typedef typename output_projection_traits<T>::ret auto_impl_t;
00088     typedef Element<Automata<auto_series_set_t>, auto_impl_t> ret;
00089   };
00090 
00091 
00092   /*-------------------------.
00093   | OUTPUT PROJECTION TRAITS |
00094   `-------------------------*/
00095 
00096   template <class S, class T>
00097   struct output_projection_helper
00098   { };
00099 
00100   // RW transducers
00101   template <class S, class T>
00102   struct output_projection_helper<Transducer<S>, T>
00103   {
00104     typedef Transducer<S> structure_t;
00105 
00106     typedef typename structure_t::series_set_t::semiring_t
00107     typeof_auto_series_set_t;
00108 
00109     typedef typename structure_t::series_set_t::semiring_t::monoid_t
00110     auto_monoid_t;
00111 
00112     typedef typename typeof_auto_series_set_t::semiring_t auto_semiring_t;
00113     typedef typename algebra::mute_series_traits<typeof_auto_series_set_t,
00114                                                  auto_semiring_t,
00115                                                  auto_monoid_t>::ret
00116     auto_series_set_t;
00117 
00118     typedef typename output_projection_traits<T>::ret auto_impl_t;
00119     typedef Element<Automata<auto_series_set_t>, auto_impl_t> ret;
00120   };
00121 
00122   // Transducers
00123   template <class S, class T>
00124   struct output_projection_helper<Automata<S>, T>
00125   {
00126     typedef Automata<S> structure_t;
00127 
00128     typedef typename structure_t::series_set_t typeof_auto_series_set_t;
00129 
00130     typedef typename structure_t::series_set_t::semiring_t auto_semiring_t;
00131 
00132     typedef typename structure_t::series_set_t::monoid_t::second_monoid_t
00133     auto_monoid_t;
00134 
00135     typedef typename algebra::mute_series_traits<typeof_auto_series_set_t,
00136                                                  auto_semiring_t,
00137                                                  auto_monoid_t>::ret
00138     auto_series_set_t;
00139 
00140     typedef typename output_projection_traits<T>::ret auto_impl_t;
00141     typedef Element<Automata<auto_series_set_t>, auto_impl_t> ret;
00142   };
00143 
00144 
00145   /*----------------.
00146   | IDENTITY TRAITS |
00147   `----------------*/
00148 
00149   template <class S, class T>
00150   struct identity_transducer_helper
00151   {
00152     typedef typename S::series_set_t     series_set_t;
00153     typedef typename series_set_t::monoid_t  monoid_t;
00154     typedef typename series_set_t::semiring_t semiring_t;
00155     typedef typename algebra::mute_series_traits<series_set_t, series_set_t, monoid_t>
00156     ::ret    tseries_set_t;
00157     typedef typename extension_traits<T>::ret impl_t;
00158     typedef Element<Transducer<tseries_set_t>, impl_t> ret;
00159   };
00160 
00161   template <class S, class T>
00162   typename identity_transducer_helper<S, T>::ret
00163   partial_identity(const Element<S, T>&);
00164 
00165 
00166   template <class Series>
00167   bool
00168   operator==(const Transducer<Series>&, const Transducer<Series>&);
00169 
00170 } // vcsn
00171 
00172 
00173 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
00174 # include <vaucanson/automata/concept/transducer.hxx>
00175 #endif // VCSN_USE_INTERFACE_ONLY
00176 
00177 
00178 #endif // ! VCSN_AUTOMATA_CONCEPT_TRANSDUCER_HH

Generated on Sun Jul 29 19:35:30 2007 for Vaucanson by  doxygen 1.5.2