00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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 # include <vaucanson/algebra/implementation/semiring/q_number.hh>
00024
00025 namespace vcsn {
00026
00027 namespace algebra {
00028
00032
00033
00034
00035
00037 template <class Self>
00038 struct SemiringBase : MonoidBase<Self>
00039 {
00040 public:
00047 template <class T>
00048 bool can_choose_non_starable(SELECTOR(T)) const;
00049
00051 template <class T>
00052 Element<Self, T> choose_starable(SELECTOR(T)) const;
00053
00055 template <class T>
00056 Element<Self, T> choose_non_starable(SELECTOR(T)) const;
00057 protected:
00059 SemiringBase();
00060
00062 SemiringBase(const SemiringBase& other);
00063 };
00064
00068 }
00069
00073
00074
00075
00076
00077 template<typename Self>
00078 struct dynamic_traits<algebra::SemiringBase<Self> >
00079 : dynamic_traits<algebra::MonoidBase<Self> >
00080 { };
00081
00082 template<typename S>
00083 struct virtual_types<algebra::SemiringBase<S> >
00084 : virtual_types<algebra::MonoidBase<S> >
00085 { };
00086
00087
00088
00089
00090
00092 template <typename Self, typename T>
00093 struct MetaElement<algebra::SemiringBase<Self>, T>
00094 : MetaElement<algebra::MonoidBase<Self>, T>
00095 {
00097 Element<Self, T>& star();
00098
00100 bool starable() const;
00101
00102 protected:
00104 MetaElement();
00105
00107 MetaElement(const MetaElement& other);
00108 };
00109
00111 template <typename S, typename T>
00112 struct op_star_traits
00113 {
00114 typedef Element<S, T> ret_t;
00115 };
00116
00117
00122 template <typename S, typename T>
00123 struct semiring_traits
00124 {
00125 enum { is_positive = 0 };
00126 };
00127
00129 template <typename S, typename T>
00130 typename op_star_traits<S, T>::ret_t
00131 star(const Element<S, T>& w);
00132
00134 template <typename S, typename T>
00135 bool
00136 parse_weight(Element<S, T>& w, const std::string&,
00137 typename std::string::const_iterator&);
00138
00140 template <typename S, typename T>
00141 bool starable(const Element<S, T>& elt);
00142
00146 namespace algebra {
00147
00148
00149
00151 template <typename S, typename T>
00152 bool
00153 op_can_choose_non_starable(const algebra::SemiringBase<S>& set,
00154 SELECTOR(T));
00155
00157 template <typename S, typename T>
00158 Element<S, T>
00159 op_choose_starable(const algebra::SemiringBase<S>& set, SELECTOR(T));
00160
00162 template <typename S, typename T>
00163 Element<S, T>
00164 op_choose_non_starable(const algebra::SemiringBase<S>& set, SELECTOR(T));
00165
00166
00167 template <typename S, typename T>
00168 bool
00169 op_parse(const algebra::SemiringBase<S>&, T& w,
00170 const std::string&,
00171 typename std::string::const_iterator&);
00172
00173 template <typename Self, typename T>
00174 bool op_starable(const algebra::SemiringBase<Self>& s, const T& v);
00175
00176 template <typename Self, typename T>
00177 void op_in_star(const algebra::SemiringBase<Self>& s, T& v);
00178
00179 template <typename Self, typename T>
00180 T op_default(SELECTOR(algebra::SemiringBase<Self>), SELECTOR(T));
00181
00182 }
00183
00184 }
00185
00186 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
00187 # include <vaucanson/algebra/concept/semiring_base.hxx>
00188 # endif // VCSN_USE_INTERFACE_ONLY
00189
00190 #endif // ! VCSN_ALGEBRA_CONCEPT_SEMIRING_BASE_HH