Vaucanson  1.4.1
gen_book.hxx
1 // gen_book.hxx: 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, 2006 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_TOOLS_GEN_BOOK_HXX
18 # define VCSN_TOOLS_GEN_BOOK_HXX
19 
20 # include <vaucanson/tools/gen_book.hh>
21 # include <vaucanson/misc/usual_macros.hh>
22 # include <vaucanson/automata/concept/handlers.hh>
23 namespace vcsn {
24 
25  namespace tools {
26 
27  template <class Auto_>
28  Auto_ lombardy(unsigned size)
29  {
30  AUTOMATON_TYPES(Auto_);
31  AUTOMATON_FREEMONOID_TYPES(Auto_);
32  // FIXME:add assert "we want automaton on char."
33  alphabets_elt_t alpha;
34  alpha.insert('a');
35  alpha.insert('b');
36  monoid_t monoid (alpha);
37  semiring_t semiring;
38  series_set_t series (semiring, monoid);
39  automaton_t automaton;
40  automaton.create();
41  automaton.series() = series;
42  hstate_t initial = automaton.add_state();
43  hstate_t c = initial;
44 
45  for (unsigned i = 0; i < size; ++i)
46  {
47  hstate_t next = automaton.add_state();
48  automaton.add_letter_transition(c, c, 'a');
49  automaton.add_letter_transition(c, next, 'b');
50  automaton.set_initial(c);
51  c = next;
52  }
53  automaton.set_final(c);
54  automaton.set_initial(c);
55  automaton.add_letter_transition(c, initial, 'a');
56  return automaton;
57  }
58 
59  } // tools
60 
61 } // vcsn
62 
63 #endif // ! VCSN_TOOLS_GEN_BOOK_HXX