Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
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 
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 
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   } 
00096 
00100   
00101 
00102 
00103 
00105   template<typename S>
00106   struct dynamic_traits<algebra::AlphabetSetBase<S> >
00107     : dynamic_traits<Structure<S> >
00108   { };
00109 
00110   
00111 
00112 
00113 
00115   template<typename S>
00116   struct virtual_types<algebra::AlphabetSetBase<S> >
00117     : virtual_types<Structure<S> >
00118   { };
00119 
00120 
00121   
00122 
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   } 
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 } 
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