00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef TOOL_WINDOW_HH_
00023 # define TOOL_WINDOW_HH_
00024
00025 # include <deque>
00026
00027 # include <wipal/tool/iterator.hh>
00028 # include <wipal/tool/iterable.hh>
00029
00030 # include "window_fwd.hh"
00031
00032 namespace tool
00033 {
00034
00036 template <class I, unsigned Ws, unsigned S, class B>
00037 struct types< window<I, Ws, S, B> >
00038 {
00039 typedef
00040 std::deque<typename I::value_type>
00041 value_type;
00042 };
00043
00045 template <class I, unsigned Ws, unsigned S, class B>
00046 struct types< window_maker<I, Ws, S, B> >
00047 {
00048 typedef
00049 window<I, Ws, S, bottom>
00050 iterator;
00051 };
00052
00087 template <class InputIterator,
00088 unsigned WSize,
00089 unsigned Step = 1,
00090 class Bottom = bottom>
00091 struct window:
00092 tt_inherit(public iterator, window<InputIterator, WSize, Step>)
00093 {
00095
00096 typedef tt_get_exact(Bottom, window<InputIterator, WSize, Step, Bottom>)
00097 exact_type;
00098 typedef tt_type(value_type, exact_type) value_type;
00100
00101 enum
00102 {
00103 max_size = WSize,
00104 step = Step
00105 };
00106
00108 template <class Iterable>
00109 window(Iterable&, bool);
00110
00111
00113
00114 bool equal(const window&) const;
00115 void increment();
00116 const value_type& get() const;
00117 const value_type* get_ptr() const;
00119
00121 const typename InputIterator::value_type&
00122 operator [] (unsigned i) const;
00123
00124 protected:
00125 bool at_end_;
00126 InputIterator next_;
00127 InputIterator last_;
00128 value_type v_;
00129 };
00130
00140 template <class InputIterator,
00141 unsigned WSize,
00142 unsigned Step = 1,
00143 class Bottom = bottom>
00144 struct window_maker:
00145 tt_inherit(public iterable,
00146 window_maker<InputIterator, WSize, Step, Bottom>)
00147 {
00149 window_maker(const InputIterator& first, const InputIterator& last);
00150
00151 private:
00152 InputIterator first_;
00153 InputIterator last_;
00154
00155 friend class window<InputIterator, WSize, Step>;
00156 };
00157
00158 }
00159
00160 # include "window.hxx"
00161
00162 #endif // ! TOOL_WINDOW_HH_