Vaucanson  1.4.1
series.hxx
1 // series.hxx: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2008 The Vaucanson Group.
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
11 //
12 // The complete GNU General Public Licence Notice can be found as the
13 // `COPYING' file in the root directory.
14 //
15 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
16 //
17 #ifndef VCSN_ALGEBRA_IMPLEMENTATION_SERIES_SERIES_HXX
18 # define VCSN_ALGEBRA_IMPLEMENTATION_SERIES_SERIES_HXX
19 
20 # include <vaucanson/algebra/implementation/series/series.hh>
21 # include <vaucanson/misc/unique.hh>
22 
23 namespace vcsn
24 {
25  namespace algebra
26  {
27  /*-------------------------.
28  | Series<Semiring, Monoid> |
29  `-------------------------*/
30 
31  template<typename Semiring, typename Monoid>
32  Series<Semiring, Monoid>::Series(const Semiring& w, const Monoid& m)
33  : SetSlot<Semiring,semiring_slot_tag>(w),
34  SetSlot<Monoid,monoid_slot_tag>(m),
35  rep_(SeriesRepDefault<Semiring, Monoid>::get_instance())
36  {
37  rep_->disambiguate((*this).monoid(), rep_);
38  }
39 
40  template<typename Semiring, typename Monoid>
41  Series<Semiring, Monoid>::Series(const Semiring& w, const Monoid& m,
42  const SeriesRep<Semiring, Monoid>& sr)
43  : SetSlot<Semiring,semiring_slot_tag>(w),
44  SetSlot<Monoid,monoid_slot_tag>(m),
45  rep_(boost::shared_ptr<SeriesRep<Semiring, Monoid> >(new SeriesRep<Semiring, Monoid>(sr)))
46  {
47  }
48 
49 
50  template<typename Semiring, typename Monoid>
51  Series<Semiring, Monoid>::Series(const Series& other) :
52  SeriesBase<Series<Semiring,Monoid> >(other),
53  SetSlot<Semiring,semiring_slot_tag>(other),
54  SetSlot<Monoid,monoid_slot_tag>(other),
55  rep_(other.rep_)
56  {}
57 
58  template<typename Semiring, typename Monoid>
59  const Semiring& Series<Semiring, Monoid>::semiring() const
60  {
61  return static_cast<const SetSlot<Semiring,semiring_slot_tag>* >(this)->_structure_get();
62  }
63 
64  template<typename Semiring, typename Monoid>
65  const Monoid& Series<Semiring, Monoid>::monoid() const
66  {
67  return static_cast<const SetSlot<Monoid,monoid_slot_tag>* >(this)->_structure_get();
68  }
69 
70  template<typename Semiring, typename Monoid>
71  const boost::shared_ptr<SeriesRep<Semiring, Monoid> >
73  {
74  return rep_;
75  }
76 
77  template<typename Semiring, typename Monoid>
78  bool Series<Semiring, Monoid>::operator==(const Series<Semiring, Monoid>& s2) const
79  {
80  return & monoid() == & s2.monoid() &&
81  & semiring() == & s2.semiring() &&
82  rep_ == s2.rep_;
83  }
84 
85  template <class W, class M, class NewW, class NewM>
86  typename mute_series_traits<Series<W, M>, NewW, NewM >::ret
87  mute_series(const Series<W, M>& s, const NewW& w, const NewM& m)
88  {
89  return mute_series_traits<Series<W, M>, NewW, NewM >::ret(w, m);
90  }
91 
92  } // algebra
93 
94 } // vcsn
95 
96 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_SERIES_SERIES_HXX