Vaucanson  1.4.1
semiring_base.hh
1 // semiring_base.hh: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2011 The Vaucanson Group.
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
11 //
12 // The complete GNU General Public Licence Notice can be found as the
13 // `COPYING' file in the root directory.
14 //
15 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
16 //
17 #ifndef VCSN_ALGEBRA_CONCEPT_SEMIRING_BASE_HH
18 # define VCSN_ALGEBRA_CONCEPT_SEMIRING_BASE_HH
19 
20 # include <vaucanson/algebra/concept/monoid_base.hh>
22 # include <string>
24 
25 namespace vcsn {
26 
27  namespace algebra {
28 
32  /*-------------------.
33  | SemiringBase<Self> |
34  `-------------------*/
35 
37  template <class Self>
38  struct SemiringBase : MonoidBase<Self>
39  {
40  public:
47  template <class T>
48  bool can_choose_non_starable(SELECTOR(T)) const;
49 
51  template <class T>
53 
55  template <class T>
57  protected:
59  SemiringBase();
60 
62  SemiringBase(const SemiringBase& other);
63  };
64 
68  } // algebra
69 
73  /*------------------------------------.
74  | dynamic_traits<SemiringBase<Self> > |
75  `------------------------------------*/
76 
77  template<typename Self>
78  struct dynamic_traits<algebra::SemiringBase<Self> >
79  : dynamic_traits<algebra::MonoidBase<Self> >
80  { };
81 
82  template<typename S>
83  struct virtual_types<algebra::SemiringBase<S> >
84  : virtual_types<algebra::MonoidBase<S> >
85  { };
86 
87  /*-----------------------------------.
88  | MetaElement<SemiringBase<Self>, T> |
89  `-----------------------------------*/
90 
92  template <typename Self, typename T>
93  struct MetaElement<algebra::SemiringBase<Self>, T>
94  : MetaElement<algebra::MonoidBase<Self>, T>
95  {
98 
100  bool starable() const;
101 
102  protected:
104  MetaElement();
105 
107  MetaElement(const MetaElement& other);
108  };
109 
111  template <typename S, typename T>
113  {
114  typedef Element<S, T> ret_t;
115  };
116 
117 
122  template <typename S, typename T>
124  {
125  enum { is_positive = 0 };
126  };
127 
129  template <typename S, typename T>
130  typename op_star_traits<S, T>::ret_t
131  star(const Element<S, T>& w);
132 
134  template <typename S, typename T>
135  bool
136  parse_weight(Element<S, T>& w, const std::string&,
137  typename std::string::const_iterator&);
138 
140  template <typename S, typename T>
141  bool starable(const Element<S, T>& elt);
142 
146  namespace algebra {
147 
148  // default implementations:
149 
151  template <typename S, typename T>
152  bool
154  SELECTOR(T));
155 
157  template <typename S, typename T>
160 
162  template <typename S, typename T>
165 
166 
167  template <typename S, typename T>
168  bool
169  op_parse(const algebra::SemiringBase<S>&, T& w,
170  const std::string&,
171  typename std::string::const_iterator&);
172 
173  template <typename Self, typename T>
174  bool op_starable(const algebra::SemiringBase<Self>& s, const T& v);
175 
176  template <typename Self, typename T>
177  void op_in_star(const algebra::SemiringBase<Self>& s, T& v);
178 
179  template <typename Self, typename T>
180  T op_default(SELECTOR(algebra::SemiringBase<Self>), SELECTOR(T));
181 
182  } // algebra
183 
184 } // vcsn
185 
186 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
187 # include <vaucanson/algebra/concept/semiring_base.hxx>
188 # endif // VCSN_USE_INTERFACE_ONLY
189 
190 #endif // ! VCSN_ALGEBRA_CONCEPT_SEMIRING_BASE_HH