00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef OLENA_CORE_ABSTRACT_ITER_HH
00029 # define OLENA_CORE_ABSTRACT_ITER_HH
00030
00031 # include <oln/core/abstract/point.hh>
00032 # include <oln/core/abstract/dpoint.hh>
00033 # include <mlc/type.hh>
00034 # include <mlc/objs.hh>
00035 # include <oln/core/macros.hh>
00036
00037 namespace oln {
00038
00041 namespace abstract {
00042 template<class Exact>
00043 struct iter;
00044 }
00045
00046 template<class Exact>
00047 struct iter_traits;
00048
00052 template<class Exact>
00053 struct iter_traits<abstract::iter<Exact> >
00054 {
00055
00056 };
00057
00058
00059 using mlc::begin;
00060 using mlc::end;
00061
00062 namespace abstract
00063 {
00178 template<class Exact>
00179 struct iter : public mlc_hierarchy::any<Exact>
00180 {
00186 typedef typename iter_traits<Exact>::point_type point_type;
00192 typedef typename iter_traits<Exact>::dpoint_type dpoint_type;
00193
00200 const point_type&
00201 point_ref() const
00202 {
00203 return p_;
00204 }
00205
00213 bool
00214 operator==(const abstract::point<point_type>& p) const
00215 {
00216 return p_ == p.exact();
00217 }
00218
00226 bool
00227 operator!=(const abstract::point<point_type>& p) const
00228 {
00229 return p_ != p.exact();
00230 }
00231
00240 point_type
00241 operator+(const abstract::dpoint<dpoint_type>& dp) const
00242 {
00243 precondition(*this != end);
00244 return p_ + dp.exact();
00245 }
00246
00255 point_type
00256 operator-(const abstract::dpoint<dpoint_type>& dp) const
00257 {
00258 precondition(*this != end);
00259 return p_ - dp.exact();
00260 }
00261
00268 operator point_type() const
00269 {
00270 return this->exact().to_point();
00271 }
00272
00279 point_type
00280 cur() const
00281 {
00282 return *this;
00283 }
00284
00285
00286
00287
00288
00289
00290
00291
00297 mlc::begin_type
00298 operator=(mlc::begin_type b)
00299 {
00300 this->exact().goto_begin_();
00301 return b;
00302 }
00303
00309 mlc::end_type
00310 operator=(mlc::end_type e)
00311 {
00312 this->exact().goto_end_();
00313 return e;
00314 }
00315
00322 bool
00323 operator==(mlc::end_type) const
00324 {
00325 return this->exact().is_at_end_();
00326 }
00327
00332 void
00333 operator++()
00334 {
00335 precondition(*this != end);
00336 this->exact().goto_next_();
00337 }
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00355 bool
00356 operator!=(mlc::end_type e) const
00357 {
00358 return ! this->operator==(e);
00359 }
00360
00362 static std::string
00363 name()
00364 {
00365 return std::string("iter<") +
00366 Exact::name() + ">";
00367 }
00368
00369 protected:
00370 point_type p_;
00371
00377 iter()
00378 {}
00379 };
00380
00381 }
00382
00383 }
00384
00385
00386 #endif // ! OLENA_CORE_ABSTRACT_ITER_HH