00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef VCSN_AUTOMATA_CONCEPT_KINDS_HXX
00018 # define VCSN_AUTOMATA_CONCEPT_KINDS_HXX
00019
00020 # include <iterator>
00021 # include <algorithm>
00022
00023 # include <vaucanson/misc/contract.hh>
00024 # include <vaucanson/misc/container_ops.hh>
00025 # include <vaucanson/automata/concept/handlers.hh>
00026
00027 namespace vcsn {
00028
00029 template<typename Series,
00030 typename MonoidElt,
00031 typename SemiringElt,
00032 typename L>
00033 ls_delta_letter_query<Series, MonoidElt, SemiringElt, L>::
00034 ls_delta_letter_query(const Series& s, const L& l)
00035 : s_(s),
00036 l_(op_convert(SELECT(typename MonoidElt::set_t),
00037 SELECT(typename MonoidElt::value_t),
00038 l))
00039 {}
00040
00041 template<typename Series,
00042 typename MonoidElt,
00043 typename SemiringElt,
00044 typename L>
00045 template<typename Label>
00046 bool ls_delta_letter_query<Series, MonoidElt, SemiringElt, L>::
00047 operator()(const Label& label) const
00048 {
00049 return (op_series_get(s_.get(), label, l_)
00050 != zero_value(SELECT(typename SemiringElt::set_t),
00051 SELECT(typename SemiringElt::value_t)));
00052 }
00053
00054
00055
00056 template<typename Self, typename Series, typename SeriesT, typename LabelT>
00057 Element<Series, SeriesT>
00058 AutoKind<labels_are_series, Self, Series, SeriesT, LabelT>::
00059 series_of(htransition_t e) const
00060 {
00061 return series_set_elt_t(auto_self().series(),
00062 auto_self().label_of(e));
00063 }
00064
00065 template<typename Self, typename Series, typename SeriesT, typename LabelT>
00066 const SeriesT&
00067 AutoKind<labels_are_series, Self, Series, SeriesT, LabelT>::
00068 series_value_of(htransition_t e) const
00069 {
00070 return auto_self().label_of(e);
00071 }
00072
00073 template<typename Self, typename Series, typename SeriesT, typename LabelT>
00074 bool
00075 AutoKind<labels_are_series, Self, Series, SeriesT, LabelT>::
00076 is_spontaneous(htransition_t e) const
00077 {
00078 const series_set_elt_t& s = auto_self().label_of(e);
00079
00080 return s == algebra::identity_as<SeriesT>::of(s.set());
00081 }
00082
00083 template<typename Self, typename Series, typename SeriesT, typename LabelT>
00084 template<typename L>
00085 L
00086 AutoKind<labels_are_series, Self, Series, SeriesT, LabelT>::
00087 letter_of(SELECTOR(L), htransition_t e) const
00088 {
00089 return *op_begin(auto_self().series().monoid(),
00090 auto_self().label_of(e).begin()->first);
00091 }
00092
00093 template<typename Self, typename Series, typename SeriesT, typename LabelT>
00094 typename Element<Series, SeriesT>::monoid_elt_t
00095 AutoKind<labels_are_series, Self, Series, SeriesT, LabelT>::
00096 word_of(htransition_t e) const
00097 {
00098 const LabelT& l = auto_self().label_of(e);
00099
00100 return monoid_elt_t(auto_self().series().monoid(),
00101 l.begin()->first);
00102 }
00103
00104 template<typename Self, typename Series, typename SeriesT, typename LabelT>
00105 const typename Element<Series, SeriesT>::monoid_elt_t::value_t&
00106 AutoKind<labels_are_series, Self, Series, SeriesT, LabelT>::
00107 word_value_of(htransition_t e) const
00108 {
00109 return auto_self().label_of(e).begin()->first;
00110 }
00111
00112 template<typename Self, typename Series, typename SeriesT, typename LabelT>
00113 template<typename S>
00114 typename Self::htransition_t
00115 AutoKind<labels_are_series, Self, Series, SeriesT, LabelT>::
00116 add_series_transition(hstate_t from, hstate_t to,
00117 const S& e)
00118 {
00119 return auto_self().add_transition(from, to, e.value());
00120 }
00121
00122 template<typename Self, typename Series, typename SeriesT, typename LabelT>
00123 typename Self::htransition_t
00124 AutoKind<labels_are_series, Self, Series, SeriesT, LabelT>::
00125 add_spontaneous(hstate_t from, hstate_t to)
00126 {
00127 return auto_self().add_transition(from, to,
00128 identity_value(SELECT(Series),
00129 SELECT(SeriesT)));
00130 }
00131
00132 template<typename Self, typename Series, typename SeriesT, typename LabelT>
00133 template<typename L>
00134 typename Self::htransition_t
00135 AutoKind<labels_are_series, Self, Series, SeriesT, LabelT>::
00136 add_letter_transition(hstate_t from, hstate_t to,
00137 const L& l)
00138 {
00139 return auto_self().add_transition(from, to,
00140 series_set_elt_t(auto_self().series(),
00141 monoid_elt_t(auto_self().series().monoid(),
00142 l)
00143 ).value()
00144 );
00145 }
00146
00147 template<typename Self, typename Series, typename SeriesT, typename LabelT>
00148 Self&
00149 AutoKind<labels_are_series, Self, Series, SeriesT, LabelT>::
00150 auto_self()
00151 { return static_cast<Self&>(*this); }
00152
00153 template<typename Self, typename Series, typename SeriesT, typename LabelT>
00154 const Self&
00155 AutoKind<labels_are_series, Self, Series, SeriesT, LabelT>::
00156 auto_self() const
00157 { return static_cast<const Self&>(*this); }
00158
00159 }
00160
00161 #endif // ! VCSN_AUTOMATA_CONCEPT_KINDS_HXX