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

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