Vaucanson 1.4
|
00001 // alphabets_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, 2006, 2007, 2008 The 00006 // Vaucanson Group. 00007 // 00008 // This program is free software; you can redistribute it and/or 00009 // modify it under the terms of the GNU General Public License 00010 // as published by the Free Software Foundation; either version 2 00011 // of the License, or (at your option) any later version. 00012 // 00013 // The complete GNU General Public Licence Notice can be found as the 00014 // `COPYING' file in the root directory. 00015 // 00016 // The Vaucanson Group consists of people listed in the `AUTHORS' file. 00017 // 00018 #ifndef VCSN_ALGEBRA_CONCEPT_ALPHABETS_BASE_HH 00019 # define VCSN_ALGEBRA_CONCEPT_ALPHABETS_BASE_HH 00020 00026 # include <vaucanson/design_pattern/design_pattern.hh> 00027 # include <vaucanson/misc/container_ops.hh> 00028 # include <vaucanson/algebra/concept/letter.hh> 00029 00030 namespace vcsn { 00031 00032 namespace algebra { 00033 00037 /*----------------------. 00038 | AlphabetSetBase<Self> | 00039 `----------------------*/ 00040 00052 template<class S> 00053 struct AlphabetSetBase 00054 : Structure<S> 00055 { 00056 protected: 00057 00059 00060 AlphabetSetBase(); 00061 AlphabetSetBase(const AlphabetSetBase& other); 00063 }; 00064 00065 /*----------------. 00066 | alphabet_traits | 00067 `----------------*/ 00068 00076 template<typename S, typename T> 00077 struct alphabet_traits 00078 { 00080 typedef undefined_type letter_t; 00081 00083 typedef undefined_type first_projection_t; 00084 00086 typedef undefined_type second_projection_t; 00087 00089 static const bool dynamic_data = false; 00090 }; 00091 00095 } // algebra 00096 00100 /*---------------. 00101 | dynamic_traits | 00102 `---------------*/ 00103 00105 template<typename S> 00106 struct dynamic_traits<algebra::AlphabetSetBase<S> > 00107 : dynamic_traits<Structure<S> > 00108 { }; 00109 00110 /*--------------. 00111 | virtual_types | 00112 `--------------*/ 00113 00115 template<typename S> 00116 struct virtual_types<algebra::AlphabetSetBase<S> > 00117 : virtual_types<Structure<S> > 00118 { }; 00119 00120 00121 /*--------------------------------------. 00122 | MetaElement<AlphabetSetBase<Self>, T> | 00123 `--------------------------------------*/ 00124 00130 template<class S, typename T> 00131 struct MetaElement<algebra::AlphabetSetBase<S>, T> 00132 : MetaElement<Structure<S>, T> 00133 { 00134 00136 typedef typename algebra::alphabet_traits<S, T>::letter_t letter_t; 00137 00139 typedef typename op_begin_traits<S, T>::const_ret_t const_iterator; 00140 00142 typedef typename op_begin_traits<S, T>::ret_t iterator; 00143 00145 void insert(const letter_t& l); 00146 00148 void insert(const std::string& lit); 00149 00151 letter_t choose() const; 00152 00154 letter_t random_letter() const; 00155 00157 size_t size() const; 00158 00160 size_t max_size() const; 00161 00163 bool letter_equality(letter_t, letter_t) const; 00164 00166 bool contains(const letter_t& l) const; 00167 00169 bool is_finite() const; 00170 00172 00173 iterator begin(); 00174 const_iterator begin() const; 00176 00178 00179 iterator end(); 00180 const_iterator end() const; 00182 00183 protected: 00185 00186 MetaElement(); 00187 MetaElement(const MetaElement& other); 00189 }; 00190 00191 namespace algebra 00192 { 00194 template <typename S, typename L> 00195 L op_parse(const AlphabetSetBase<S>& s, 00196 const std::string&, 00197 size_t&); 00198 00200 template <typename S, typename St, typename T> 00201 St& op_rout(const AlphabetSetBase<S>& s, St& st, const T& a); 00202 00204 template <typename S, typename T, typename L> 00205 bool op_letter_equality(const AlphabetSetBase<S>& s, 00206 const T& a, 00207 L lhs, 00208 L rhs); 00209 } // ! algebra 00210 00212 template <typename S, typename T> 00213 std::pair<bool, typename Element<S, T>::letter_t> 00214 parse_letter(const Element<S, T>& alphabet, 00215 const std::string& s); 00216 00220 } // vcsn 00221 00222 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB 00223 # include <vaucanson/algebra/concept/alphabets_base.hxx> 00224 # endif // VCSN_USE_INTERFACE_ONLY 00225 00226 #endif // ! VCSN_ALGEBRA_CONCEPT_ALPHABETS_BASE_HH