Vaucanson 1.4
transducer_base.hh
00001 // transducer_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, 2006, 2007, 2008 The
00006 // Vaucanson Group.
00007 //
00008 // This program is free software; you can redistribute it and/or
00009 // modify it under the terms of the GNU General Public License
00010 // as published by the Free Software Foundation; either version 2
00011 // of the License, or (at your option) any later version.
00012 //
00013 // The complete GNU General Public Licence Notice can be found as the
00014 // `COPYING' file in the root directory.
00015 //
00016 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
00017 //
00018 #ifndef VCSN_AUTOMATA_CONCEPT_TRANSDUCER_BASE_HH
00019 # define VCSN_AUTOMATA_CONCEPT_TRANSDUCER_BASE_HH
00020 
00021 # include <iterator>
00022 # include <vaucanson/design_pattern/design_pattern.hh>
00023 # include <vaucanson/design_pattern/predecls.hh>
00024 # include <vaucanson/automata/concept/automata_base.hh>
00025 # include <vaucanson/misc/usual_macros.hh>
00026 
00027 namespace vcsn {
00028     
00032   /*---------------------.
00033   | TransducerBase<Self> |
00034   `----------------------*/
00041   template <typename Self>
00042   struct TransducerBase
00043     : AutomataBase<Self>
00044   {
00045     public:
00047       typedef typename virtual_types<Self>::series_set_t  series_set_t;
00048       typedef typename virtual_types<Self>::kind_t kind_t;
00049 
00050     protected:
00052       TransducerBase();
00053 
00055       TransducerBase(const TransducerBase& other);
00056   };
00057 
00059   template <typename T>
00060   struct transducer_traits
00061   {
00062       typedef undefined_type input_monoid_elt_value_t;
00063       typedef undefined_type output_monoid_elt_value_t;
00064   };
00065 
00066   template <typename T>
00067   struct extension_traits
00068   {
00069       typedef undefined_type ret;
00070   };
00071 
00072   template <class T>
00073   struct input_projection_traits
00074   {
00075       typedef undefined_type    ret;
00076   };
00077 
00078   template <class T>
00079   struct fmp_input_projection_traits
00080   {
00081       typedef undefined_type    ret;
00082   };
00083 
00084   // FIXME: the semantics should be defined more precisely.
00085   // What is the output "on a graph" (it is well defined with
00086   // transducers)
00087   template <class T>
00088   struct output_projection_traits
00089   {
00090     typedef undefined_type      ret;
00091   };
00092 
00093   template <class T>
00094   struct fmp_output_projection_traits
00095   {
00096     typedef undefined_type      ret;
00097   };
00098 
00099   /*-----------------------------------.
00100   | virtual_types<AutomataBase<Self> > |
00101   `-----------------------------------*/
00102   template <class S>
00103   struct virtual_types<TransducerBase<S> >
00104     : virtual_types<AutomataBase<S> >
00105   { };
00106 
00107   /*------------------------------------.
00108   | dynamic_traits<AutomataBase<Self> > |
00109   `------------------------------------*/
00110   template <class S>
00111   struct dynamic_traits<TransducerBase<S> >
00112     : dynamic_traits<AutomataBase<S> >
00113   { };
00114 
00115   /*-------------------------------------.
00116   | MetaElement<TransducerBase<Self>, T> |
00117   `-------------------------------------*/
00125   template <typename Self, typename T>
00126   struct MetaElement<TransducerBase<Self>, T>
00127     : MetaElement<AutomataBase<Self>, T>
00128   {
00130       typedef MetaElement<TransducerBase<Self>, T> self_t;
00131 
00133       typedef MetaElement<AutomataBase<Self>, T> super_t;
00134 
00136       typedef MetaElement<AutomataBase<Self>, T> automaton_t;
00137 
00139       IMPORT_TYPEDEF_(automaton_t, series_set_t);
00140 
00142       IMPORT_TYPEDEF_(automaton_t, series_set_elt_value_t);
00143 
00145       IMPORT_TYPEDEF_(automaton_t, series_set_elt_t);
00146 
00148       IMPORT_TYPEDEF_(automaton_t, monoid_t);
00149 
00151       IMPORT_TYPEDEF_(automaton_t, monoid_elt_t);
00152 
00154       IMPORT_TYPEDEF_(automaton_t, monoid_elt_value_t);
00155 
00157       IMPORT_TYPEDEF_(automaton_t, letter_t);
00158 
00160       IMPORT_TYPEDEF_(automaton_t, semiring_t);
00161 
00163       IMPORT_TYPEDEF_(automaton_t, semiring_elt_t);
00164 
00166       IMPORT_TYPEDEF_(automaton_t, semiring_elt_value_t);
00167 
00169       IMPORT_TYPEDEF_(automaton_t, tag_t);
00170 
00172       IMPORT_TYPEDEF_(automaton_t, label_t);
00173 
00175       IMPORT_TYPEDEF_(automaton_t, states_t);
00176 
00178       IMPORT_TYPEDEF_(automaton_t, state_iterator);
00179 
00181       IMPORT_TYPEDEF_(automaton_t, transitions_t);
00182 
00184       IMPORT_TYPEDEF_(automaton_t, transition_iterator);
00185 
00187       IMPORT_TYPEDEF_(automaton_t, initial_support_t);
00188 
00190       IMPORT_TYPEDEF_(automaton_t, initial_iterator);
00191 
00193       IMPORT_TYPEDEF_(automaton_t, final_support_t);
00194 
00196       IMPORT_TYPEDEF_(automaton_t, final_iterator);
00197 
00199       typedef typename super_t::semiring_elt_t output_series_set_elt_t;
00200 
00201       typedef typename algebra::series_traits<semiring_elt_value_t>::monoid_elt_value_t
00202       output_monoid_elt_value_t;
00203 
00205       typedef typename semiring_t::monoid_t     output_monoid_t;
00206 
00208       typedef Element<output_monoid_t, output_monoid_elt_value_t>
00209       output_monoid_elt_t;
00210 
00211       typedef typename output_monoid_t::letter_t output_letter_t;
00212 
00214       typedef typename super_t::monoid_elt_value_t input_monoid_elt_value_t;
00215 
00217       typedef typename super_t::monoid_t                input_monoid_t;
00218 
00220       typedef Element<input_monoid_t, input_monoid_elt_value_t>
00221       input_monoid_elt_t;
00222 
00223       typedef typename input_monoid_t::letter_t input_letter_t;
00224 
00226       typedef typename algebra::series_traits<semiring_elt_value_t>::semiring_elt_value_t
00227       output_semiring_elt_value_t;
00228 
00230       typedef typename semiring_t::semiring_t   output_semiring_t;
00231 
00233       typedef Element<output_semiring_t, output_semiring_elt_value_t>
00234       output_semiring_elt_t;
00235 
00237       input_monoid_elt_t input_of(typename automaton_traits<T>::htransition_t) const;
00238 
00240       output_series_set_elt_t output_of(typename automaton_traits<T>::htransition_t) const;
00241 
00244       template <typename U, typename V>
00245       typename automaton_traits<T>::htransition_t
00246       add_io_transition(typename automaton_traits<T>::hstate_t, typename automaton_traits<T>::hstate_t,
00247                         const U&,
00248                         const V&,
00249                         output_semiring_elt_t = output_semiring_elt_t());
00250 
00252       template <typename U>
00253       typename automaton_traits<T>::htransition_t
00254       add_o_transition(typename automaton_traits<T>::hstate_t, typename automaton_traits<T>::hstate_t,
00255                        const U&,
00256                        output_semiring_elt_t = output_semiring_elt_t());
00257 
00259       template <typename U>
00260       typename automaton_traits<T>::htransition_t
00261       add_i_transition(typename automaton_traits<T>::hstate_t, typename automaton_traits<T>::hstate_t,
00262                        const U&,
00263                        output_semiring_elt_t = output_semiring_elt_t());
00264 
00266       template <typename U>
00267       void set_o_final(typename automaton_traits<T>::hstate_t, const U&);
00268 
00271       template <typename U>
00272       void set_o_initial(typename automaton_traits<T>::hstate_t, const U&);
00273 
00274     protected:
00275       MetaElement();
00276       MetaElement(const MetaElement& other);
00277   };
00278 
00279 
00283 } // vcsn
00284 
00285 
00286 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
00287 #  include <vaucanson/automata/concept/transducer_base.hxx>
00288 # endif // VCSN_USE_INTERFACE_ONLY
00289 
00290 
00291 #endif // ! VCSN_AUTOMATA_CONCEPT_TRANSDUCER_BASE_HH