00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 #ifndef VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_LENGTH_VISITOR_HXX
00018 # define VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_LENGTH_VISITOR_HXX
00019 
00020 # include <vaucanson/algebra/implementation/series/rat/length_visitor.hh>
00021 
00022 # include <algorithm>
00023 
00024 namespace vcsn {
00025 
00026   namespace rat {
00027 
00028     template<typename M_, typename W_>
00029     void
00030     LengthVisitor<M_,W_>::sum_or_product(const Node<M_, W_>* left_,
00031                                          const Node<M_, W_>* right_)
00032     {
00033       left_->accept(*this);
00034       right_->accept(*this);
00035     }
00036 
00037     template<typename M_, typename W_>
00038     void
00039     LengthVisitor<M_, W_>::weight_or_star(const Node<M_, W_>* node)
00040     {
00041       node->accept(*this);
00042     }
00043 
00044     template<typename M_, typename W_>
00045     void
00046     LengthVisitor<M_, W_>::product(const Node<M_, W_>* left_,
00047                                    const Node<M_, W_>* right_)
00048     {
00049       sum_or_product(left_, right_);
00050     }
00051 
00052     template<typename M_, typename W_>
00053     void
00054     LengthVisitor<M_, W_>::sum(const Node<M_, W_>* left_,
00055                                const Node<M_, W_>* right_)
00056     {
00057       sum_or_product(left_, right_);
00058     }
00059 
00060     template<typename M_, typename W_>
00061     void
00062     LengthVisitor<M_, W_>::star(const Node<M_, W_>* node)
00063     {
00064       weight_or_star(node);
00065     }
00066 
00067     template<typename M_, typename W_>
00068     void
00069     LengthVisitor<M_, W_>::left_weight(const W_&, const Node<M_, W_>* node)
00070     {
00071       weight_or_star(node);
00072     }
00073 
00074     template<typename M_, typename W_>
00075     void
00076     LengthVisitor<M_, W_>::right_weight(const W_&, const Node<M_, W_>* node)
00077     {
00078       weight_or_star(node);
00079     }
00080 
00081     template<typename M_, typename W_>
00082     void
00083     LengthVisitor<M_, W_>::constant(const M_&)
00084     {
00085       ++s_;
00086     }
00087 
00088     template<typename M_, typename W_>
00089     void LengthVisitor<M_, W_>::zero()
00090     {
00091       ++s_;
00092     }
00093 
00094     template<typename M_, typename W_>
00095     void LengthVisitor<M_, W_>::one()
00096     {
00097       ++s_;
00098     }
00099 
00100     template<typename M_, typename W_>
00101     size_t LengthVisitor<M_, W_>::get() const
00102     {
00103       return s_;
00104     }
00105 
00106   } 
00107 
00108 } 
00109 
00110 
00111 
00112 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_LENGTH_VISITOR_HXX