Vaucanson 1.4
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, 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_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/monoid/free_monoid.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 // The following line is a potential INTERFACE lines which has been disabled because of the LinExp pseudo-type.
00046 // Interface: LinExp linearize(const Exp& e) { return vcsn::linearize(e); }
00047 
00049   template <typename S, typename T>
00050   struct linearize_element
00051   {
00052     // Get types which are useful to build the new type
00053     typedef typename T::semiring_elt_value_t    orig_semiring_elt_value_t;
00054     typedef typename S::semiring_t              orig_semiring_t;
00055     typedef typename S::monoid_t                orig_monoid_t;
00056     typedef typename orig_monoid_t::letter_t    orig_letter_t;
00057 
00058     // Build it!
00059     typedef int                                 index_t;
00060     typedef std::pair<orig_letter_t, index_t>   letter_t;
00061     // FIXME: Here, we want X<letter_t> where X is the type of the alphabet
00062     // FIXME: concept. See next FIXME.
00063     typedef algebra::AlphabetSet<letter_t>              alphabets_t;
00064     typedef std::set<letter_t>                          alphabet_impl_t;
00065     typedef Element<alphabets_t, alphabet_impl_t>       alphabet_t;
00066     // FIXME: in fact, here we want X<alphabet_t> where X is the type of
00067     // FIXME: the monoid concept. For the moment, we just have FreeMonoid, so
00068     // FIXME: it is not important but in the future, we will have to introduce
00069     // FIXME: a convenient way of substituting types parameters ...
00070     typedef algebra::FreeMonoid<alphabet_t>             monoid_t;
00071     // FIXME: same remark here.
00072     typedef algebra::Series<orig_semiring_t, monoid_t>  series_set_t;
00073     typedef std::basic_string<letter_t, misc::char_traits<letter_t> >
00074                                                         monoid_elt_value_t;
00075     typedef rat::exp<monoid_elt_value_t, orig_semiring_elt_value_t>
00076                                                         series_set_elt_value_t;
00077     // And the resulting type:
00078     typedef Element<series_set_t, series_set_elt_value_t>
00079                                                         element_t;
00080   };
00081 
00083   template <class Series, class T>
00084   typename linearize_element<Series, T>::element_t
00085   linearize(const Element<Series, T>& exp);
00086 
00089 } // vcsn
00090 
00091 # if !defined VCSN_USE_INTERFACE_ONLY && !defined VCSN_USE_LIB
00092 #  include <vaucanson/algorithms/krat_exp_linearize.hxx>
00093 # endif // VCSN_USE_INTERFACE_ONLY
00094 
00095 #endif // ! VCSN_ALGORITHMS_KRAT_EXP_LINEARIZE_HH