Vaucanson  1.4.1
length_visitor.hxx
1 // length_visitor.hxx: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 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_LENGTH_VISITOR_HXX
18 # define VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_LENGTH_VISITOR_HXX
19 
20 # include <vaucanson/algebra/implementation/series/rat/length_visitor.hh>
21 
22 # include <algorithm>
23 
24 namespace vcsn {
25 
26  namespace rat {
27 
28  template<typename M_, typename W_>
29  void
30  LengthVisitor<M_,W_>::sum_or_product(const Node<M_, W_>* left_,
31  const Node<M_, W_>* right_)
32  {
33  left_->accept(*this);
34  right_->accept(*this);
35  }
36 
37  template<typename M_, typename W_>
38  void
39  LengthVisitor<M_, W_>::weight_or_star(const Node<M_, W_>* node)
40  {
41  node->accept(*this);
42  }
43 
44  template<typename M_, typename W_>
45  void
46  LengthVisitor<M_, W_>::product(const Node<M_, W_>* left_,
47  const Node<M_, W_>* right_)
48  {
49  sum_or_product(left_, right_);
50  }
51 
52  template<typename M_, typename W_>
53  void
54  LengthVisitor<M_, W_>::sum(const Node<M_, W_>* left_,
55  const Node<M_, W_>* right_)
56  {
57  sum_or_product(left_, right_);
58  }
59 
60  template<typename M_, typename W_>
61  void
62  LengthVisitor<M_, W_>::star(const Node<M_, W_>* node)
63  {
64  weight_or_star(node);
65  }
66 
67  template<typename M_, typename W_>
68  void
69  LengthVisitor<M_, W_>::left_weight(const W_&, const Node<M_, W_>* node)
70  {
71  weight_or_star(node);
72  }
73 
74  template<typename M_, typename W_>
75  void
76  LengthVisitor<M_, W_>::right_weight(const W_&, const Node<M_, W_>* node)
77  {
78  weight_or_star(node);
79  }
80 
81  template<typename M_, typename W_>
82  void
83  LengthVisitor<M_, W_>::constant(const M_&)
84  {
85  ++s_;
86  }
87 
88  template<typename M_, typename W_>
89  void LengthVisitor<M_, W_>::zero()
90  {
91  ++s_;
92  }
93 
94  template<typename M_, typename W_>
95  void LengthVisitor<M_, W_>::one()
96  {
97  ++s_;
98  }
99 
100  template<typename M_, typename W_>
101  size_t LengthVisitor<M_, W_>::get() const
102  {
103  return s_;
104  }
105 
106  } // End of namespace rat.
107 
108 } // End of namespace vcsn.
109 
110 
111 
112 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_LENGTH_VISITOR_HXX