17 #ifndef VCSN_AUTOMATA_CONCEPT_TRANSDUCER_OPS_HXX
18 # define VCSN_AUTOMATA_CONCEPT_TRANSDUCER_OPS_HXX
20 # include <vaucanson/algebra/concept/monoid_base.hh>
24 #define AutoType(Type) \
25 typename Element<S, T>::Type
27 template <
class S,
class T>
28 typename Element<S, T>::input_monoid_elt_t
29 op_input_of(
const TransducerBase<S>& s,
31 typename automaton_traits<T>::htransition_t e)
36 template <
class S,
class T>
37 typename Element<S, T>::output_series_set_elt_t
38 op_output_of(
const TransducerBase<S>& s,
40 typename automaton_traits<T>::htransition_t e)
43 precondition(is.supp().size() == 1);
45 is.
get(AutoType(monoid_elt_t) (is.structure().monoid(),
49 template <class S, class T>
50 typename automaton_traits<T>::htransition_t
51 op_add_io_transition(const TransducerBase<S>& s,
53 typename automaton_traits<T>::hstate_t from,
54 typename automaton_traits<T>::hstate_t to,
55 AutoType(input_monoid_elt_t) input_w,
56 AutoType(output_monoid_elt_t) output_w,
57 AutoType(output_semiring_elt_t) w)
59 AutoType(output_series_set_elt_t) os(s.series().semiring());
60 os.assoc(output_w, w);
61 AutoType(series_set_elt_t) is(s.series());
62 is.assoc(input_w, os);
66 template <class S, class T>
67 typename automaton_traits<T>::htransition_t
68 op_add_i_transition(const TransducerBase<S>& s,
70 typename automaton_traits<T>::hstate_t from,
71 typename automaton_traits<T>::hstate_t to,
72 AutoType(input_letter_t) i,
73 AutoType(output_semiring_elt_t) w)
75 AutoType(input_monoid_elt_t) input_w(s.series().monoid(), i);
76 AutoType(output_monoid_elt_t) output_w(s.series().semiring().monoid());
77 AutoType(output_series_set_elt_t) os(s.series().semiring());
78 os.assoc(output_w, w);
79 AutoType(series_set_elt_t) is(s.series());
80 is.assoc(input_w, os);
84 template <class S, class T>
85 typename automaton_traits<T>::htransition_t
86 op_add_o_transition(const TransducerBase<S>& s,
88 typename automaton_traits<T>::hstate_t from,
89 typename automaton_traits<T>::hstate_t to,
90 AutoType(input_letter_t) o,
91 AutoType(output_semiring_elt_t) w)
93 AutoType(input_monoid_elt_t) input_w(s.series().monoid());
94 AutoType(output_monoid_elt_t) output_w(s.series().semiring().monoid(), o);
95 AutoType(output_series_set_elt_t) os(s.series().semiring());
96 os.assoc(output_w, w);
97 AutoType(series_set_elt_t) is(s.series());
98 is.assoc(input_w, os);
102 template <class S, class T>
103 AutoType(series_set_elt_t)
104 make_series(const TransducerBase<S>& s,
105 AutoType(output_monoid_elt_value_t) o)
107 AutoType(input_monoid_elt_t) empty =
108 algebra::identity_as<AutoType(input_monoid_elt_value_t)>::
109 of(s.series().monoid());
110 AutoType(output_semiring_elt_t) semi_id =
111 algebra::identity_as<AutoType(output_semiring_elt_value_t)>::
112 of(s.series().semiring().semiring());
114 AutoType(input_monoid_elt_t) input_w(s.series().monoid());
115 AutoType(output_series_set_elt_t) os (s.series().semiring());
117 Element<AutoType(output_monoid_t), AutoType(output_monoid_elt_value_t)>
118 o_elt (s.series().semiring().monoid(), o);
119 os.assoc(o_elt, semi_id);
120 AutoType(series_set_elt_t) is (s.series());
125 template <class S, class T>
127 op_set_o_final(const TransducerBase<S>& s,
129 typename automaton_traits<T>::hstate_t final,
130 AutoType(output_monoid_elt_value_t) o)
132 AutoType(series_set_elt_t) is = make_series<S, T>(s, o);
136 template <class S, class T>
138 op_set_o_initial(const TransducerBase<S>& s,
140 typename automaton_traits<T>::hstate_t initial,
141 AutoType(output_monoid_elt_value_t) o)
143 AutoType(series_set_elt_t) is = make_series<S, T>(s, o);
151 #endif // ! VCSN_AUTOMATA_CONCEPT_TRANSDUCER_OPS_HXX