Vaucanson  1.4.1
reverse_visitor.hh
1 // reverse_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 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_REVERSE_VISITOR_HH
18 # define VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_REVERSE_VISITOR_HH
19 
20 # include <vaucanson/algebra/concept/series_base.hh>
21 # include <vaucanson/algebra/concept/semiring_base.hh>
22 # include <vaucanson/algebra/implementation/series/rat/exp.hh>
23 
24 namespace vcsn
25 {
26 
27  namespace rat
28  {
29 
30  template <class Semiring, class Word, class Weight>
31  class ReverseVisitor :
32  public rat::DefaultMutableNodeVisitor<Word, Weight>
33  {
34  public:
35  ReverseVisitor(const algebra::SemiringBase<Semiring>& s);
36 
37  virtual
38  void
39  product(rat::Node<Word, Weight>* lhs,
40  rat::Node<Word, Weight>* rhs);
41 
42  virtual
43  void
44  constant(Word& w);
45 
46  virtual
47  void
48  left_weight(Weight& w);
49 
50  virtual
51  void
52  right_weight(Weight& w);
53 
54  protected:
55  template <class S>
56  static
57  Weight
58  transpose(const algebra::SeriesBase<S>&, const Weight&);
59 
60  template <class S>
61  static
62  Weight
63  transpose(const algebra::SemiringBase<S>&, const Weight&);
64 
65  const Semiring& s_;
66  };
67 
68  } // End of namespace rat.
69 
70  namespace algebra
71  {
72 
73  template <typename S, typename T>
74  struct DefaultTransposeFun;
75 
76  template <typename S, typename Word, typename Weight>
77  struct DefaultTransposeFun< S, rat::exp<Word, Weight> >
78  {
79  rat::exp<Word, Weight>&
80  operator () (const S&, const rat::exp<Word, Weight>& exp);
81  };
82 
83  } // End of namespace algebra.
84 
85 } // End of namespace vcsn.
86 
87 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
88 # include <vaucanson/algebra/implementation/series/rat/reverse_visitor.hxx>
89 # endif // ! VCSN_USE_INTERFACE_ONLY
90 
91 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_REVERSE_VISITOR_HH