Vaucanson 1.4
free_monoid.hh
00001 // free_monoid.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_MONOID_FREE_MONOID_HH
00018 # define VCSN_ALGEBRA_IMPLEMENTATION_MONOID_FREE_MONOID_HH
00019 
00020 # include <set>
00021 
00022 # include <vaucanson/algebra/concept/freemonoid_base.hh>
00023 # include <vaucanson/algebra/implementation/monoid/monoid_rep.hh>
00024 # include <vaucanson/misc/unique.hh>
00025 # include <vaucanson/misc/usual_macros.hh>
00026 
00027 namespace vcsn
00028 {
00029   namespace algebra
00030   {  
00034     /*--------------.
00035     | FreeMonoid<A> |
00036     `--------------*/
00037 
00039     template<typename A>
00040     struct FreeMonoid
00041       : FreeMonoidBase<FreeMonoid<A> >
00042     {
00043       // Type helpers.
00044       typedef A alphabets_elt_t;
00045       typedef MonoidRep<FreeMonoid<A> > monoid_rep_t;
00046       typedef boost::shared_ptr<monoid_rep_t> shared_monoid_rep_t;
00047 
00050       FreeMonoid(const A& a);
00051 
00054       FreeMonoid(const A& a, monoid_rep_t mr);
00055 
00057       FreeMonoid(const FreeMonoid& w);
00058 
00060       const shared_monoid_rep_t representation() const;
00061 
00065       A&        alphabet();
00066 
00068       const A&  alphabet() const;
00069 
00070     public:
00073       void set_representation(monoid_rep_t mr);
00074 
00075     protected:
00076       shared_monoid_rep_t rep_;
00077       A alph_;
00078     };
00079 
00080     template<typename A>
00081     bool operator==(const FreeMonoid<A>& a,
00082                     const FreeMonoid<A>& b);
00083 
00087   } // ! algebra
00088   
00092   /*-------------------------------.
00093   | dynamic_traits<FreeMonoid<A> > |
00094   `-------------------------------*/
00096   template<typename A>
00097   struct dynamic_traits<algebra::FreeMonoid<A> >
00098     : dynamic_traits<algebra::FreeMonoidBase<algebra::FreeMonoid<A> > >
00099   {
00101     static const bool           ret = A::dynamic;
00102   };
00103 
00104   /*------------------------------.
00105   | MetaElement<FreeMonoid<A>, T> |
00106   `------------------------------*/
00109   template<typename A, typename T>
00110   struct MetaElement<algebra::FreeMonoid<A>, T>
00111     : MetaElement<algebra::FreeMonoidBase<algebra::FreeMonoid<A> >, T>
00112   {};
00113 
00117   template <class A>
00118   struct virtual_types<algebra::FreeMonoid<A> >
00119     : virtual_types<algebra::FreeMonoidBase<algebra::FreeMonoid<A> > >
00120   {
00121     typedef A           alphabet_t;
00122   };
00123 
00130   enum op_choose_max_word_length_t { op_choose_max_word_length = 32 };
00131 
00132 } // ! vcsn
00133 
00134 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
00135 #  include <vaucanson/algebra/implementation/monoid/free_monoid.hxx>
00136 # endif // VCSN_USE_INTERFACE_ONLY
00137 
00138 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_MONOID_FREE_MONOID_HH