Vaucanson 1.4
series.hxx
00001 // series.hxx: 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, 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_HXX
00018 # define VCSN_ALGEBRA_IMPLEMENTATION_SERIES_SERIES_HXX
00019 
00020 # include <vaucanson/algebra/implementation/series/series.hh>
00021 # include <vaucanson/misc/unique.hh>
00022 
00023 namespace vcsn
00024 {
00025   namespace algebra
00026   {
00027     /*-------------------------.
00028     | Series<Semiring, Monoid> |
00029     `-------------------------*/
00030 
00031     template<typename Semiring, typename Monoid>
00032     Series<Semiring, Monoid>::Series(const Semiring& w, const Monoid& m)
00033       : SetSlot<Semiring,semiring_slot_tag>(w),
00034         SetSlot<Monoid,monoid_slot_tag>(m),
00035       rep_(SeriesRepDefault<Semiring, Monoid>::get_instance())
00036     {
00037       rep_->disambiguate((*this).monoid(), rep_);
00038     }
00039 
00040     template<typename Semiring, typename Monoid>
00041     Series<Semiring, Monoid>::Series(const Semiring& w, const Monoid& m,
00042                                      const SeriesRep<Semiring, Monoid>& sr)
00043       : SetSlot<Semiring,semiring_slot_tag>(w),
00044         SetSlot<Monoid,monoid_slot_tag>(m),
00045       rep_(boost::shared_ptr<SeriesRep<Semiring, Monoid> >(new SeriesRep<Semiring, Monoid>(sr)))
00046     {
00047     }
00048 
00049 
00050     template<typename Semiring, typename Monoid>
00051     Series<Semiring, Monoid>::Series(const Series& other) :
00052       SeriesBase<Series<Semiring,Monoid> >(other),
00053       SetSlot<Semiring,semiring_slot_tag>(other),
00054       SetSlot<Monoid,monoid_slot_tag>(other),
00055       rep_(other.rep_)
00056     {}
00057 
00058     template<typename Semiring, typename Monoid>
00059     const Semiring& Series<Semiring, Monoid>::semiring() const
00060     {
00061       return static_cast<const SetSlot<Semiring,semiring_slot_tag>* >(this)->_structure_get();
00062     }
00063 
00064     template<typename Semiring, typename Monoid>
00065     const Monoid& Series<Semiring, Monoid>::monoid() const
00066     {
00067       return static_cast<const SetSlot<Monoid,monoid_slot_tag>* >(this)->_structure_get();
00068     }
00069 
00070     template<typename Semiring, typename Monoid>
00071     const boost::shared_ptr<SeriesRep<Semiring, Monoid> >
00072     Series<Semiring, Monoid>::representation() const
00073     {
00074       return rep_;
00075     }
00076 
00077     template<typename Semiring, typename Monoid>
00078     bool Series<Semiring, Monoid>::operator==(const Series<Semiring, Monoid>& s2) const
00079     {
00080       return & monoid() == & s2.monoid() &&
00081         & semiring() == & s2.semiring() &&
00082         rep_ == s2.rep_;
00083     }
00084 
00085     template <class W, class M, class NewW, class NewM>
00086     typename mute_series_traits<Series<W, M>, NewW, NewM >::ret
00087     mute_series(const Series<W, M>& s, const NewW& w, const NewM& m)
00088     {
00089       return mute_series_traits<Series<W, M>, NewW, NewM >::ret(w, m);
00090     }
00091 
00092   } // algebra
00093 
00094 } // vcsn
00095 
00096 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_SERIES_SERIES_HXX