length_visitor.hh

00001 // length_visitor.hh: 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_LENGTH_VISITOR_HH
00018 # define VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_LENGTH_VISITOR_HH
00019 
00020 
00021 # include <cstddef>
00022 
00023 # include <vaucanson/algebra/implementation/series/rat/nodes.hh>
00024 
00025 namespace vcsn {
00026 
00027   namespace rat {
00028 
00029     template<typename M_, typename W_>
00030     class LengthVisitor : public ConstNodeVisitor<M_, W_>
00031     {
00032     protected:
00033       void
00034       sum_or_product(const Node<M_, W_>* left_, const Node<M_, W_>* right_);
00035       void
00036       weight_or_star(const Node<M_, W_>* node);
00037 
00038     public:
00039       LengthVisitor() :
00040         s_(0)
00041       {}
00042 
00043       virtual void
00044       product(const Node<M_, W_>* left_, const Node<M_, W_>* right_);
00045 
00046       virtual void
00047       sum(const Node<M_, W_>* left_, const Node<M_, W_>* right_);
00048 
00049       virtual void
00050       star(const Node<M_, W_>* node);
00051 
00052       virtual void
00053       left_weight(const W_&, const Node<M_, W_>* node);
00054 
00055       virtual void
00056       right_weight(const W_&, const Node<M_, W_>* node);
00057 
00058       virtual void
00059       constant(const M_& m);
00060 
00061       virtual void zero();
00062 
00063       virtual void one();
00064 
00065       size_t get() const;
00066 
00067       size_t set(size_t v)
00068       {
00069         this->s_ = v;
00070         return this->s_;
00071       }
00072 
00073     protected:
00074       size_t            s_;
00075     };
00076 
00077   } // rat
00078 
00079 } // vcsn
00080 
00081 #include <vaucanson/algebra/implementation/series/rat/length_visitor.hxx>
00082 
00083 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_LENGTH_VISITOR_HH

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