- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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