Vaucanson  1.4.1
dispatch_visitor.hxx
1 // dispatch_visitor.hxx: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 2004, 2005 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_RAT_DISPATCH_VISITOR_HXX
18 # define VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_DISPATCH_VISITOR_HXX
19 
20 # include <vaucanson/algebra/implementation/series/rat/dispatch_visitor.hh>
21 
22 namespace vcsn
23 {
24 
25  namespace algebra
26  {
27 
28  template <class Matcher, class Monoid, class Semiring>
29  DispatchVisitor<Matcher, Monoid, Semiring>::DispatchVisitor(Matcher& m) :
30  matcher_(m)
31  {}
32 
33  template <class Matcher, class Monoid, class Semiring>
34  DispatchVisitor<Matcher, Monoid, Semiring>::~DispatchVisitor()
35  {}
36 
37  template <class Matcher, class Monoid, class Semiring>
38  void
39  DispatchVisitor<Matcher, Monoid, Semiring>::
40  product(const node_t* lhs, const node_t* rhs)
41  {
42  ret_ = matcher_.match_nodeProduct(typename Matcher::Product(lhs, rhs));
43  }
44 
45  template <class Matcher, class Monoid, class Semiring>
46  void
47  DispatchVisitor<Matcher, Monoid, Semiring>::
48  sum(const node_t* lhs, const node_t* rhs)
49  {
50  ret_ = matcher_.match_nodeSum(typename Matcher::Sum(lhs, rhs));
51  }
52 
53  template <class Matcher, class Monoid, class Semiring>
54  void
56  star(const node_t* node)
57  {
58  ret_ = matcher_.match_nodeStar(typename Matcher::Star(node));
59  }
60 
61  template <class Matcher, class Monoid, class Semiring>
62  void
63  DispatchVisitor<Matcher, Monoid, Semiring>::
64  left_weight(const semiring_elt_value_t& w, const node_t* node)
65  {
66  ret_ = matcher_.match_nodeLeftWeight(typename Matcher::LeftWeight(w,
67  node));
68  }
69 
70  template <class Matcher, class Monoid, class Semiring>
71  void
72  DispatchVisitor<Matcher, Monoid, Semiring>::
73  right_weight(const semiring_elt_value_t& w, const node_t* node)
74  {
75  ret_ = matcher_.match_nodeRightWeight(typename
76  Matcher::RightWeight(node, w));
77  }
78 
79  template <class Matcher, class Monoid, class Semiring>
80  void
81  DispatchVisitor<Matcher, Monoid, Semiring>::
82  constant(const monoid_elt_value_t& m)
83  {
84  ret_ = matcher_.match_nodeConstant(typename Matcher::Constant(m));
85  }
86 
87  template <class Matcher, class Monoid, class Semiring>
88  void
89  DispatchVisitor<Matcher, Monoid, Semiring>::
90  zero()
91  {
92  ret_ = matcher_.match_nodeZero(typename Matcher::Zero());
93  }
94 
95  template <class Matcher, class Monoid, class Semiring>
96  void
97  DispatchVisitor<Matcher, Monoid, Semiring>::
98  one()
99  {
100  ret_ = matcher_.match_nodeOne(typename Matcher::One());
101  }
102 
103  template <class Matcher, class Monoid, class Semiring>
104  typename DispatchVisitor<Matcher, Monoid, Semiring>::return_type
105  DispatchVisitor<Matcher, Monoid, Semiring>::
106  get_ret()
107  {
108  return ret_;
109  }
110 
111  template <class M, class W>
112  template <class Matcher>
113  typename Matcher::return_type
114  DispatchFunction< rat::exp<M, W> >::d(Matcher& matcher,
115  const rat::exp<M, W>& exp)
116  {
117  DispatchVisitor<Matcher, M, W> v(matcher);
118  exp.accept(v);
119  return v.get_ret ();
120  }
121 
122  } // End of namespace algebra.
123 
124 } // End of namespace vcsn.
125 
126 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_DISPATCH_VISITOR_HXX