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_HXX
00018 # define VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_DISPATCH_VISITOR_HXX
00019 
00020 # include <vaucanson/algebra/implementation/series/rat/dispatch_visitor.hh>
00021 
00022 namespace vcsn
00023 {
00024 
00025   namespace algebra
00026   {
00027 
00028     template <class Matcher, class Monoid, class Semiring>
00029     DispatchVisitor<Matcher, Monoid, Semiring>::DispatchVisitor(Matcher& m) :
00030       matcher_(m)
00031     {}
00032 
00033     template <class Matcher, class Monoid, class Semiring>
00034     DispatchVisitor<Matcher, Monoid, Semiring>::~DispatchVisitor()
00035     {}
00036 
00037     template <class Matcher, class Monoid, class Semiring>
00038     void
00039     DispatchVisitor<Matcher, Monoid, Semiring>::
00040     product(const node_t* lhs, const node_t* rhs)
00041     {
00042       ret_ = matcher_.match_nodeProduct(typename Matcher::Product(lhs, rhs));
00043     }
00044 
00045     template <class Matcher, class Monoid, class Semiring>
00046     void
00047     DispatchVisitor<Matcher, Monoid, Semiring>::
00048     sum(const node_t* lhs, const node_t* rhs)
00049     {
00050       ret_ = matcher_.match_nodeSum(typename Matcher::Sum(lhs, rhs));
00051     }
00052 
00053     template <class Matcher, class Monoid, class Semiring>
00054     void
00055     DispatchVisitor<Matcher, Monoid, Semiring>::
00056     star(const node_t* node)
00057     {
00058       ret_ = matcher_.match_nodeStar(typename Matcher::Star(node));
00059     }
00060 
00061     template <class Matcher, class Monoid, class Semiring>
00062     void
00063     DispatchVisitor<Matcher, Monoid, Semiring>::
00064     left_weight(const semiring_elt_value_t& w, const node_t* node)
00065     {
00066       ret_ = matcher_.match_nodeLeftWeight(typename Matcher::LeftWeight(w,
00067                                                                         node));
00068     }
00069 
00070     template <class Matcher, class Monoid, class Semiring>
00071     void
00072     DispatchVisitor<Matcher, Monoid, Semiring>::
00073     right_weight(const semiring_elt_value_t& w, const node_t* node)
00074     {
00075       ret_ = matcher_.match_nodeRightWeight(typename
00076                                             Matcher::RightWeight(node, w));
00077     }
00078 
00079     template <class Matcher, class Monoid, class Semiring>
00080     void
00081     DispatchVisitor<Matcher, Monoid, Semiring>::
00082     constant(const monoid_elt_value_t& m)
00083     {
00084       ret_ = matcher_.match_nodeConstant(typename Matcher::Constant(m));
00085     }
00086 
00087     template <class Matcher, class Monoid, class Semiring>
00088     void
00089     DispatchVisitor<Matcher, Monoid, Semiring>::
00090     zero()
00091     {
00092       ret_ = matcher_.match_nodeZero(typename Matcher::Zero());
00093     }
00094 
00095     template <class Matcher, class Monoid, class Semiring>
00096     void
00097     DispatchVisitor<Matcher, Monoid, Semiring>::
00098     one()
00099     {
00100       ret_ = matcher_.match_nodeOne(typename Matcher::One());
00101     }
00102 
00103     template <class Matcher, class Monoid, class Semiring>
00104     typename DispatchVisitor<Matcher, Monoid, Semiring>::return_type
00105     DispatchVisitor<Matcher, Monoid, Semiring>::
00106     get_ret()
00107     {
00108       return ret_;
00109     }
00110 
00111     template <class M, class W>
00112     template <class Matcher>
00113     typename Matcher::return_type
00114     DispatchFunction< rat::exp<M, W> >::d(Matcher& matcher,
00115                                           const rat::exp<M, W>& exp)
00116     {
00117       DispatchVisitor<Matcher, M, W> v(matcher);
00118       exp.accept(v);
00119       return v.get_ret ();
00120     }
00121 
00122   } 
00123 
00124 } 
00125 
00126 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_DISPATCH_VISITOR_HXX