Vaucanson  1.4.1
dispatch_visitor.hh
1 // dispatch_visitor.hh: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 2004, 2005, 2006 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_HH
18 # define VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_DISPATCH_VISITOR_HH
19 
20 # include <vaucanson/algebra/implementation/series/rat/exp.hh>
22 
23 namespace vcsn
24 {
25 
26  namespace algebra
27  {
28 
29  template <class Matcher, class Monoid, class Semiring>
30  class DispatchVisitor :
31  public rat::DefaultMutableNodeVisitor<Monoid, Semiring>
32  {
33  public:
34  typedef Matcher matcher_t;
35  typedef typename Matcher::return_type return_type;
36  typedef Monoid monoid_elt_value_t;
37  typedef Semiring semiring_elt_value_t;
38  typedef rat::Node<monoid_elt_value_t, semiring_elt_value_t> node_t;
39 
40  DispatchVisitor(Matcher& m);
41 
42  virtual
43  ~DispatchVisitor();
44 
45  virtual void
46  product(const node_t* lhs, const node_t* rhs);
47 
48  virtual void
49  sum(const node_t* lhs, const node_t* rhs);
50 
51  virtual void
52  star(const node_t* node);
53 
54  virtual void
55  left_weight(const semiring_elt_value_t& w, const node_t* node);
56 
57  virtual void
58  right_weight(const semiring_elt_value_t& w, const node_t* node);
59 
60  virtual void
61  constant(const monoid_elt_value_t& m);
62 
63  virtual void
64  zero();
65 
66  virtual void
67  one();
68 
69  return_type get_ret();
70 
71  private:
72  matcher_t& matcher_;
73  misc::Deferrer<return_type> ret_;
74  };
75 
76  template <class T>
77  struct DispatchFunction;
78 
85  template <class M, class W>
86  struct DispatchFunction< rat::exp<M, W> >
87  {
88  template <class Matcher>
89  static
90  typename Matcher::return_type
91  d(Matcher& matcher, const rat::exp<M, W>& exp);
92  };
93 
94  } // End of namespace algebra.
95 
96 } // End of namespace vcsn.
97 
98 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
99 # include <vaucanson/algebra/implementation/series/rat/dispatch_visitor.hxx>
100 # endif // ! VCSN_USE_INTERFACE_ONLY
101 
102 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_DISPATCH_VISITOR_HH