Vaucanson  1.4.1
free_monoid.hxx
1 // free_monoid.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_MONOID_FREE_MONOID_HXX
18 # define VCSN_ALGEBRA_IMPLEMENTATION_MONOID_FREE_MONOID_HXX
19 
20 # include <vaucanson/algebra/implementation/monoid/free_monoid.hh>
21 
22 namespace vcsn
23 {
24  namespace algebra
25  {
26  /*--------------.
27  | FreeMonoid<A> |
28  `--------------*/
29 
30  template <class A>
32  rep_(MonoidRepDefault<FreeMonoid<A> >::get_instance()),
33  alph_(a)
34  {
35  rep_->disambiguate(*this, rep_);
36  }
37 
38  template <class A>
39  FreeMonoid<A>::FreeMonoid(const A& a, MonoidRep<FreeMonoid<A> > mr) :
40  rep_(boost::shared_ptr<MonoidRep<FreeMonoid<A> > >(new MonoidRep<FreeMonoid<A> > (mr))),
41  alph_(a)
42  {
43  }
44 
45  template <class A>
47  FreeMonoidBase<FreeMonoid<A> >(w),
48  rep_(w.rep_),
49  alph_(w.alph_)
50  {
51  }
52 
53  template <class A>
54  const boost::shared_ptr<MonoidRep<FreeMonoid<A> > >
56  {
57  return rep_;
58  }
59 
60  template <class A>
61  void
63  {
64  rep_ = boost::shared_ptr<MonoidRep<FreeMonoid<A> > >(new MonoidRep<FreeMonoid<A> > (mr));
65  }
66 
67  template <class A>
69  {
70  return alph_;
71  }
72 
73  template <class A>
74  const A& FreeMonoid<A>::alphabet() const
75  {
76  return alph_;
77  }
78 
79  template <typename A>
80  bool
81  operator==(const FreeMonoid<A>& lhs,
82  const FreeMonoid<A>& rhs)
83  {
84  return (lhs.alphabet() == rhs.alphabet() &&
85  lhs.representation() == rhs.representation());
86  }
87 
88  } // ! algebra
89 
90 } // ! vcsn
91 
92 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_MONOID_FREE_MONOID_HXX