krat_exp_linearize.hh

Go to the documentation of this file.
00001 // krat_exp_linearize.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_ALGORITHMS_KRAT_EXP_LINEARIZE_HH
00018 # define VCSN_ALGORITHMS_KRAT_EXP_LINEARIZE_HH
00019 
00030 # include <vaucanson/design_pattern/design_pattern.hh>
00031 # include <vaucanson/algebra/concept/series_base.hh>
00032 # include <vaucanson/algebra/implementation/series/series.hh>
00033 # include <vaucanson/algebra/implementation/alphabets/alphabets.hh>
00034 # include <vaucanson/algebra/implementation/free_monoid/words.hh>
00035 # include <vaucanson/algebra/implementation/letter/couple_letter.hh>
00036 # include <vaucanson/misc/char_traits.hh>
00037 # include <vaucanson/algebra/implementation/series/krat.hh>
00038 
00039 # include <utility>
00040 
00041 namespace vcsn {
00042 
00045 
00046   template <typename S, typename T>
00047   struct linearize_element
00048   {
00049     // Get types which are useful to build the new type
00050     typedef typename T::semiring_elt_value_t    orig_semiring_elt_value_t;
00051     typedef typename S::semiring_t              orig_semiring_t;
00052     typedef typename S::monoid_t                orig_monoid_t;
00053     typedef typename orig_monoid_t::letter_t    orig_letter_t;
00054 
00055     // Build it !
00056     typedef int                                 index_t;
00057     typedef std::pair<orig_letter_t, index_t>   letter_t;
00058     // FIXME: Here, we want X<letter_t> where X is the type of the alphabet
00059     // FIXME: concept. See next FIXME.
00060     typedef algebra::AlphabetSet<letter_t>              alphabets_t;
00061     typedef std::set<letter_t>                          alphabet_impl_t;
00062     typedef Element<alphabets_t, alphabet_impl_t>       alphabet_t;
00063     // FIXME: in fact, here we want X<alphabet_t> where X is the type of
00064     // FIXME: the monoid concept. For the moment, we just have FreeMonoid, so
00065     // FIXME: it is not important but in the future, we will have to introduce
00066     // FIXME: a convenient way of substituting types parameters ...
00067     typedef algebra::FreeMonoid<alphabet_t>             monoid_t;
00068     // FIXME: same remark here.
00069     typedef algebra::Series<orig_semiring_t, monoid_t>  series_set_t;
00070     typedef std::basic_string<letter_t, misc::char_traits<letter_t> >
00071                                                         monoid_elt_value_t;
00072     typedef rat::exp<monoid_elt_value_t, orig_semiring_elt_value_t>
00073                                                         series_set_elt_value_t;
00074     // And the resulting type:
00075     typedef Element<series_set_t, series_set_elt_value_t>
00076                                                         element_t;
00077   };
00078 
00080   template <class Series, class T>
00081   typename linearize_element<Series, T>::element_t
00082   linearize(const Element<Series, T>& exp);
00083 
00086 } // vcsn
00087 
00088 # if !defined VCSN_USE_INTERFACE_ONLY && !defined VCSN_USE_LIB
00089 #  include <vaucanson/algorithms/krat_exp_linearize.hxx>
00090 # endif // VCSN_USE_INTERFACE_ONLY
00091 
00092 #endif // ! VCSN_ALGORITHMS_KRAT_EXP_LINEARIZE_HH

Generated on Wed Jun 13 17:00:24 2007 for Vaucanson by  doxygen 1.5.1