range.hh

00001 // range.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 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_ALGEBRA_IMPLEMENTATION_LETTER_RANGE_HH
00018 # define VCSN_ALGEBRA_IMPLEMENTATION_LETTER_RANGE_HH
00019 
00020 # include <vaucanson/algebra/concept/letter.hh>
00021 
00022 namespace vcsn {
00023 
00024   namespace algebra {
00025 
00026     template <class T, class Interval>
00027     class static_ranged
00028     {
00029     public:
00030       static_ranged();
00031       static_ranged(const T& v);
00032       static_ranged(const static_ranged& r);
00033       operator T() const;
00034       static_ranged     randomized();
00035       T&                value();
00036       const T&          value() const;
00037 
00038       // FIXME: add operator++ !!! It should loop from 'begin' to 'to' !
00039 
00040     private:
00041       T        value_;
00042     };
00043 
00044     template <char From, char To>
00045     struct static_char_interval
00046     {
00047       static bool check(char c);
00048       static char from();
00049       static char to();
00050       static char random();
00051       enum bounds
00052         {
00053           from_value = From,
00054           to_value = To
00055         };
00056     };
00057 
00058     template <class T, class Interval>
00059     struct letter_traits< static_ranged<T, Interval> >
00060     {
00061       enum
00062         {
00063           cardinal = Interval::to_value - Interval::from_value + 1
00064         };
00065     };
00066 
00067     // FIXME: op_leq may be more adapted.
00068     template <class T, class Interval>
00069     bool operator<(const static_ranged<T, Interval>& lhs,
00070                    const static_ranged<T, Interval>& rhs);
00071 
00072     template <class T, class Interval>
00073     bool operator==(const static_ranged<T, Interval>& lhs,
00074                     const static_ranged<T, Interval>& rhs);
00075 
00076     template <class Stream, class T, class Interval>
00077     Stream& operator<<(Stream& s, static_ranged<T, Interval>& sr)
00078     {
00079       s << sr.value ();
00080       return s;
00081     }
00082 
00083   } // algebra
00084 
00085 } // vcsn
00086 
00087 
00088 # ifndef VCSN_USE_INTERFACE_ONLY
00089 #  include <vaucanson/algebra/implementation/letter/range.hxx>
00090 # endif // VCSN_USE_INTERFACE_ONLY
00091 
00092 
00093 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_LETTER_RANGE_HH

Generated on Fri Jul 28 12:18:51 2006 for Vaucanson by  doxygen 1.4.6