Vaucanson 1.4
series.hh
00001 // series.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_SERIES_SERIES_HH
00018 # define VCSN_ALGEBRA_IMPLEMENTATION_SERIES_SERIES_HH
00019 
00020 # include <vaucanson/algebra/concept/series_base.hh>
00021 # include <vaucanson/algebra/implementation/series/series_rep.hh>
00022 # include <vaucanson/design_pattern/slots.hh>
00023 
00024 
00025 namespace vcsn
00026 {
00027   namespace algebra
00028   {
00029     /*-------------------------.
00030     | Series<Semiring, Monoid> |
00031     `-------------------------*/
00032 
00033     struct semiring_slot_tag {};
00034     struct monoid_slot_tag {};
00035 
00038     template<typename Semiring, typename Monoid>
00039     struct Series
00040       : SeriesBase<Series<Semiring, Monoid> >,
00041         private SetSlot<Semiring, semiring_slot_tag>,
00042         private SetSlot<Monoid, monoid_slot_tag>
00043     {
00044       typedef SeriesRep<Semiring, Monoid> series_rep_t;
00045       typedef boost::shared_ptr<series_rep_t> shared_series_rep_t;
00046 
00047       Series(const Semiring& w, const Monoid& m);
00048       Series(const Semiring& w, const Monoid& m, const series_rep_t& sr);
00049       Series(const Series& other);
00050 
00051       const Semiring&   semiring() const;
00052 
00053       const Monoid&     monoid() const;
00054 
00055       const shared_series_rep_t representation() const;
00056 
00057       bool operator==(const Series<Semiring, Monoid>&) const;
00058 
00059     protected:
00060       shared_series_rep_t rep_;
00061     };
00062 
00063     template <class W, class M, class NewW, class NewM>
00064     struct mute_series_traits<Series<W, M>, NewW, NewM >
00065     {
00066       typedef Series<NewW, NewM> ret;
00067     };
00068 
00069     template <class W, class M, class NewW, class NewM>
00070     typename mute_series_traits<Series<W, M>, NewW, NewM >::ret
00071     mute_series(const Series<W, M>& s, const NewW& w, const NewM& m);
00072 
00073   } // algebra
00074 
00075   /*-----------------------------.
00076   | MetaElement<Series<W, M>, T> |
00077   `-----------------------------*/
00078 
00080   template <class W, class M, class T>
00081   struct MetaElement<algebra::Series<W, M>, T> :
00082     public MetaElement<algebra::SeriesBase<algebra::Series<W, M> >, T>
00083   { };
00084 
00085   /*-----------------------------.
00086   | dynamic_traits<Series<W, M>> |
00087   `-----------------------------*/
00088 
00090   template<typename W, typename M>
00091   struct dynamic_traits<algebra::Series<W, M> >
00092     : dynamic_traits<algebra::SeriesBase<algebra::Series<W, M> > >
00093   {
00094     static const bool ret =
00095       dynamic_traits<W>::ret || dynamic_traits<M>::ret;
00096 
00097   };
00098 
00099   /*----------------------------.
00100   | virtual_types<Series<W, N>> |
00101   `----------------------------*/
00102 
00104   template<typename W, typename M>
00105   struct virtual_types<algebra::Series<W, M> >
00106     : virtual_types<algebra::SeriesBase<algebra::Series<W, M> > >
00107   {
00108     typedef W semiring_t;
00109     typedef M monoid_t;
00110   };
00111 
00112 } // vcsn
00113 
00114 
00115 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
00116 # include <vaucanson/algebra/implementation/series/series.hxx>
00117 #endif // VCSN_USE_INTERFACE_ONLY
00118 
00119 
00120 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_SERIES_SERIES_HH