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 wpl
00033 {
00034
00035 namespace tool
00036 {
00037
00038 template <class, unsigned, unsigned, class>
00039 struct window;
00040
00041 template <class, unsigned, unsigned, class>
00042 struct window_maker;
00043
00045 template <class I, unsigned Ws, unsigned S, class B>
00046 struct types< window<I, Ws, S, B> >
00047 {
00048 typedef std::deque<typename I::value_type> value_type;
00049 };
00050
00052 template <class I, unsigned Ws, unsigned S, class B>
00053 struct types< window_maker<I, Ws, S, B> >
00054 {
00055 typedef window<I, Ws, S, bottom> iterator;
00056 };
00057
00092 template <class InputIterator,
00093 unsigned WSize,
00094 unsigned Step = 1,
00095 class Bottom = bottom>
00096 struct window:
00097 WP_INHERIT(public iterator, window<InputIterator, WSize, Step>)
00098 {
00100
00101 typedef WP_GET_EXACT(Bottom, window<InputIterator, WSize, Step, Bottom>)
00102 exact_type;
00103 typedef WP_TYPE(value_type, exact_type) value_type;
00105
00106 enum
00107 {
00108 max_size = WSize,
00109 step = Step
00110 };
00111
00113 template <class Iterable>
00114 window(Iterable&, bool);
00115
00116
00118
00119 bool equal(const window&) const;
00120 void increment();
00121 const value_type& get() const;
00122 const value_type* get_ptr() const;
00124
00126 const typename InputIterator::value_type&
00127 operator [] (unsigned i) const;
00128
00130 bool last() const;
00131
00132 protected:
00133 bool at_end_;
00134 InputIterator next_;
00135 InputIterator last_;
00136 value_type v_;
00137 };
00138
00148 template <class InputIterator,
00149 unsigned WSize,
00150 unsigned Step = 1,
00151 class Bottom = bottom>
00152 struct window_maker:
00153 WP_INHERIT(public iterable,
00154 window_maker<InputIterator, WSize, Step, Bottom>)
00155 {
00157 window_maker(const InputIterator& first, const InputIterator& last);
00158
00159 private:
00160 InputIterator first_;
00161 InputIterator last_;
00162
00163 friend class window<InputIterator, WSize, Step>;
00164 };
00165
00166 }
00167
00168 }
00169
00170 # include "window.hxx"
00171
00172 #endif // ! TOOL_WINDOW_HH_