Vaucanson 1.4
|
00001 // kind_adapter.hh: this file is part of the Vaucanson project. 00002 // 00003 // Vaucanson, a generic library for finite state machines. 00004 // 00005 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 The Vaucanson Group. 00006 // 00007 // This program is free software; you can redistribute it and/or 00008 // modify it under the terms of the GNU General Public License 00009 // as published by the Free Software Foundation; either version 2 00010 // of the License, or (at your option) any later version. 00011 // 00012 // The complete GNU General Public Licence Notice can be found as the 00013 // `COPYING' file in the root directory. 00014 // 00015 // The Vaucanson Group consists of people listed in the `AUTHORS' file. 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 typename automaton_traits<T>::htransition_t \ 00029 op_add_letter_transition(const AutomataBase<S>& s, \ 00030 T& v, \ 00031 const typename automaton_traits<T>::hstate_t& from,\ 00032 const typename automaton_traits<T>::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 const typename automaton_traits<T>::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 const typename automaton_traits<T>::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 00095 #define ADAPT_ADD_SERIE_TRANSITION_TO_LETTERS_LABEL(T...) \ 00096 typename automaton_traits<T>::htransition_t \ 00097 op_add_series_transition(const AutomataBase<S>& a_set, \ 00098 T& v, \ 00099 const typename automaton_traits<T>::hstate_t& from,\ 00100 const typename automaton_traits<T>::hstate_t& to, \ 00101 const typename Element<S,T>::series_set_elt_t& s) \ 00102 { \ 00103 assertion(s.supp().size() == 1); \ 00104 typedef typename Element<S, T>::series_set_elt_t::value_t::monoid_elt_value_t\ 00105 monoid_elt_value_t; \ 00106 typename automaton_traits<T>::htransition_t res; \ 00107 monoid_elt_value_t supp = *s.supp().begin(); \ 00108 for (typename monoid_elt_value_t::const_iterator it = supp.begin(); \ 00109 it != supp.end(); ++it) \ 00110 res = op_add_letter_transition(a_set, v, from, to, *it); \ 00111 return res; \ 00112 } 00113 00114 #define ADAPT_WORD_OF_TO_LETTERS_LABEL(T...) \ 00115 typename Element<AutomataBase<S>, T >::monoid_elt_t \ 00116 op_word_of(const AutomataBase<S>& a_set, \ 00117 const T& v, \ 00118 const typename automaton_traits<T>::htransition_t& e)\ 00119 { \ 00120 typedef T value_t; \ 00121 typedef typename S::series_set_t series_set_t; \ 00122 typedef typename series_set_t::monoid_t monoid_t; \ 00123 typedef typename Element<S, value_t>::monoid_elt_value_t \ 00124 word_value_t; \ 00125 Element<monoid_t, word_value_t> \ 00126 w(a_set.series().monoid()); \ 00127 w += op_letter_of(a_set, v, e); \ 00128 return w; \ 00129 } 00130 00131 #define ADAPT_SERIE_OF_TO_LETTERS_LABEL(T...) \ 00132 typename Element<AutomataBase<S>, T >::series_set_elt_t \ 00133 op_series_of(const AutomataBase<S>& a_set, \ 00134 const T& v, \ 00135 const typename automaton_traits<T>::htransition_t& e) \ 00136 { \ 00137 typedef T value_t; \ 00138 \ 00139 typedef typename S::series_set_t series_set_t; \ 00140 typedef typename series_set_t::monoid_t monoid_t; \ 00141 typedef typename Element<S, value_t>::monoid_elt_value_t \ 00142 word_value_t; \ 00143 typedef typename Element<S, value_t>::semiring_elt_value_t \ 00144 semiring_elt_value_t; \ 00145 typedef typename Element<S, value_t>::series_set_elt_value_t \ 00146 series_set_elt_value_t; \ 00147 Element<monoid_t, word_value_t> w(a_set.series().monoid()); \ 00148 w = op_letter_of(a_set, v, e); \ 00149 Element<series_set_t, series_set_elt_value_t> s(a_set.series()); \ 00150 s.assoc(w, algebra::identity_as<semiring_elt_value_t> \ 00151 ::of(a_set.series().semiring())); \ 00152 return s; \ 00153 } 00154 00155 } // vcsn 00156 00157 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB 00158 # include <vaucanson/automata/implementation/kind_adapter.hxx> 00159 # endif // VCSN_USE_INTERFACE_ONLY 00160 00161 #endif // ! VCSN_AUTOMATA_IMPLEMENTATION_KIND_ADAPTER_HH