Vaucanson  1.4.1
range.hh
1 // range.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 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_ALGEBRA_IMPLEMENTATION_LETTER_RANGE_HH
18 # define VCSN_ALGEBRA_IMPLEMENTATION_LETTER_RANGE_HH
19 
20 # include <vaucanson/algebra/concept/letter.hh>
21 
22 namespace vcsn {
23 
24  namespace algebra {
25 
26  template <class T, class Interval>
27  class static_ranged
28  {
29  public:
30  static_ranged();
31  static_ranged(const T& v);
32  static_ranged(const static_ranged& r);
33  operator T() const;
34  static_ranged randomized();
35  T& value();
36  const T& value() const;
37 
38  // FIXME: add operator++ !!! It should loop from 'begin' to 'to' !
39 
40  private:
41  T value_;
42  };
43 
44  template <char From, char To>
45  struct static_char_interval
46  {
47  static bool check(char c);
48  static char from();
49  static char to();
50  static char random();
51  enum bounds
52  {
53  from_value = From,
54  to_value = To
55  };
56  };
57 
58  template <class T, class Interval>
59  struct letter_traits< static_ranged<T, Interval> >
60  {
61  enum
62  {
63  cardinal = Interval::to_value - Interval::from_value + 1
64  };
65 
66  // We can not "project" a static_ranged letter.
67  typedef undefined_type first_projection_t;
68  typedef undefined_type second_projection_t;
69  };
70 
71  // FIXME: op_leq may be more adapted.
72  template <class T, class Interval>
73  bool operator<(const static_ranged<T, Interval>& lhs,
74  const static_ranged<T, Interval>& rhs);
75 
76  template <class T, class Interval>
77  bool operator==(const static_ranged<T, Interval>& lhs,
78  const static_ranged<T, Interval>& rhs);
79 
80  template <class Stream, class T, class Interval>
81  Stream& operator<<(Stream& s, static_ranged<T, Interval>& sr)
82  {
83  s << sr.value ();
84  return s;
85  }
86 
87  } // algebra
88 
89 } // vcsn
90 
91 
92 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
93 # include <vaucanson/algebra/implementation/letter/range.hxx>
94 # endif // VCSN_USE_INTERFACE_ONLY
95 
96 
97 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_LETTER_RANGE_HH