words.hh

00001 // words.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_ALGEBRA_IMPLEMENTATION_FREE_MONOID_WORDS_HH
00018 # define VCSN_ALGEBRA_IMPLEMENTATION_FREE_MONOID_WORDS_HH
00019 
00020 # include <string>
00021 # include <vaucanson/algebra/concept/freemonoid_base.hh>
00022 # include <vaucanson/misc/unique.hh>
00023 # include <vaucanson/misc/usual_macros.hh>
00024 
00025 namespace vcsn
00026 {
00027   namespace algebra
00028   {  
00032     /*--------------.
00033     | FreeMonoid<A> |
00034     `--------------*/
00035 
00037     template<typename A>
00038     struct FreeMonoid
00039       : FreeMonoidBase<FreeMonoid<A> >
00040     {
00041       typedef A alphabets_elt_t;
00042 
00044       FreeMonoid(const A& a);
00045 
00047       FreeMonoid(const FreeMonoid& w);
00048 
00051       A&        alphabet();
00052 
00054       const A&  alphabet() const;
00055 
00056     protected:
00057       A alph_;
00058     };
00059 
00060     template<typename A>
00061     bool operator==(const FreeMonoid<A>& a,
00062                     const FreeMonoid<A>& b);
00063 
00064     /*---------------------------------------------------------------------.
00065     | word_traits<FreeMonoid<A>, std::basic_string<typename A::letter_t> > |
00066     `---------------------------------------------------------------------*/
00067 
00072     template <typename A>
00073     struct word_traits<FreeMonoid<A>,
00074                        std::basic_string<typename A::letter_t> >
00075     {
00077       typedef A alphabet_t;
00078 
00080       typedef Element<FreeMonoid<A>,
00081               std::basic_string<typename alphabet_t::letter_t> > word_t;
00082 
00084       typedef typename word_t::value_t word_value_t;
00085 
00087       typedef typename alphabet_traits<typename alphabet_t::set_t,
00088                                        typename alphabet_t::value_t>::
00089 	first_projection_t first_projection_alphabet_t;
00090 
00092       typedef typename alphabet_traits<typename alphabet_t::set_t,
00093                                        typename alphabet_t::value_t>::
00094 	second_projection_t second_projection_alphabet_t;
00095 
00097       typedef FreeMonoid<first_projection_alphabet_t> first_monoid_t;
00098 
00100       typedef FreeMonoid<second_projection_alphabet_t> second_monoid_t;
00101 
00103       typedef Element<first_monoid_t,
00104               std::basic_string<typename first_projection_alphabet_t::
00105                                 letter_t> > first_projection_t;
00106 
00108       typedef typename first_projection_t::value_t first_projection_value_t;
00109 
00111       typedef Element<second_monoid_t,
00112               std::basic_string<typename second_projection_alphabet_t::
00113                                 letter_t> > second_projection_t;
00114 
00116       typedef typename second_projection_t::value_t second_projection_value_t;
00117 
00119       static first_projection_t first_projection(const first_monoid_t&,
00120                                                  const word_t&);
00121       static first_projection_value_t first_projection(const word_value_t&);
00122 
00124       static second_projection_t second_projection(const second_monoid_t&,
00125                                                    const word_t&);
00126       static second_projection_value_t second_projection(const word_value_t&);
00127     };
00128 
00132   } // ! algebra
00133   
00137   /*-------------------------------.
00138   | dynamic_traits<FreeMonoid<A> > |
00139   `-------------------------------*/
00141   template<typename A>
00142   struct dynamic_traits<algebra::FreeMonoid<A> >
00143     : dynamic_traits<algebra::FreeMonoidBase<algebra::FreeMonoid<A> > >
00144   {
00146     static const bool           ret = A::dynamic;
00147   };
00148 
00149   /*------------------------------.
00150   | MetaElement<FreeMonoid<A>, T> |
00151   `------------------------------*/
00154   template<typename A, typename T>
00155   struct MetaElement<algebra::FreeMonoid<A>, T>
00156     : MetaElement<algebra::FreeMonoidBase<algebra::FreeMonoid<A> >, T>
00157   {};
00158 
00162   template <class A>
00163   struct virtual_types<algebra::FreeMonoid<A> >
00164     : virtual_types<algebra::FreeMonoidBase<algebra::FreeMonoid<A> > >
00165   {
00167     typedef algebra::mul_kind semigroup_kind;
00168 
00169     typedef A           alphabet_t;
00170   };
00171 
00178   enum op_choose_max_word_length_t { op_choose_max_word_length = 32 };
00179 
00180 } // ! vcsn
00181 
00182 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
00183 #  include <vaucanson/algebra/implementation/free_monoid/words.hxx>
00184 # endif // VCSN_USE_INTERFACE_ONLY
00185 
00186 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_FREE_MONOID_WORDS_HH

Generated on Thu Oct 9 20:22:42 2008 for Vaucanson by  doxygen 1.5.1