Vaucanson  1.4.1
alphabets_base.hh
Go to the documentation of this file.
1 // alphabets_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, 2008 The
6 // Vaucanson Group.
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License
10 // as published by the Free Software Foundation; either version 2
11 // of the License, or (at your option) any later version.
12 //
13 // The complete GNU General Public Licence Notice can be found as the
14 // `COPYING' file in the root directory.
15 //
16 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
17 //
18 #ifndef VCSN_ALGEBRA_CONCEPT_ALPHABETS_BASE_HH
19 # define VCSN_ALGEBRA_CONCEPT_ALPHABETS_BASE_HH
20 
26 # include <vaucanson/design_pattern/design_pattern.hh>
28 # include <vaucanson/algebra/concept/letter.hh>
29 
30 namespace vcsn {
31 
32  namespace algebra {
33 
37  /*----------------------.
38  | AlphabetSetBase<Self> |
39  `----------------------*/
40 
52  template<class S>
54  : Structure<S>
55  {
56  protected:
57 
59 
61  AlphabetSetBase(const AlphabetSetBase& other);
63  };
64 
65  /*----------------.
66  | alphabet_traits |
67  `----------------*/
68 
76  template<typename S, typename T>
78  {
80  typedef undefined_type letter_t;
81 
83  typedef undefined_type first_projection_t;
84 
86  typedef undefined_type second_projection_t;
87 
89  static const bool dynamic_data = false;
90  };
91 
95  } // algebra
96 
100  /*---------------.
101  | dynamic_traits |
102  `---------------*/
103 
105  template<typename S>
106  struct dynamic_traits<algebra::AlphabetSetBase<S> >
107  : dynamic_traits<Structure<S> >
108  { };
109 
110  /*--------------.
111  | virtual_types |
112  `--------------*/
113 
115  template<typename S>
116  struct virtual_types<algebra::AlphabetSetBase<S> >
117  : virtual_types<Structure<S> >
118  { };
119 
120 
121  /*--------------------------------------.
122  | MetaElement<AlphabetSetBase<Self>, T> |
123  `--------------------------------------*/
124 
130  template<class S, typename T>
131  struct MetaElement<algebra::AlphabetSetBase<S>, T>
132  : MetaElement<Structure<S>, T>
133  {
134 
137 
139  typedef typename op_begin_traits<S, T>::const_ret_t const_iterator;
140 
142  typedef typename op_begin_traits<S, T>::ret_t iterator;
143 
145  void insert(const letter_t& l);
146 
148  void insert(const std::string& lit);
149 
151  letter_t choose() const;
152 
154  letter_t random_letter() const;
155 
157  size_t size() const;
158 
160  size_t max_size() const;
161 
163  bool letter_equality(letter_t, letter_t) const;
164 
166  bool contains(const letter_t& l) const;
167 
169  bool is_finite() const;
170 
172 
173  iterator begin();
174  const_iterator begin() const;
176 
178 
179  iterator end();
180  const_iterator end() const;
182 
183  protected:
185 
186  MetaElement();
187  MetaElement(const MetaElement& other);
189  };
190 
191  namespace algebra
192  {
194  template <typename S, typename L>
195  L op_parse(const AlphabetSetBase<S>& s,
196  const std::string&,
197  size_t&);
198 
200  template <typename S, typename St, typename T>
201  St& op_rout(const AlphabetSetBase<S>& s, St& st, const T& a);
202 
204  template <typename S, typename T, typename L>
205  bool op_letter_equality(const AlphabetSetBase<S>& s,
206  const T& a,
207  L lhs,
208  L rhs);
209  } // ! algebra
210 
212  template <typename S, typename T>
213  std::pair<bool, typename Element<S, T>::letter_t>
214  parse_letter(const Element<S, T>& alphabet,
215  const std::string& s);
216 
220 } // vcsn
221 
222 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
223 # include <vaucanson/algebra/concept/alphabets_base.hxx>
224 # endif // VCSN_USE_INTERFACE_ONLY
225 
226 #endif // ! VCSN_ALGEBRA_CONCEPT_ALPHABETS_BASE_HH