Vaucanson 1.4
transducer_base.hxx
00001 // transducer_base.hxx: 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_BASE_HXX
00018 # define VCSN_AUTOMATA_CONCEPT_TRANSDUCER_BASE_HXX
00019 
00020 # include <vaucanson/automata/concept/transducer_base.hh>
00021 # include <vaucanson/automata/concept/transducer_ops.hh>
00022 
00023 namespace vcsn {
00024 
00025   template <typename Self>
00026   TransducerBase<Self>::TransducerBase()
00027   {}
00028 
00029   template <typename Self>
00030   TransducerBase<Self>::TransducerBase(const TransducerBase& other) :
00031     AutomataBase<Self>(other)
00032   {}
00033 
00034   template <typename Self, typename T>
00035   MetaElement<TransducerBase<Self>, T>::MetaElement()
00036   {}
00037 
00038   template <typename Self, typename T>
00039   MetaElement<TransducerBase<Self>, T>::MetaElement(const MetaElement& a):
00040     MetaElement<AutomataBase<Self>, T>::MetaElement(a)
00041   {}
00042 
00043   template <typename Self, typename T>
00044   typename MetaElement<TransducerBase<Self>, T>::input_monoid_elt_t
00045   MetaElement<TransducerBase<Self>, T>::input_of(typename automaton_traits<T>::htransition_t e) const
00046   {
00047     return op_input_of(this->structure(), this->value(), e);
00048   }
00049 
00050   template <typename Self, typename T>
00051   typename MetaElement<TransducerBase<Self>, T>::output_series_set_elt_t
00052   MetaElement<TransducerBase<Self>, T>::output_of(typename automaton_traits<T>::htransition_t e) const
00053   {
00054     return op_output_of(this->structure(), this->value(), e);
00055   }
00056 
00057   template <typename Self, typename T>
00058   template <typename U, typename V>
00059   typename automaton_traits<T>::htransition_t
00060   MetaElement<TransducerBase<Self>, T>::
00061   add_io_transition(typename automaton_traits<T>::hstate_t from,
00062                     typename automaton_traits<T>::hstate_t to,
00063                     const U& i,
00064                     const V& o,
00065                     output_semiring_elt_t w)
00066   {
00067     if (w == output_semiring_elt_t())
00068       w = algebra::identity_as<output_semiring_elt_value_t>
00069         ::of(this->series().semiring().semiring());
00070     Element<input_monoid_t, input_monoid_elt_value_t>
00071       i_elt (this->structure().series().monoid(), i);
00072     Element<output_monoid_t, output_monoid_elt_value_t>
00073       o_elt (this->structure().series().semiring().monoid(), o);
00074     return op_add_io_transition(this->structure(), this->value(),
00075                                 from, to, i_elt, o_elt, w);
00076   }
00077 
00078   template <typename Self, typename T>
00079   template <typename U>
00080   typename automaton_traits<T>::htransition_t
00081   MetaElement<TransducerBase<Self>, T>::
00082   add_o_transition(typename automaton_traits<T>::hstate_t from,
00083                    typename automaton_traits<T>::hstate_t to,
00084                    const U& o,
00085                    output_semiring_elt_t w)
00086   {
00087     if (w == output_semiring_elt_t())
00088       w = algebra::identity_as<output_semiring_elt_value_t>
00089         ::of(this->series().semiring().semiring());
00090     Element<output_monoid_t, output_monoid_elt_value_t>
00091       o_elt (this->structure().series().semiring().monoid(), o);
00092     return op_add_o_transition(this->structure(), this->value(),
00093                                from, to, o_elt, w);
00094   }
00095 
00096   template <typename Self, typename T>
00097   template <typename U>
00098   typename automaton_traits<T>::htransition_t
00099   MetaElement<TransducerBase<Self>, T>::
00100   add_i_transition(typename automaton_traits<T>::hstate_t from,
00101                    typename automaton_traits<T>::hstate_t to,
00102                    const U& i,
00103                    output_semiring_elt_t w)
00104   {
00105     if (w == output_semiring_elt_t())
00106       w = algebra::identity_as<output_semiring_elt_value_t>
00107         ::of(this->series().semiring().semiring());
00108     Element<input_monoid_t, input_monoid_elt_value_t>
00109       i_elt (this->structure().series().monoid(), i);
00110     return op_add_i_transition(this->structure(), this->value(),
00111                                from, to, i_elt, w);
00112   }
00113 
00114   template <typename Self, typename T>
00115   template <typename U>
00116   void
00117   MetaElement<TransducerBase<Self>, T>::
00118   set_o_final(typename automaton_traits<T>::hstate_t final,
00119               const U& o)
00120   {
00121     Element<output_monoid_t, output_monoid_elt_value_t>
00122       o_elt (this->structure().series().semiring().monoid(), o);
00123     op_set_o_final(this->structure(), this->value(), final, o_elt.value());
00124   }
00125 
00126   template <typename Self, typename T>
00127   template <typename U>
00128   void
00129   MetaElement<TransducerBase<Self>, T>::
00130   set_o_initial(typename automaton_traits<T>::hstate_t initial,
00131                 const U& o)
00132   {
00133     Element<output_monoid_t, output_monoid_elt_value_t>
00134       o_elt (this->structure().series().semiring().monoid(), o);
00135     op_set_o_initial(this->structure(), this->value(), initial, o_elt.value());
00136   }
00137 
00138 } // vcsn
00139 
00140 #endif // ! VCSN_AUTOMATA_CONCEPT_TRANSDUCER_BASE_HXX