gen_book.hxx

00001 // gen_book.hxx: 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_TOOLS_GEN_BOOK_HXX
00018 # define VCSN_TOOLS_GEN_BOOK_HXX
00019 
00020 # include <vaucanson/tools/gen_book.hh>
00021 # include <vaucanson/misc/usual_macros.hh>
00022 # include <vaucanson/automata/concept/handlers.hh>
00023 namespace vcsn {
00024 
00025   namespace tools {
00026 
00027     template <class Auto_>
00028     Auto_       lombardy(unsigned size)
00029     {
00030       AUTOMATON_TYPES(Auto_);
00031       AUTOMATON_FREEMONOID_TYPES(Auto_);
00032       // FIXME:add assert "we want automaton on char."
00033       alphabets_elt_t   alpha;
00034       alpha.insert('a');
00035       alpha.insert('b');
00036       monoid_t          monoid (alpha);
00037       semiring_t        semiring;
00038       series_set_t      series (semiring, monoid);
00039       automaton_t       automaton;
00040       automaton.create();
00041       automaton.series() = series;
00042       hstate_t          initial = automaton.add_state();
00043       hstate_t          c       = initial;
00044 
00045       for (unsigned i = 0; i < size; ++i)
00046       {
00047         hstate_t        next = automaton.add_state();
00048         automaton.add_letter_transition(c, c, 'a');
00049         automaton.add_letter_transition(c, next, 'b');
00050         automaton.set_initial(c);
00051         c = next;
00052       }
00053       automaton.set_final(c);
00054       automaton.set_initial(c);
00055       automaton.add_letter_transition(c, initial, 'a');
00056       return automaton;
00057     }
00058 
00059   } // tools
00060 
00061 } // vcsn
00062 
00063 #endif // ! VCSN_TOOLS_GEN_BOOK_HXX

Generated on Sun Jul 29 19:35:19 2007 for Vaucanson by  doxygen 1.5.2