00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 #ifndef VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_DISPATCH_VISITOR_HH
00018 # define VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_DISPATCH_VISITOR_HH
00019 
00020 # include <vaucanson/algebra/implementation/series/rat/exp.hh>
00021 # include <vaucanson/misc/deferrer.hh>
00022 
00023 namespace vcsn
00024 {
00025 
00026   namespace algebra
00027   {
00028 
00029     template <class Matcher, class Monoid, class Semiring>
00030     class DispatchVisitor :
00031       public rat::DefaultMutableNodeVisitor<Monoid, Semiring>
00032     {
00033     public:
00034       typedef Matcher                                   matcher_t;
00035       typedef typename Matcher::return_type             return_type;
00036       typedef Monoid                                    monoid_elt_value_t;
00037       typedef Semiring                                  semiring_elt_value_t;
00038       typedef rat::Node<monoid_elt_value_t, semiring_elt_value_t>       node_t;
00039 
00040       DispatchVisitor(Matcher& m);
00041 
00042       virtual
00043       ~DispatchVisitor();
00044 
00045       virtual void
00046       product(const node_t* lhs, const node_t* rhs);
00047 
00048       virtual void
00049       sum(const node_t* lhs, const node_t* rhs);
00050 
00051       virtual void
00052       star(const node_t* node);
00053 
00054       virtual void
00055       left_weight(const semiring_elt_value_t& w, const node_t* node);
00056 
00057       virtual void
00058       right_weight(const semiring_elt_value_t& w, const node_t* node);
00059 
00060       virtual void
00061       constant(const monoid_elt_value_t& m);
00062 
00063       virtual void
00064       zero();
00065 
00066       virtual void
00067       one();
00068 
00069       return_type get_ret();
00070 
00071     private:
00072       matcher_t&                        matcher_;
00073       misc::Deferrer<return_type>       ret_;
00074     };
00075 
00076     template <class T>
00077     struct DispatchFunction;
00078 
00085     template <class M, class W>
00086     struct DispatchFunction< rat::exp<M, W> >
00087     {
00088       template <class Matcher>
00089       static
00090       typename Matcher::return_type
00091       d(Matcher& matcher, const rat::exp<M, W>& exp);
00092     };
00093 
00094   } 
00095 
00096 } 
00097 
00098 # ifndef VCSN_USE_INTERFACE_ONLY
00099 #  include <vaucanson/algebra/implementation/series/rat/dispatch_visitor.hxx>
00100 # endif // ! VCSN_USE_INTERFACE_ONLY
00101 
00102 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_DISPATCH_VISITOR_HH