- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

# depth_visitor.hxx

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