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 Element<Series, SeriesT> series_set_elt_t;
00092 typedef typename Series::monoid_t monoid_t;
00093 typedef typename series_set_elt_t::monoid_elt_t monoid_elt_t;
00094 typedef typename Series::semiring_t semiring_t;
00095 typedef typename series_set_elt_t::semiring_elt_t semiring_elt_t;
00096
00097 public:
00098
00099 series_set_elt_t series_of(htransition_t e) const;
00100
00101 const SeriesT& series_value_of(htransition_t e) const;
00102
00103 bool is_spontaneous(htransition_t e) const;
00104
00105 template<typename L>
00106 L letter_of(SELECTOR(L), htransition_t e) const;
00107
00108 monoid_elt_t word_of(htransition_t e) const;
00109
00110 const typename monoid_elt_t::value_t& word_value_of(htransition_t e) const;
00111
00112 template<typename S>
00113 htransition_t add_series_transition(hstate_t from, hstate_t to,
00114 const S& e);
00115
00116 htransition_t add_spontaneous(hstate_t from, hstate_t to);
00117
00118 template<typename L>
00119 htransition_t add_letter_transition(hstate_t from, hstate_t to,
00120 const L& l);
00121
00122 template <typename OutputIterator, typename L>
00123 void letter_delta(OutputIterator res,
00124 hstate_t from,
00125 const L& l,
00126 delta_kind::transitions k = delta_kind::transitions()) const;
00127
00128 template <typename Container, typename L>
00129 void letter_deltac(Container& dst,
00130 hstate_t from,
00131 const L& l,
00132 delta_kind::transitions k = delta_kind::transitions()) const;
00133
00134 template <typename OutputIterator, typename L>
00135 void letter_rdelta(OutputIterator res,
00136 hstate_t from,
00137 const L& l,
00138 delta_kind::transitions k = delta_kind::transitions()) const;
00139
00140 template <typename Container, typename L>
00141 void letter_rdeltac(Container& dst,
00142 hstate_t from,
00143 const L& l,
00144 delta_kind::transitions k = delta_kind::transitions()) const;
00145
00146 template <typename OutputIterator, typename L>
00147 void letter_delta(OutputIterator res,
00148 hstate_t from,
00149 const L& l,
00150 delta_kind::states k) const;
00151
00152 template <typename Container, typename L>
00153 void letter_deltac(Container& dst,
00154 hstate_t from,
00155 const L& l,
00156 delta_kind::states k) const;
00157
00158 template <typename OutputIterator, typename L>
00159 void letter_rdelta(OutputIterator res,
00160 hstate_t from,
00161 const L& l,
00162 delta_kind::states k) const;
00163
00164 template <typename Container, typename L>
00165 void letter_rdeltac(Container& dst,
00166 hstate_t from,
00167 const L& l,
00168 delta_kind::states k) const;
00169
00170 protected:
00171 Self& auto_self();
00172 const Self& auto_self() const;
00173 };
00174
00175
00176 struct labels_are_couples
00177 {};
00178
00179 template<typename Monoid, typename L>
00180 struct lc_delta_letter_query
00181 {
00182 lc_delta_letter_query(const Monoid& m, const L& l);
00183
00184 template<typename Label>
00185 bool operator()(const Label& label) const;
00186
00187 protected:
00188 SetSlot<Monoid> m_;
00189 L l_;
00190 };
00191
00192 template<typename Self, typename Series, typename SeriesT, typename LabelT>
00193 class AutoKind<labels_are_couples, Self, Series, SeriesT, LabelT>
00194 {
00195 protected:
00196 typedef Element<Series, SeriesT> series_set_elt_t;
00197 typedef typename Series::monoid_t monoid_t;
00198 typedef typename series_set_elt_t::monoid_elt_t monoid_elt_t;
00199 typedef typename Series::semiring_t semiring_t;
00200 typedef typename series_set_elt_t::semiring_elt_t semiring_elt_t;
00201
00202 public:
00203
00204 series_set_elt_t series_of(htransition_t e) const;
00205
00206 const SeriesT series_value_of(htransition_t e) const;
00207
00208 bool is_spontaneous(htransition_t e) const;
00209
00210 template<typename L>
00211 L letter_of(SELECTOR(L), htransition_t e) const;
00212
00213 monoid_elt_t word_of(htransition_t e) const;
00214
00215 const typename monoid_elt_t::value_t& word_value_of(htransition_t e) const;
00216
00217 template<typename S>
00218 htransition_t add_series_transition(hstate_t from, hstate_t to,
00219 const S& e);
00220
00221 htransition_t add_spontaneous(hstate_t from, hstate_t to);
00222
00223 template<typename L>
00224 htransition_t add_letter_transition(hstate_t from, hstate_t to,
00225 const L& l);
00226
00227 template <typename OutputIterator, typename L>
00228 void letter_delta(OutputIterator res,
00229 hstate_t from,
00230 const L& l,
00231 delta_kind::transitions k = delta_kind::transitions()) const;
00232
00233 template <typename Container, typename L>
00234 void letter_deltac(Container& dst,
00235 hstate_t from,
00236 const L& l,
00237 delta_kind::transitions k = delta_kind::transitions()) const;
00238
00239 template <typename OutputIterator, typename L>
00240 void letter_rdelta(OutputIterator res,
00241 hstate_t from,
00242 const L& l,
00243 delta_kind::transitions k = delta_kind::transitions()) const;
00244
00245 template <typename Container, typename L>
00246 void letter_rdeltac(Container& dst,
00247 hstate_t from,
00248 const L& l,
00249 delta_kind::transitions k = delta_kind::transitions()) const;
00250
00251 template <typename OutputIterator, typename L>
00252 void letter_delta(OutputIterator res,
00253 hstate_t from,
00254 const L& l,
00255 delta_kind::states k) const;
00256
00257 template <typename Container, typename L>
00258 void letter_deltac(Container& dst,
00259 hstate_t from,
00260 const L& l,
00261 delta_kind::states k) const;
00262
00263 template <typename OutputIterator, typename L>
00264 void letter_rdelta(OutputIterator res,
00265 hstate_t from,
00266 const L& l,
00267 delta_kind::states k) const;
00268
00269 template <typename Container, typename L>
00270 void letter_rdeltac(Container& dst,
00271 hstate_t from,
00272 const L& l,
00273 delta_kind::states k) const;
00274
00275 protected:
00276 Self& auto_self();
00277 const Self& auto_self() const;
00278 };
00279
00280 }
00281
00282
00283 #ifndef VCSN_USE_INTERFACE_ONLY
00284 # include <vaucanson/automata/concept/kinds.hxx>
00285 #endif // VCSN_USE_INTERFACE_ONLY
00286
00287
00288 #endif // ! VCSN_AUTOMATA_CONCEPT_KINDS_HH