semiring_base.hh

00001 // semiring_base.hh: this file is part of the Vaucanson project.
00002 //
00003 // Vaucanson, a generic library for finite state machines.
00004 //
00005 // Copyright (C) 2001, 2002, 2003, 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_CONCEPT_SEMIRING_BASE_HH
00018 # define VCSN_ALGEBRA_CONCEPT_SEMIRING_BASE_HH
00019 
00020 # include <vaucanson/algebra/concept/monoid_base.hh>
00021 # include <vaucanson/misc/contract.hh>
00022 # include <string>
00023 
00024 namespace vcsn {
00025 
00026   namespace algebra {
00027 
00031     /*-------------------.
00032     | SemiringBase<Self> |
00033     `-------------------*/
00034 
00036     template <class Self>
00037     struct SemiringBase : MonoidBase<Self>
00038     {
00039     public:
00046       template <class T>
00047       bool can_choose_non_starable(SELECTOR(T)) const;
00048 
00050       template <class T>
00051       Element<Self, T>  choose_starable(SELECTOR(T)) const;
00052 
00054       template <class T>
00055       Element<Self, T> choose_non_starable(SELECTOR(T)) const;
00056     protected:
00058       SemiringBase();
00059 
00061       SemiringBase(const SemiringBase& other);
00062     };
00063 
00067   } // algebra
00068 
00072   /*------------------------------------.
00073   | dynamic_traits<SemiringBase<Self> > |
00074   `------------------------------------*/
00075 
00076   template<typename Self>
00077   struct dynamic_traits<algebra::SemiringBase<Self> >
00078     : dynamic_traits<algebra::MonoidBase<Self> >
00079   { };
00080 
00081   template<typename S>
00082   struct virtual_types<algebra::SemiringBase<S> >
00083     : virtual_types<algebra::MonoidBase<S> >
00084   { };
00085 
00086   /*-----------------------------------.
00087   | MetaElement<SemiringBase<Self>, T> |
00088   `-----------------------------------*/
00089 
00091   template <typename Self, typename T>
00092   struct MetaElement<algebra::SemiringBase<Self>, T>
00093     : MetaElement<algebra::MonoidBase<Self>, T>
00094   {
00096     Element<Self, T>&   star();
00097 
00099     bool                starable() const;
00100 
00101   protected:
00103     MetaElement();
00104 
00106     MetaElement(const MetaElement& other);
00107   };
00108 
00110   template <typename S, typename T>
00111   struct op_star_traits
00112   {
00113     typedef Element<S, T> ret_t;
00114   };
00115 
00117   template <typename S, typename T>
00118   typename op_star_traits<S, T>::ret_t
00119   star(const Element<S, T>& w);
00120 
00122   template <typename S, typename T>
00123   bool
00124   parse_weight(Element<S, T>& w, const std::string&,
00125                typename std::string::const_iterator&);
00126 
00128   template <typename S, typename T>
00129   bool starable(const Element<S, T>& elt);
00130 
00134   // default implementations:
00135 
00137   template <typename S, typename T>
00138   bool
00139   op_can_choose_non_starable(const algebra::SemiringBase<S>& set, SELECTOR(T));
00140 
00142   template <typename S, typename T>
00143   Element<S, T>
00144   op_choose_starable(const algebra::SemiringBase<S>& set, SELECTOR(T));
00145 
00147   template <typename S, typename T>
00148   Element<S, T>
00149   op_choose_non_starable(const algebra::SemiringBase<S>& set, SELECTOR(T));
00150 
00151 
00152   template <typename S, typename T>
00153   bool
00154   op_parse(const algebra::SemiringBase<S>&, T& w,
00155         const std::string&,
00156         typename std::string::const_iterator&);
00157 
00158   template <typename Self, typename T>
00159   bool op_starable(const algebra::SemiringBase<Self>& s, const T& v);
00160 
00161   template <typename Self, typename T>
00162   void op_in_star(const algebra::SemiringBase<Self>& s, T& v);
00163 
00164   template <typename Self, typename T>
00165   T op_default(SELECTOR(algebra::SemiringBase<Self>), SELECTOR(T));
00166 
00167 } // vcsn
00168 
00169 # ifndef VCSN_USE_INTERFACE_ONLY
00170 #  include <vaucanson/algebra/concept/semiring_base.hxx>
00171 # endif // VCSN_USE_INTERFACE_ONLY
00172 
00173 #endif // ! VCSN_ALGEBRA_CONCEPT_SEMIRING_BASE_HH

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