00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef VCSN_AUTOMATA_CONCEPT_AUTOMATA_HXX
00018 # define VCSN_AUTOMATA_CONCEPT_AUTOMATA_HXX
00019
00020 #include <vaucanson/automata/concept/automata_base.hh>
00021 #include <vaucanson/misc/unique.hh>
00022
00023 namespace vcsn {
00024
00025 template <typename Series, typename Kind>
00026 Automata<Series, Kind>::Automata(const series_set_t& s):
00027 SetSlot<Series>(s)
00028 {}
00029
00030 template <typename Series, typename Kind>
00031 const Series&
00032 Automata<Series, Kind>::series() const
00033 {
00034 return this->_structure_get();
00035 }
00036
00037 template <typename Series, typename Kind>
00038 bool
00039 operator==(const Automata<Series, Kind>& lhs,
00040 const Automata<Series, Kind>& rhs)
00041 {
00042 return & lhs.series() == & rhs.series();
00043 }
00044
00045 # define PROJECTION_TRAITS \
00046 projection_traits<Automata<S, K>, T>
00047
00048 template <typename S, typename K, typename T>
00049 inline typename PROJECTION_TRAITS::first_projection_t
00050 PROJECTION_TRAITS::
00051 first_projection(const PROJECTION_TRAITS::automaton_t& aut)
00052 {
00053
00054 static_assertion_(not (misc::static_eq<first_projection_t,
00055 undefined_type>::value), need_first_projection);
00056
00057 semiring_t semiring = aut.series().semiring();
00058 alphabet_t A = aut.series().monoid().alphabet();
00059
00060
00061 typename alphabet_traits_t::first_projection_t B =
00062 alphabet_traits_t::first_projection(A);
00063
00064
00065 typename word_traits_t::first_monoid_t freemonoid(B);
00066
00067
00068 typename first_projection_t::series_set_t series(semiring, freemonoid);
00069
00070
00071 typename first_projection_t::set_t set_t(series);
00072
00073 return first_projection_t(set_t);
00074 }
00075
00076 template <typename S, typename K, typename T>
00077 inline typename PROJECTION_TRAITS::second_projection_t
00078 PROJECTION_TRAITS::
00079 second_projection(const PROJECTION_TRAITS::automaton_t& aut)
00080 {
00081
00082 static_assertion_(not (misc::static_eq<second_projection_t,
00083 undefined_type>::value), need_second_projection);
00084
00085 semiring_t semiring = aut.series().semiring();
00086 alphabet_t A = aut.series().monoid().alphabet();
00087
00088
00089 typename alphabet_traits_t::second_projection_t B =
00090 alphabet_traits_t::second_projection(A);
00091
00092
00093 typename word_traits_t::second_monoid_t freemonoid(B);
00094
00095
00096 typename second_projection_t::series_set_t series(semiring, freemonoid);
00097
00098
00099 typename second_projection_t::set_t set_t(series);
00100
00101 return second_projection_t(set_t);
00102 }
00103
00104 template <typename S, typename K, typename T>
00105 inline typename PROJECTION_TRAITS::series_first_projection_t
00106 PROJECTION_TRAITS::
00107 series_first_projection(const PROJECTION_TRAITS::first_series_t& series,
00108 const PROJECTION_TRAITS::series_set_elt_t& ss)
00109 {
00110
00111 static_assertion_(not (misc::static_eq<first_projection_t,
00112 undefined_type>::value), need_first_projection);
00113
00114 series_first_projection_t ret(series);
00115
00116 for_all_const_(series_set_elt_t::support_t, s, ss.supp())
00117 ret.assoc(word_traits_t::first_projection(*s),
00118 ss.get(*s));
00119
00120 return ret;
00121 }
00122
00123 template <typename S, typename K, typename T>
00124 inline typename PROJECTION_TRAITS::series_second_projection_t
00125 PROJECTION_TRAITS::
00126 series_second_projection(const PROJECTION_TRAITS::second_series_t& series,
00127 const PROJECTION_TRAITS::series_set_elt_t& ss)
00128 {
00129
00130 static_assertion_(not (misc::static_eq<second_projection_t,
00131 undefined_type>::value), need_second_projection);
00132
00133 series_second_projection_t ret(series);
00134
00135 for_all_const_(series_set_elt_t::support_t, s, ss.supp())
00136 ret.assoc(word_traits_t::second_projection(*s),
00137 ss.get(*s));
00138
00139 return ret;
00140 }
00141
00142 # undef PROJECTION_TRAITS
00143
00144 }
00145
00146 #endif // ! VCSN_AUTOMATA_CONCEPT_AUTOMATA_HXX