Base class for iterators on an image. More...
#include <image.hpp>
Public Types | |
typedef pixel_type | value_type |
typedef pixel_type & | reference |
typedef pixel_type * | pointer |
typedef ptrdiff_t | difference_type |
typedef std::random_access_iterator_tag | iterator_category |
Public Member Functions | |
base_iterator () | |
Constructor. | |
base_iterator (image_type &owner, unsigned int x=0, unsigned int y=0) | |
Constructor, from an image. | |
bool | operator== (const self_type &that) const |
Tell if two iterator point to the same address. | |
bool | operator!= (const self_type &that) const |
Tell if two iterator points to different addresses. | |
bool | operator< (const self_type &that) const |
Tell if the current iterator is before an other. | |
bool | operator> (const self_type &that) const |
Tell if the current iterator is after an other. | |
bool | operator<= (const self_type &that) const |
Tell if the current iterator is before an other, or on the same address. | |
bool | operator>= (const self_type &that) const |
Tell if the current iterator is after an other, or on the same address. | |
self_type & | operator+= (int n) |
Move the iterator. | |
self_type & | operator-= (int n) |
Move the iterator. | |
self_type | operator+ (int n) const |
Get an iterator at a specific distance of the current iterator. | |
self_type | operator- (int n) const |
Get an iterator at a specific distance of the current iterator. | |
difference_type | operator- (const self_type &that) const |
Get the distance between two iterators. | |
self_type & | operator++ () |
Preincrement. | |
self_type | operator++ (int) |
Postincrement. | |
self_type & | operator-- () |
Predecrement. | |
self_type | operator-- (int) |
Postdecrement. | |
reference | operator* () const |
Get a reference on the pointed pixel. | |
pointer | operator-> () const |
Get a pointer on the pointed pixel. | |
reference | operator[] (int n) const |
Get a pixel, using the iterator like an array. | |
Private Types | |
typedef Image | image_type |
The type of the image we are iterating through. | |
typedef Pixel | pixel_type |
The type of the pointed pixels. | |
typedef base_iterator < image_type, pixel_type > | self_type |
The type of the current class. | |
Private Member Functions | |
bool | is_final () const |
Tell if the iterator is past the end of its owner. | |
Private Attributes | |
image_type * | m_owner |
The image we are iterating through. | |
math::coordinate_2d< unsigned int > | m_pos |
Coordinates of the pointed pixel in m_owner. | |
Friends | |
template<typename ImageT , typename PixelT > | |
self_type | operator+ (int n, const self_type &self) |
Base class for iterators on an image.
Definition at line 103 of file image.hpp.
typedef ptrdiff_t claw::graphic::image::base_iterator< Image, Pixel >::difference_type |
typedef Image claw::graphic::image::base_iterator< Image, Pixel >::image_type [private] |
typedef std::random_access_iterator_tag claw::graphic::image::base_iterator< Image, Pixel >::iterator_category |
typedef Pixel claw::graphic::image::base_iterator< Image, Pixel >::pixel_type [private] |
typedef pixel_type* claw::graphic::image::base_iterator< Image, Pixel >::pointer |
typedef pixel_type& claw::graphic::image::base_iterator< Image, Pixel >::reference |
typedef base_iterator<image_type, pixel_type> claw::graphic::image::base_iterator< Image, Pixel >::self_type [private] |
typedef pixel_type claw::graphic::image::base_iterator< Image, Pixel >::value_type |
claw::graphic::image::base_iterator< Image, Pixel >::base_iterator | ( | ) | [inline] |
Constructor.
Definition at line 62 of file image.ipp.
References CLAW_POSTCOND, and claw::graphic::image::base_iterator< Image, Pixel >::is_final().
00063 : m_owner(NULL), m_pos(0, 0) 00064 { 00065 CLAW_POSTCOND(is_final()); 00066 } // image::base_iterator::base_iterator()
claw::graphic::image::base_iterator< Image, Pixel >::base_iterator | ( | image_type & | owner, | |
unsigned int | x = 0 , |
|||
unsigned int | y = 0 | |||
) | [inline] |
bool claw::graphic::image::base_iterator< Image, Pixel >::is_final | ( | ) | const [inline, private] |
Tell if the iterator is past the end of its owner.
Definition at line 409 of file image.ipp.
References claw::graphic::image::base_iterator< Image, Pixel >::m_owner, claw::graphic::image::base_iterator< Image, Pixel >::m_pos, claw::math::coordinate_2d< T >::x, and claw::math::coordinate_2d< T >::y.
Referenced by claw::graphic::image::base_iterator< Image, Pixel >::base_iterator(), claw::graphic::image::base_iterator< Image, Pixel >::operator*(), claw::graphic::image::base_iterator< Image, Pixel >::operator++(), claw::graphic::image::base_iterator< Image, Pixel >::operator+=(), claw::graphic::image::base_iterator< Image, Pixel >::operator--(), and claw::graphic::image::base_iterator< Image, Pixel >::operator->().
bool claw::graphic::image::base_iterator< Image, Pixel >::operator!= | ( | const self_type & | that | ) | const [inline] |
claw::graphic::image::base_iterator< Image, Pixel >::reference claw::graphic::image::base_iterator< Image, Pixel >::operator* | ( | ) | const [inline] |
Get a reference on the pointed pixel.
Definition at line 371 of file image.ipp.
References CLAW_PRECOND, claw::graphic::image::base_iterator< Image, Pixel >::is_final(), claw::graphic::image::base_iterator< Image, Pixel >::m_owner, claw::graphic::image::base_iterator< Image, Pixel >::m_pos, claw::math::coordinate_2d< T >::x, and claw::math::coordinate_2d< T >::y.
00372 { 00373 CLAW_PRECOND( !is_final() ); 00374 00375 return (*m_owner)[m_pos.y][m_pos.x]; 00376 } // image::base_iterator::operator*()
claw::graphic::image::base_iterator< Image, Pixel >::self_type claw::graphic::image::base_iterator< Image, Pixel >::operator+ | ( | int | n | ) | const [inline] |
claw::graphic::image::base_iterator< Image, Pixel >::self_type claw::graphic::image::base_iterator< Image, Pixel >::operator++ | ( | int | ) | [inline] |
claw::graphic::image::base_iterator< Image, Pixel >::self_type & claw::graphic::image::base_iterator< Image, Pixel >::operator++ | ( | ) | [inline] |
Preincrement.
Definition at line 302 of file image.ipp.
References CLAW_PRECOND, claw::graphic::image::base_iterator< Image, Pixel >::is_final(), claw::graphic::image::base_iterator< Image, Pixel >::m_owner, claw::graphic::image::base_iterator< Image, Pixel >::m_pos, claw::math::coordinate_2d< T >::x, and claw::math::coordinate_2d< T >::y.
claw::graphic::image::base_iterator< Image, Pixel >::self_type & claw::graphic::image::base_iterator< Image, Pixel >::operator+= | ( | int | n | ) | [inline] |
Move the iterator.
n | Number of steps of the move. |
Definition at line 178 of file image.ipp.
References CLAW_PRECOND, claw::graphic::image::base_iterator< Image, Pixel >::is_final(), claw::graphic::image::base_iterator< Image, Pixel >::m_owner, claw::graphic::image::base_iterator< Image, Pixel >::m_pos, claw::math::coordinate_2d< T >::x, and claw::math::coordinate_2d< T >::y.
00179 { 00180 if (n < 0) 00181 return *this -= -n; 00182 else 00183 { 00184 CLAW_PRECOND( !is_final() ); 00185 00186 unsigned int n_y = n / m_owner->width(); 00187 unsigned int n_x = n % m_owner->width(); 00188 00189 m_pos.x += n_x; 00190 m_pos.y += n_y; 00191 00192 return *this; 00193 } 00194 } // image::base_iterator::operator+=()
claw::graphic::image::base_iterator< Image, Pixel >::difference_type claw::graphic::image::base_iterator< Image, Pixel >::operator- | ( | const self_type & | that | ) | const [inline] |
Get the distance between two iterators.
that | The other operand. |
Definition at line 277 of file image.ipp.
References CLAW_PRECOND.
00278 { 00279 CLAW_PRECOND( is_final() || that.is_final() || (m_owner == that.m_owner) ); 00280 00281 if ( that.is_final() ) 00282 { 00283 if ( is_final() ) 00284 return 0; 00285 else 00286 return -(m_owner->height() - m_pos.y) * m_owner->width() - m_pos.x; 00287 } 00288 else if ( is_final() ) 00289 return (that.m_owner->height() - that.m_pos.y) * that.m_owner->width() 00290 + that.m_pos.x; 00291 else 00292 return m_pos.y * m_owner->width() + m_pos.x 00293 - that.m_pos.y * that.m_owner->width() + that.m_pos.x; 00294 } // image::base_iterator::operator-()
claw::graphic::image::base_iterator< Image, Pixel >::self_type claw::graphic::image::base_iterator< Image, Pixel >::operator- | ( | int | n | ) | const [inline] |
claw::graphic::image::base_iterator< Image, Pixel >::self_type claw::graphic::image::base_iterator< Image, Pixel >::operator-- | ( | int | ) | [inline] |
claw::graphic::image::base_iterator< Image, Pixel >::self_type & claw::graphic::image::base_iterator< Image, Pixel >::operator-- | ( | ) | [inline] |
Predecrement.
Definition at line 336 of file image.ipp.
References CLAW_PRECOND, claw::graphic::image::base_iterator< Image, Pixel >::is_final(), claw::graphic::image::base_iterator< Image, Pixel >::m_owner, claw::graphic::image::base_iterator< Image, Pixel >::m_pos, claw::math::coordinate_2d< T >::x, and claw::math::coordinate_2d< T >::y.
00337 { 00338 CLAW_PRECOND( !is_final() ); 00339 CLAW_PRECOND( (m_pos.y > 0) || (m_pos.x > 0) ); 00340 00341 if ( m_pos.x == 0 ) 00342 { 00343 m_pos.x = m_owner->width() - 1; 00344 --m_pos.y; 00345 } 00346 else 00347 --m_pos.x; 00348 00349 return *this; 00350 } // image::base_iterator::operator--()
claw::graphic::image::base_iterator< Image, Pixel >::self_type & claw::graphic::image::base_iterator< Image, Pixel >::operator-= | ( | int | n | ) | [inline] |
Move the iterator.
n | Number of steps of the move. |
Definition at line 203 of file image.ipp.
References CLAW_PRECOND, claw::graphic::image::base_iterator< Image, Pixel >::m_owner, claw::graphic::image::base_iterator< Image, Pixel >::m_pos, claw::math::coordinate_2d< T >::x, and claw::math::coordinate_2d< T >::y.
00204 { 00205 if (n < 0) 00206 return *this += -n; 00207 else 00208 { 00209 CLAW_PRECOND( m_owner ); 00210 00211 unsigned int n_y = n / m_owner->width(); 00212 unsigned int n_x = n % m_owner->width(); 00213 00214 CLAW_PRECOND( m_pos.x >= n_x ); 00215 CLAW_PRECOND( m_pos.y >= n_y ); 00216 00217 m_pos.x -= n_x; 00218 m_pos.y -= n_y; 00219 00220 return *this; 00221 } 00222 } // image::base_iterator::operator-=()
claw::graphic::image::base_iterator< Image, Pixel >::pointer claw::graphic::image::base_iterator< Image, Pixel >::operator-> | ( | ) | const [inline] |
Get a pointer on the pointed pixel.
Definition at line 384 of file image.ipp.
References CLAW_PRECOND, claw::graphic::image::base_iterator< Image, Pixel >::is_final(), claw::graphic::image::base_iterator< Image, Pixel >::m_pos, claw::math::coordinate_2d< T >::x, and claw::math::coordinate_2d< T >::y.
00385 { 00386 CLAW_PRECOND( !is_final() ); 00387 00388 return &(*m_owner)[m_pos.y][m_pos.x]; 00389 } // image::base_iterator::operator->()
bool claw::graphic::image::base_iterator< Image, Pixel >::operator< | ( | const self_type & | that | ) | const [inline] |
Tell if the current iterator is before an other.
that | The other operand. |
bool claw::graphic::image::base_iterator< Image, Pixel >::operator<= | ( | const self_type & | that | ) | const [inline] |
bool claw::graphic::image::base_iterator< Image, Pixel >::operator== | ( | const self_type & | that | ) | const [inline] |
Tell if two iterator point to the same address.
that | The other operand. |
bool claw::graphic::image::base_iterator< Image, Pixel >::operator> | ( | const self_type & | that | ) | const [inline] |
bool claw::graphic::image::base_iterator< Image, Pixel >::operator>= | ( | const self_type & | that | ) | const [inline] |
claw::graphic::image::base_iterator< Image, Pixel >::reference claw::graphic::image::base_iterator< Image, Pixel >::operator[] | ( | int | n | ) | const [inline] |
self_type operator+ | ( | int | n, | |
const self_type & | self | |||
) | [friend] |
image_type* claw::graphic::image::base_iterator< Image, Pixel >::m_owner [private] |
The image we are iterating through.
Definition at line 162 of file image.hpp.
Referenced by claw::graphic::image::base_iterator< Image, Pixel >::is_final(), claw::graphic::image::base_iterator< Image, Pixel >::operator*(), claw::graphic::image::base_iterator< Image, Pixel >::operator++(), claw::graphic::image::base_iterator< Image, Pixel >::operator+=(), claw::graphic::image::base_iterator< Image, Pixel >::operator--(), and claw::graphic::image::base_iterator< Image, Pixel >::operator-=().
math::coordinate_2d<unsigned int> claw::graphic::image::base_iterator< Image, Pixel >::m_pos [private] |
Coordinates of the pointed pixel in m_owner.
Definition at line 165 of file image.hpp.
Referenced by claw::graphic::image::base_iterator< Image, Pixel >::is_final(), claw::graphic::image::base_iterator< Image, Pixel >::operator*(), claw::graphic::image::base_iterator< Image, Pixel >::operator++(), claw::graphic::image::base_iterator< Image, Pixel >::operator+=(), claw::graphic::image::base_iterator< Image, Pixel >::operator--(), claw::graphic::image::base_iterator< Image, Pixel >::operator-=(), and claw::graphic::image::base_iterator< Image, Pixel >::operator->().