Vaucanson  1.4.1
length_visitor.hh
1 // length_visitor.hh: 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_HH
18 # define VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_LENGTH_VISITOR_HH
19 
20 
21 # include <cstddef>
22 
23 # include <vaucanson/algebra/implementation/series/rat/nodes.hh>
24 
25 namespace vcsn {
26 
27  namespace rat {
28 
29  template<typename M_, typename W_>
30  class LengthVisitor : public ConstNodeVisitor<M_, W_>
31  {
32  protected:
33  void
34  sum_or_product(const Node<M_, W_>* left_, const Node<M_, W_>* right_);
35  void
36  weight_or_star(const Node<M_, W_>* node);
37 
38  public:
39  LengthVisitor() :
40  s_(0)
41  {}
42 
43  virtual void
44  product(const Node<M_, W_>* left_, const Node<M_, W_>* right_);
45 
46  virtual void
47  sum(const Node<M_, W_>* left_, const Node<M_, W_>* right_);
48 
49  virtual void
50  star(const Node<M_, W_>* node);
51 
52  virtual void
53  left_weight(const W_&, const Node<M_, W_>* node);
54 
55  virtual void
56  right_weight(const W_&, const Node<M_, W_>* node);
57 
58  virtual void
59  constant(const M_& m);
60 
61  virtual void zero();
62 
63  virtual void one();
64 
65  size_t get() const;
66 
67  size_t set(size_t v)
68  {
69  this->s_ = v;
70  return this->s_;
71  }
72 
73  protected:
74  size_t s_;
75  };
76 
77  } // rat
78 
79 } // vcsn
80 
81 #include <vaucanson/algebra/implementation/series/rat/length_visitor.hxx>
82 
83 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_LENGTH_VISITOR_HH