Vaucanson 1.4
|
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, 2005 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 // We can not "project" a static_ranged letter. 00067 typedef undefined_type first_projection_t; 00068 typedef undefined_type second_projection_t; 00069 }; 00070 00071 // FIXME: op_leq may be more adapted. 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 T, class Interval> 00077 bool operator==(const static_ranged<T, Interval>& lhs, 00078 const static_ranged<T, Interval>& rhs); 00079 00080 template <class Stream, class T, class Interval> 00081 Stream& operator<<(Stream& s, static_ranged<T, Interval>& sr) 00082 { 00083 s << sr.value (); 00084 return s; 00085 } 00086 00087 } // algebra 00088 00089 } // vcsn 00090 00091 00092 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB 00093 # include <vaucanson/algebra/implementation/letter/range.hxx> 00094 # endif // VCSN_USE_INTERFACE_ONLY 00095 00096 00097 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_LETTER_RANGE_HH