Vaucanson 1.4
|
00001 // reverse_visitor.hh: this file is part of the Vaucanson project. 00002 // 00003 // Vaucanson, a generic library for finite state machines. 00004 // 00005 // Copyright (C) 2004, 2005 The Vaucanson Group. 00006 // 00007 // This program is free software; you can redistribute it and/or 00008 // modify it under the terms of the GNU General Public License 00009 // as published by the Free Software Foundation; either version 2 00010 // of the License, or (at your option) any later version. 00011 // 00012 // The complete GNU General Public Licence Notice can be found as the 00013 // `COPYING' file in the root directory. 00014 // 00015 // The Vaucanson Group consists of people listed in the `AUTHORS' file. 00016 // 00017 #ifndef VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_REVERSE_VISITOR_HH 00018 # define VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_REVERSE_VISITOR_HH 00019 00020 # include <vaucanson/algebra/concept/series_base.hh> 00021 # include <vaucanson/algebra/concept/semiring_base.hh> 00022 # include <vaucanson/algebra/implementation/series/rat/exp.hh> 00023 00024 namespace vcsn 00025 { 00026 00027 namespace rat 00028 { 00029 00030 template <class Semiring, class Word, class Weight> 00031 class ReverseVisitor : 00032 public rat::DefaultMutableNodeVisitor<Word, Weight> 00033 { 00034 public: 00035 ReverseVisitor(const algebra::SemiringBase<Semiring>& s); 00036 00037 virtual 00038 void 00039 product(rat::Node<Word, Weight>* lhs, 00040 rat::Node<Word, Weight>* rhs); 00041 00042 virtual 00043 void 00044 constant(Word& w); 00045 00046 virtual 00047 void 00048 left_weight(Weight& w); 00049 00050 virtual 00051 void 00052 right_weight(Weight& w); 00053 00054 protected: 00055 template <class S> 00056 static 00057 Weight 00058 transpose(const algebra::SeriesBase<S>&, const Weight&); 00059 00060 template <class S> 00061 static 00062 Weight 00063 transpose(const algebra::SemiringBase<S>&, const Weight&); 00064 00065 const Semiring& s_; 00066 }; 00067 00068 } // End of namespace rat. 00069 00070 namespace algebra 00071 { 00072 00073 template <typename S, typename T> 00074 struct DefaultTransposeFun; 00075 00076 template <typename S, typename Word, typename Weight> 00077 struct DefaultTransposeFun< S, rat::exp<Word, Weight> > 00078 { 00079 rat::exp<Word, Weight>& 00080 operator () (const S&, const rat::exp<Word, Weight>& exp); 00081 }; 00082 00083 } // End of namespace algebra. 00084 00085 } // End of namespace vcsn. 00086 00087 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB 00088 # include <vaucanson/algebra/implementation/series/rat/reverse_visitor.hxx> 00089 # endif // ! VCSN_USE_INTERFACE_ONLY 00090 00091 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_REVERSE_VISITOR_HH