star_height_visitor.hxx

00001 // star_height_visitor.hxx: this file is part of the Vaucanson project.
00002 //
00003 // Vaucanson, a generic library for finite state machines.
00004 //
00005 // Copyright (C) 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_STAR_HEIGHT_VISITOR_HXX
00018 # define VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_STAR_HEIGHT_VISITOR_HXX
00019 
00020 # include <algorithm>
00021 
00022 # include <vaucanson/algebra/implementation/series/rat/star_height_visitor.hh>
00023 
00024 namespace vcsn {
00025 
00026   namespace rat {
00027 
00028     template<typename M_, typename W_>
00029     void
00030     StarHeightVisitor<M_,W_>::sum_or_product(const Node<M_, W_>* left_,
00031                                              const Node<M_, W_>* right_)
00032     {
00033       size_t post = h_;
00034       left_->accept(*this);
00035       size_t left_height = h_;
00036       h_ = post;
00037       right_->accept(*this);
00038       h_ = std::max(h_, left_height);
00039     }
00040 
00041     template<typename M_, typename W_>
00042     void
00043     StarHeightVisitor<M_, W_>::weight_or_star(const Node<M_, W_>* node)
00044     {
00045       node->accept(*this);
00046     }
00047 
00048     template<typename M_, typename W_>
00049     void
00050     StarHeightVisitor<M_, W_>::product(const Node<M_, W_>* left_,
00051                                    const Node<M_, W_>* right_)
00052     {
00053       sum_or_product(left_, right_);
00054     }
00055 
00056     template<typename M_, typename W_>
00057     void
00058     StarHeightVisitor<M_, W_>::sum(const Node<M_, W_>* left_,
00059                               const Node<M_, W_>* right_)
00060     {
00061       sum_or_product(left_, right_);
00062     }
00063 
00064     template<typename M_, typename W_>
00065     void
00066     StarHeightVisitor<M_, W_>::star(const Node<M_, W_>* node)
00067     {
00068       h_++;
00069       node->accept(*this);
00070     }
00071 
00072     template<typename M_, typename W_>
00073     void
00074     StarHeightVisitor<M_, W_>::left_weight(const W_&, const Node<M_, W_>* node)
00075     {
00076       weight_or_star(node);
00077     }
00078 
00079     template<typename M_, typename W_>
00080     void
00081     StarHeightVisitor<M_, W_>::right_weight(const W_&, const Node<M_, W_>* node)
00082     {
00083       weight_or_star(node);
00084     }
00085 
00086     template<typename M_, typename W_>
00087     void
00088     StarHeightVisitor<M_, W_>::constant(const M_&)
00089     {
00090     }
00091 
00092     template<typename M_, typename W_>
00093     void StarHeightVisitor<M_, W_>::zero()
00094     {
00095     }
00096 
00097     template<typename M_, typename W_>
00098     void StarHeightVisitor<M_, W_>::one()
00099     {
00100     }
00101 
00102     template<typename M_, typename W_>
00103     size_t StarHeightVisitor<M_, W_>::get() const
00104     {
00105       return h_;
00106     }
00107 
00108   } // End of namespace rat.
00109 
00110 } // End of namespace vcsn.
00111 
00112 
00113 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_STAR_HEIGHT_VISITOR_HXX

Generated on Fri Jul 28 12:18:53 2006 for Vaucanson by  doxygen 1.4.6