00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef VCSN_AUTOMATA_CONCEPT_KINDS_HH
00018 # define VCSN_AUTOMATA_CONCEPT_KINDS_HH
00019
00020 # include <vaucanson/config/system.hh>
00021 # include <iterator>
00022 # include <vaucanson/misc/contract.hh>
00023 # include <algorithm>
00024
00025 # include <vaucanson/algebra/concept/series_base.hh>
00026 # include <vaucanson/design_pattern/design_pattern.hh>
00027 # include <vaucanson/automata/concept/handlers.hh>
00028
00029 namespace vcsn {
00030
00031 template <
00032 typename Kind,
00033 typename Self,
00034 typename Series,
00035 typename SeriesT,
00036 typename LabelT
00037 >
00038 class AutoKind {};
00039
00040 namespace delta_kind {
00041
00042 struct transitions
00043 {};
00044
00045 struct states
00046 {};
00047
00048 }
00049
00050
00051 struct labels_are_series
00052 {};
00053
00054 template <
00055 typename Series,
00056 typename MonoidElt,
00057 typename SemiringElt,
00058 typename L
00059 >
00060 struct ls_delta_letter_query
00061 {
00062 ls_delta_letter_query(const Series& s, const L& l);
00063
00064 template<typename Label>
00065 bool operator()(const Label& label) const;
00066
00067 protected:
00068 SetSlot<Series> s_;
00069 typename MonoidElt::value_t l_;
00070 };
00071
00072
00073
00074
00076
00082 template <
00083 typename Self,
00084 typename Series,
00085 typename SeriesT,
00086 typename LabelT
00087 >
00088 class AutoKind<labels_are_series, Self, Series, SeriesT, LabelT>
00089 {
00090 protected:
00091 typedef typename Self::hstate_t hstate_t;
00092 typedef typename Self::htransition_t htransition_t;
00093 typedef Element<Series, SeriesT> series_set_elt_t;
00094 typedef typename Series::monoid_t monoid_t;
00095 typedef typename series_set_elt_t::monoid_elt_t monoid_elt_t;
00096 typedef typename Series::semiring_t semiring_t;
00097 typedef typename series_set_elt_t::semiring_elt_t semiring_elt_t;
00098
00099 public:
00100
00101 series_set_elt_t series_of(htransition_t e) const;
00102
00103 const SeriesT& series_value_of(htransition_t e) const;
00104
00105 bool is_spontaneous(htransition_t e) const;
00106
00107 template<typename L>
00108 L letter_of(SELECTOR(L), htransition_t e) const;
00109
00110 monoid_elt_t word_of(htransition_t e) const;
00111
00112 const typename monoid_elt_t::value_t& word_value_of(htransition_t e) const;
00113
00114 template<typename S>
00115 htransition_t add_series_transition(hstate_t from, hstate_t to,
00116 const S& e);
00117
00118 htransition_t add_spontaneous(hstate_t from, hstate_t to);
00119
00120 template<typename L>
00121 htransition_t add_letter_transition(hstate_t from, hstate_t to,
00122 const L& l);
00123
00124 template <typename OutputIterator, typename L>
00125 void letter_delta(OutputIterator res,
00126 hstate_t from,
00127 const L& l,
00128 delta_kind::transitions k = delta_kind::transitions()) const;
00129
00130 template <typename Container, typename L>
00131 void letter_deltac(Container& dst,
00132 hstate_t from,
00133 const L& l,
00134 delta_kind::transitions k = delta_kind::transitions()) const;
00135
00136 template <typename OutputIterator, typename L>
00137 void letter_rdelta(OutputIterator res,
00138 hstate_t from,
00139 const L& l,
00140 delta_kind::transitions k = delta_kind::transitions()) const;
00141
00142 template <typename Container, typename L>
00143 void letter_rdeltac(Container& dst,
00144 hstate_t from,
00145 const L& l,
00146 delta_kind::transitions k = delta_kind::transitions()) const;
00147
00148 template <typename OutputIterator, typename L>
00149 void letter_delta(OutputIterator res,
00150 hstate_t from,
00151 const L& l,
00152 delta_kind::states k) const;
00153
00154 template <typename Container, typename L>
00155 void letter_deltac(Container& dst,
00156 hstate_t from,
00157 const L& l,
00158 delta_kind::states k) const;
00159
00160 template <typename OutputIterator, typename L>
00161 void letter_rdelta(OutputIterator res,
00162 hstate_t from,
00163 const L& l,
00164 delta_kind::states k) const;
00165
00166 template <typename Container, typename L>
00167 void letter_rdeltac(Container& dst,
00168 hstate_t from,
00169 const L& l,
00170 delta_kind::states k) const;
00171
00172 protected:
00173 Self& auto_self();
00174 const Self& auto_self() const;
00175 };
00176
00177
00178 struct labels_are_couples
00179 {};
00180
00181 template<typename Monoid, typename L>
00182 struct lc_delta_letter_query
00183 {
00184 lc_delta_letter_query(const Monoid& m, const L& l);
00185
00186 template<typename Label>
00187 bool operator()(const Label& label) const;
00188
00189 protected:
00190 SetSlot<Monoid> m_;
00191 L l_;
00192 };
00193
00194 template<typename Self, typename Series, typename SeriesT, typename LabelT>
00195 class AutoKind<labels_are_couples, Self, Series, SeriesT, LabelT>
00196 {
00197 protected:
00198 typedef typename Self::hstate_t hstate_t;
00199 typedef typename Self::htransition_t htransition_t;
00200 typedef Element<Series, SeriesT> series_set_elt_t;
00201 typedef typename Series::monoid_t monoid_t;
00202 typedef typename series_set_elt_t::monoid_elt_t monoid_elt_t;
00203 typedef typename Series::semiring_t semiring_t;
00204 typedef typename series_set_elt_t::semiring_elt_t semiring_elt_t;
00205
00206 public:
00207
00208 series_set_elt_t series_of(htransition_t e) const;
00209
00210 const SeriesT series_value_of(htransition_t e) const;
00211
00212 bool is_spontaneous(htransition_t e) const;
00213
00214 template<typename L>
00215 L letter_of(SELECTOR(L), htransition_t e) const;
00216
00217 monoid_elt_t word_of(htransition_t e) const;
00218
00219 const typename monoid_elt_t::value_t& word_value_of(htransition_t e) const;
00220
00221 template<typename S>
00222 htransition_t add_series_transition(hstate_t from, hstate_t to,
00223 const S& e);
00224
00225 htransition_t add_spontaneous(hstate_t from, hstate_t to);
00226
00227 template<typename L>
00228 htransition_t add_letter_transition(hstate_t from, hstate_t to,
00229 const L& l);
00230
00231 template <typename OutputIterator, typename L>
00232 void letter_delta(OutputIterator res,
00233 hstate_t from,
00234 const L& l,
00235 delta_kind::transitions k = delta_kind::transitions()) const;
00236
00237 template <typename Container, typename L>
00238 void letter_deltac(Container& dst,
00239 hstate_t from,
00240 const L& l,
00241 delta_kind::transitions k = delta_kind::transitions()) const;
00242
00243 template <typename OutputIterator, typename L>
00244 void letter_rdelta(OutputIterator res,
00245 hstate_t from,
00246 const L& l,
00247 delta_kind::transitions k = delta_kind::transitions()) const;
00248
00249 template <typename Container, typename L>
00250 void letter_rdeltac(Container& dst,
00251 hstate_t from,
00252 const L& l,
00253 delta_kind::transitions k = delta_kind::transitions()) const;
00254
00255 template <typename OutputIterator, typename L>
00256 void letter_delta(OutputIterator res,
00257 hstate_t from,
00258 const L& l,
00259 delta_kind::states k) const;
00260
00261 template <typename Container, typename L>
00262 void letter_deltac(Container& dst,
00263 hstate_t from,
00264 const L& l,
00265 delta_kind::states k) const;
00266
00267 template <typename OutputIterator, typename L>
00268 void letter_rdelta(OutputIterator res,
00269 hstate_t from,
00270 const L& l,
00271 delta_kind::states k) const;
00272
00273 template <typename Container, typename L>
00274 void letter_rdeltac(Container& dst,
00275 hstate_t from,
00276 const L& l,
00277 delta_kind::states k) const;
00278
00279 protected:
00280 Self& auto_self();
00281 const Self& auto_self() const;
00282 };
00283
00284 }
00285
00286
00287 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
00288 # include <vaucanson/automata/concept/kinds.hxx>
00289 #endif // VCSN_USE_INTERFACE_ONLY
00290
00291
00292 #endif // ! VCSN_AUTOMATA_CONCEPT_KINDS_HH