00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef VCSN_AUTOMATA_IMPLEMENTATION_KIND_ADAPTER_HH
00018 # define VCSN_AUTOMATA_IMPLEMENTATION_KIND_ADAPTER_HH
00019
00020 # include <vaucanson/automata/concept/automata_kind.hh>
00021
00022 namespace vcsn {
00023
00026
00027 #define ADAPT_ADD_LETTER_TRANSITION_TO_SERIES_LABEL(T...) \
00028 htransition_t \
00029 op_add_letter_transition(const AutomataBase<S>& s, \
00030 T& v, \
00031 hstate_t from, \
00032 hstate_t to, \
00033 const typename Element<S, T >::letter_t & l) \
00034 { \
00035 typedef typename S::series_set_t series_set_t; \
00036 typedef typename series_set_t::monoid_t monoid_t; \
00037 typedef typename series_set_t::semiring_t semiring_t; \
00038 typedef typename Element<S, T >::monoid_elt_value_t \
00039 monoid_elt_value_t; \
00040 typedef typename Element<S, T >::semiring_elt_value_t \
00041 semiring_elt_value_t; \
00042 typedef typename Element<S, T >::series_set_elt_value_t \
00043 series_set_elt_value_t; \
00044 \
00045 Element<series_set_t, series_set_elt_value_t> label (s.series()); \
00046 \
00047 Element<monoid_t, monoid_elt_value_t> word (s.series().monoid(), l); \
00048 label.assoc(word, \
00049 s.series().semiring().identity(SELECT(semiring_elt_value_t))); \
00050 \
00051 return op_add_transition(s, v, from, to, label.value()); \
00052 }
00053
00054 #define ADAPT_LETTER_OF_TO_SERIES_LABEL(T...) \
00055 typename Element<AutomataBase<S>, T >::letter_t \
00056 op_letter_of(const AutomataBase<S>& s, \
00057 const T& v, \
00058 htransition_t e) \
00059 { \
00060 typedef typename S::series_set_t series_set_t; \
00061 typedef typename series_set_t::monoid_t monoid_t; \
00062 typedef typename Element<S, T >::monoid_elt_value_t \
00063 word_value_t; \
00064 typedef typename Element<S, T >::series_set_elt_value_t \
00065 series_set_elt_value_t; \
00066 \
00067 Element<series_set_t, series_set_elt_value_t> sl = op_series_of(s, v, e); \
00068 precondition(sl.supp().size() == 1); \
00069 Element<monoid_t, word_value_t> w = sl.choose_from_supp(); \
00070 precondition(w.length() == 1); \
00071 return *w.begin(); \
00072 }
00073
00074 #define ADAPT_WORD_OF_TO_SERIES_LABEL(T...) \
00075 typename Element<AutomataBase<S>, T >::monoid_elt_t \
00076 op_word_of(const AutomataBase<S>& s, \
00077 const T& v, \
00078 htransition_t e) \
00079 { \
00080 typedef typename S::series_set_t series_set_t; \
00081 typedef typename series_set_t::monoid_t monoid_t; \
00082 typedef typename Element<S, T >::monoid_elt_value_t \
00083 word_value_t; \
00084 typedef typename Element<S, T >::series_set_elt_value_t \
00085 series_set_elt_value_t; \
00086 \
00087 Element<series_set_t, series_set_elt_value_t> sl = op_series_of(s, v, e); \
00088 precondition(sl.supp().size() == 1); \
00089 Element<monoid_t, word_value_t> w = sl.choose_from_supp(); \
00090 return w; \
00091 }
00092
00093 #define ADAPT_ADD_SERIE_TRANSITION_TO_LETTERS_LABEL(T...) \
00094 htransition_t \
00095 op_add_series_transition(const AutomataBase<S>& a_set, \
00096 T& v, \
00097 hstate_t from, \
00098 hstate_t to, \
00099 const typename Element<S,T >::series_set_elt_t& s) \
00100 { \
00101 assertion(s.supp().size() == 1); \
00102 return op_add_letter_transition(a_set, v, from, to, *s.supp().begin()); \
00103 }
00104
00105 #define ADAPT_WORD_OF_TO_LETTERS_LABEL(T...) \
00106 typename Element<AutomataBase<S>, T >::monoid_elt_t \
00107 op_word_of(const AutomataBase<S>& a_set, \
00108 const T& v, \
00109 htransition_t e) \
00110 { \
00111 typedef T value_t; \
00112 typedef typename S::series_set_t series_set_t; \
00113 typedef typename series_set_t::monoid_t monoid_t; \
00114 typedef typename Element<S, value_t>::monoid_elt_value_t \
00115 word_value_t; \
00116 Element<monoid_t, word_value_t> \
00117 w(a_set.series().monoid()); \
00118 w += op_letter_of(a_set, v, e); \
00119 return w; \
00120 }
00121
00122 #define ADAPT_SERIE_OF_TO_LETTERS_LABEL(T...) \
00123 typename Element<AutomataBase<S>, T >::series_set_elt_t \
00124 op_series_of(const AutomataBase<S>& a_set, \
00125 const T& v, \
00126 htransition_t e) \
00127 { \
00128 typedef T value_t; \
00129 \
00130 typedef typename S::series_set_t series_set_t; \
00131 typedef typename series_set_t::monoid_t monoid_t; \
00132 typedef typename Element<S, value_t>::monoid_elt_value_t \
00133 word_value_t; \
00134 typedef typename Element<S, value_t>::semiring_elt_value_t \
00135 semiring_elt_value_t; \
00136 typedef typename Element<S, value_t>::series_set_elt_value_t \
00137 series_set_elt_value_t; \
00138 Element<monoid_t, word_value_t> w(a_set.series().monoid()); \
00139 w = op_letter_of(a_set, v, e); \
00140 Element<series_set_t, series_set_elt_value_t> s(a_set.series()); \
00141 s.assoc(w, algebra::identity_as<semiring_elt_value_t> \
00142 ::of(a_set.series().semiring())); \
00143 return s; \
00144 }
00145
00146 }
00147
00148 # ifndef VCSN_USE_INTERFACE_ONLY
00149 # include <vaucanson/automata/implementation/kind_adapter.hxx>
00150 # endif // VCSN_USE_INTERFACE_ONLY
00151
00152 #endif // ! VCSN_AUTOMATA_IMPLEMENTATION_KIND_ADAPTER_HH