Vaucanson  1.4.1
automata.hh
1 // automata.hh: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2008 The Vaucanson Group.
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
11 //
12 // The complete GNU General Public Licence Notice can be found as the
13 // `COPYING' file in the root directory.
14 //
15 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
16 //
17 #ifndef VCSN_AUTOMATA_CONCEPT_AUTOMATA_HH
18 # define VCSN_AUTOMATA_CONCEPT_AUTOMATA_HH
19 
20 # include <vaucanson/automata/concept/automata_base.hh>
22 
23 namespace vcsn
24 {
25 
26  template <typename Series, typename Kind>
27  // FIXME: Rename to AutomatonSet (see Trac #3)
28  struct Automata;
29 
31  template <typename Series, typename Kind>
32  struct dynamic_traits<Automata<Series, Kind> >
33  : dynamic_traits<AutomataBase<Automata<Series, Kind> > >
34  {
35  static const bool ret = dynamic_traits<Series>::ret;
36  };
37 
39  template <typename Series, typename Kind, typename T>
40  struct MetaElement<Automata<Series, Kind>, T>
41  : MetaElement<AutomataBase<Automata<Series, Kind> >, T>
42  {};
43 
45  template <typename Series, typename Kind>
46  struct virtual_types<Automata<Series, Kind> >
47  : virtual_types<AutomataBase<Automata<Series, Kind> > >
48  {
49  typedef Series series_set_t;
50  typedef Kind kind_t;
51  };
52 
53 
55  template <typename Series, typename Kind>
56  class Automata
57  : public AutomataBase<Automata<Series, Kind> >,
58  private SetSlot<Series>
59  {
60  public:
62  typedef Series series_set_t;
63  typedef Kind kind_t;
64 
65  Automata(const series_set_t&);
66 
67  const series_set_t& series() const;
68  };
69 
70  template <typename S, typename K, typename T>
71  struct projection_traits<Automata<S, K>, T>
72  {
73  typedef Automata<S, K> structure_t;
74  typedef T impl_t;
75 
76  typedef Element<structure_t, impl_t> automaton_t;
77 
78  typedef typename automaton_t::series_set_elt_t series_set_elt_t;
79 
80  typedef typename structure_t::series_set_t series_set_t;
81 
82  typedef typename structure_t::series_set_t::semiring_t semiring_t;
83 
84  typedef typename structure_t::series_set_t::monoid_t monoid_t;
85 
86  typedef typename impl_t::monoid_elt_value_t monoid_elt_value_t;
87 
88  typedef typename monoid_t::alphabet_t alphabet_t;
89 
90  typedef typename algebra::alphabet_traits<typename alphabet_t::set_t,
91  typename alphabet_t::value_t>
92  alphabet_traits_t;
93 
95  word_traits_t;
96 
97  typedef typename word_traits_t::first_monoid_t first_monoid_t;
98 
99  typedef typename word_traits_t::second_monoid_t second_monoid_t;
100 
101  typedef typename algebra::mute_series_traits<series_set_t,
102  semiring_t,
103  first_monoid_t>::ret
104  first_series_t;
105 
106  typedef typename algebra::mute_series_traits<series_set_t,
107  semiring_t,
108  second_monoid_t>::ret
109  second_series_t;
110 
111  typedef typename mute_graph_impl_traits<impl_t, word_traits_t>::
112  first_projection_t first_impl_t;
113 
114  typedef typename mute_graph_impl_traits<impl_t, word_traits_t>::
115  second_projection_t second_impl_t;
116 
117  typedef Element<Automata<first_series_t, K>, first_impl_t>
118  first_projection_t;
119 
120  typedef Element<Automata<second_series_t, K>, second_impl_t>
121  second_projection_t;
122 
123  // These are only "makers". Ie they will not contruct the projection.
124  // See the relevant algorithms.
125  static first_projection_t first_projection(const automaton_t&);
126  static second_projection_t second_projection(const automaton_t&);
127 
128  typedef automaton_traits<first_impl_t> first_series_traits_t;
129 
130  typedef automaton_traits<second_impl_t> second_series_traits_t;
131 
132  typedef Element<first_series_t,
133  typename first_series_traits_t::series_set_elt_value_t>
134  series_first_projection_t;
135 
136  typedef Element<second_series_t,
137  typename second_series_traits_t::series_set_elt_value_t>
138  series_second_projection_t;
139 
140  // FIXME: As for now we limit series projection here. In the future,
141  // we will move it in series_traits.
142  static series_first_projection_t
143  series_first_projection(const first_series_t&,
144  const series_set_elt_t&);
145  static series_second_projection_t
146  series_second_projection(const second_series_t&,
147  const series_set_elt_t&);
148  };
149 
150 // Some usefull types to manipulate pair letters automaton.
151 # define AUTOMATON_PROJECTION_TYPES() \
152  typedef algebra::alphabet_traits<alphabet_t::set_t, \
153  alphabet_t::value_t> alphabet_traits_t; \
154  typedef alphabet_traits_t::first_projection_t \
155  first_projection_alphabet_t; \
156  typedef alphabet_traits_t::second_projection_t \
157  second_projection_alphabet_t; \
158  \
159  typedef algebra::word_traits<monoid_elt_t::set_t, \
160  monoid_elt_t::value_t> word_traits_t; \
161  typedef word_traits_t::first_monoid_t first_monoid_t; \
162  typedef word_traits_t::second_monoid_t second_monoid_t; \
163  typedef word_traits_t::first_projection_t first_projection_word_t; \
164  typedef word_traits_t::second_projection_t second_projection_word_t; \
165  \
166  typedef projection_traits<automata_set_t, automaton_impl_t> \
167  projection_traits_t; \
168  typedef projection_traits_t::first_projection_t \
169  first_projection_automaton_t; \
170  typedef projection_traits_t::second_projection_t \
171  second_projection_automaton_t
172 
173  template <typename Series, typename Kind>
174  bool
175  operator==(const Automata<Series, Kind>&, const Automata<Series, Kind>&);
176 
177 } // ! vcsn
178 
179 
180 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
181 # include <vaucanson/automata/concept/automata.hxx>
182 # endif // VCSN_USE_INTERFACE_ONLY
183 
184 
185 #endif // ! VCSN_AUTOMATA_CONCEPT_AUTOMATA_HH