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 104 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().
: m_owner(NULL), m_pos(0, 0) { CLAW_POSTCOND(is_final()); } // 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.
{
CLAW_PRECOND( !is_final() );
return (*m_owner)[m_pos.y][m_pos.x];
} // 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++ | ( | ) | [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 | ) | [inline] |
| 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.
| 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 >::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.
{
CLAW_PRECOND( is_final() || that.is_final() || (m_owner == that.m_owner) );
if ( that.is_final() )
{
if ( is_final() )
return 0;
else
return -(m_owner->height() - m_pos.y) * m_owner->width() - m_pos.x;
}
else if ( is_final() )
return (that.m_owner->height() - that.m_pos.y) * that.m_owner->width()
+ that.m_pos.x;
else
return m_pos.y * m_owner->width() + m_pos.x
- that.m_pos.y * that.m_owner->width() + that.m_pos.x;
} // image::base_iterator::operator-()
| 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.
{
CLAW_PRECOND( !is_final() );
CLAW_PRECOND( (m_pos.y > 0) || (m_pos.x > 0) );
if ( m_pos.x == 0 )
{
m_pos.x = m_owner->width() - 1;
--m_pos.y;
}
else
--m_pos.x;
return *this;
} // 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.
{
if (n < 0)
return *this += -n;
else
{
CLAW_PRECOND( m_owner );
unsigned int n_y = n / m_owner->width();
unsigned int n_x = n % m_owner->width();
CLAW_PRECOND( m_pos.x >= n_x );
CLAW_PRECOND( m_pos.y >= n_y );
m_pos.x -= n_x;
m_pos.y -= n_y;
return *this;
}
} // 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.
{
CLAW_PRECOND( !is_final() );
return &(*m_owner)[m_pos.y][m_pos.x];
} // image::base_iterator::operator->()
| 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] |
| 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] |
| 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 163 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 166 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->().
1.7.1