freemonoid_product_pair_str.hxx

00001 // freemonoid_product_pair_str.hxx: this file is part of the Vaucanson project.
00002 //
00003 // Vaucanson, a generic library for finite state machines.
00004 //
00005 // Copyright (C) 2004, 2005, 2007 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_FREE_MONOID_PRODUCT_FREEMONOID_PRODUCT_PAIR_STR_HXX
00018 # define VCSN_ALGEBRA_IMPLEMENTATION_FREE_MONOID_PRODUCT_FREEMONOID_PRODUCT_PAIR_STR_HXX
00019 
00020 # include <vaucanson/algebra/implementation/free_monoid_product/freemonoid_product_pair_str.hxx>
00021 
00022 namespace vcsn {
00023 
00024   namespace algebra {
00025 
00026     template <class Self, typename T>
00027     typename
00028     MetaElement<algebra::FreeMonoidProductBase<Self>, T>::first_monoid_elt_t&
00029     op_first(const algebra::FreeMonoidProductBase<Self>& s, T& v)
00030     {
00031       return Element<typename virtual_types<Self>::first_monoid_t,
00032                      typename T::first_type> (s.first_monoid(), v.first);
00033     }
00034 
00035     template <class Self, typename T>
00036     typename
00037     MetaElement<algebra::FreeMonoidProductBase<Self>, T>::second_monoid_elt_t&
00038     op_second(const algebra::FreeMonoidProductBase<Self>& s, T& v)
00039     {
00040       return Element<typename virtual_types<Self>::second_monoid_t,
00041                      typename T::second_type> (s.second_monoid(), v.second);
00042     }
00043 
00044     template <class F, class S>
00045     void
00046     op_in_mul(const algebra::FreeMonoidProduct<F, S>& s,
00047               std::pair<std::basic_string<typename F::letter_t>,
00048                         std::basic_string<typename S::letter_t> >& dst,
00049               const std::pair<std::basic_string<typename F::letter_t>,
00050                               std::basic_string<typename S::letter_t> >& src)
00051     {
00052       dst.first += src.first;
00053       dst.second += src.second;
00054     }
00055 
00056     template<class F, class S>
00057     std::pair<std::basic_string<typename F::letter_t>,
00058               std::basic_string<typename S::letter_t> >
00059     op_mul(const algebra::FreeMonoidProduct<F, S>&,
00060            const std::pair<std::basic_string<typename F::letter_t>,
00061                            std::basic_string<typename S::letter_t> >& a,
00062            const std::pair<std::basic_string<typename F::letter_t>,
00063                            std::basic_string<typename S::letter_t> >& b)
00064     {
00065       return std::pair< std::basic_string<typename F::letter_t>,
00066                         std::basic_string<typename S::letter_t> >
00067                                 (a.first + b.first, a.second + b.second);
00068     }
00069 
00070     template<class F, class S>
00071     const std::pair<std::basic_string<typename F::letter_t>,
00072                     std::basic_string<typename S::letter_t> >
00073     identity_value(SELECTOR2(algebra::FreeMonoidProduct<F, S>),
00074                    SELECTOR2(std::pair<std::basic_string<typename F::letter_t>,
00075                             std::basic_string<typename S::letter_t> >))
00076     {
00077       static const std::pair<std::basic_string<typename F::letter_t>,
00078                              std::basic_string<typename S::letter_t> >
00079         instance;
00080       return instance;
00081     }
00082 
00083     template <class F, class S>
00084     Element<algebra::FreeMonoidProduct<F, S>,
00085             std::pair<std::basic_string<typename F::letter_t>,
00086                       std::basic_string<typename S::letter_t> > >
00087     op_choose(const algebra::FreeMonoidProduct<F, S>& s,
00088               SELECTOR2(std::pair<std::basic_string<typename F::letter_t>,
00089                                  std::basic_string<typename S::letter_t> >))
00090     {
00091       typedef std::basic_string<typename F::letter_t> T1;
00092       typedef std::basic_string<typename S::letter_t> T2;
00093 
00094       std::pair< T1, T2 > res(s.first_monoid().choose(SELECT(T1)).value(),
00095                               s.second_monoid().choose(SELECT(T2)).value());
00096 
00097       return Element<algebra::FreeMonoidProduct<F, S>,
00098                      std::pair< T1, T2 > >              (s, res);
00099     }
00100 
00101     template<typename Self, typename T>
00102     void
00103     op_in_mirror(const algebra::FreeMonoidProductBase<Self>& s, T& v)
00104     {
00105       op_in_mirror(s.first_monoid(), v.first);
00106       op_in_mirror(s.second_monoid(), v.second);
00107     }
00108 
00109     template<typename Self, typename T, typename Ftor>
00110     typename Ftor::result_type
00111     op_length(const algebra::FreeMonoidProductBase<Self>&, const T& v, Ftor f)
00112     {
00113       return f(v.first.length(), v.second.length());
00114     }
00115 
00116     template <typename Self, typename St, typename T>
00117     St&
00118     op_rout(const algebra::FreeMonoidProductBase<Self>& s,
00119             St& st,
00120             const T& v)
00121     {
00122       st << "(";
00123       op_rout(s.first_monoid(), st, v.first);
00124       st << ",";
00125       op_rout(s.second_monoid(), st, v.second);
00126       st << ")";
00127       return st;
00128     }
00129 
00130   } // algebra
00131 
00132 } // vcsn
00133 
00134 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_FREE_MONOID_PRODUCT_FREEMONOID_PRODUCT_PAIR_STR_HXX

Generated on Thu Dec 13 16:02:59 2007 for Vaucanson by  doxygen 1.5.4