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 <trace-tools/tool/iterator.hh>
00028 # include <trace-tools/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 typedef tt_get_exact(Bottom, window<InputIterator, WSize, Step, Bottom>)
00096 exact_type;
00097
00099 typedef tt_type(value_type, exact_type) value_type;
00100
00102 template <class Iterable>
00103 window(Iterable&, bool);
00104
00106 bool equal(const window&) const;
00107
00109 void increment();
00110
00112 const value_type& get() const;
00113
00115 const value_type* get_ptr() const;
00116
00118 const typename InputIterator::value_type&
00119 operator [] (unsigned i) const;
00120
00121 protected:
00122 bool at_end_;
00123 InputIterator next_;
00124 InputIterator last_;
00125 value_type v_;
00126 };
00127
00137 template <class InputIterator,
00138 unsigned WSize,
00139 unsigned Step = 1,
00140 class Bottom = bottom>
00141 struct window_maker:
00142 tt_inherit(public iterable,
00143 window_maker<InputIterator, WSize, Step, Bottom>)
00144 {
00146 window_maker(const InputIterator& first, const InputIterator& last);
00147
00148 private:
00149 InputIterator first_;
00150 InputIterator last_;
00151
00152 friend class window<InputIterator, WSize, Step>;
00153 };
00154
00155 }
00156
00157 # include "window.hxx"
00158
00159 #endif // ! TOOL_WINDOW_HH_