/* Copyright 2015, Michele Santullo
* This file is part of DoorKeeper.
*
* DoorKeeper is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* DoorKeeper is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DoorKeeper. If not, see .
*/
#ifndef id873715F57B504CCF8227CE03EA28CAFA
#define id873715F57B504CCF8227CE03EA28CAFA
#include "doorkeeper/primitivetypes.hpp"
#include "doorkeeper/implem/helpers.hpp"
#include "doorkeeper/components/tilecoords.hpp"
#include "doorkeeper/components/pixelconv.hpp"
#include "doorkeeper/components/tile.hpp"
#include
#include
#include
#include
#include
#include
#include
namespace dk {
template
class TileIterator;
namespace implem {
template
struct TypeWithQualifiers {
typedef typename std::conditional::value && std::is_const::value,
typename std::add_cv::type,
typename std::conditional::value,
typename std::add_volatile::type>::type,
typename std::conditional::value,
typename std::add_const::type>::type,
typename std::remove_cv::type
>::type
>::type
>::type result;
};
} //namespace implem
//TODO: replace with a custom iterator rewrite, not using iterator_facade.
//The idea is to have operator* return a Tile<>, which is heavy to
//construct but it's unlikely to be called very often, and then have
//operator-> return a TileHandle<> object that only wraps a pointer to
//the iterator's current state, so it's much more lightweight and it's not
//expected to be kept around by client code.
template ::type>
class TileIterator : public boost::iterator_facade, T, boost::random_access_traversal_tag, Tile, CoordinateDistType> {
friend class boost::iterator_core_access;
typedef std::vector vector_type;
typedef typename implem::TypeWithQualifiers::result qualif_vector_type;
typedef boost::iterator_facade, T, boost::random_access_traversal_tag, Tile, CoordinateDistType> base_class;
public:
typedef TileCoords TileCoordsType;
typedef typename TileCoordsType::coords coords;
typedef typename base_class::difference_type difference_type;
typedef typename base_class::value_type value_type;
typedef typename base_class::pointer pointer;
typedef typename base_class::reference reference;
typedef typename base_class::iterator_category iterator_category;
TileIterator ( void ) = default;
TileIterator ( const TileIterator& parOther ) = default;
TileIterator ( TileIterator&& parOther ) = default;
TileIterator ( qualif_vector_type* parData, const PixelConv& parPixConv, const coords& parArea );
TileIterator ( qualif_vector_type* parData, const PixelConv& parPixConv, const coords& parStart, const coords& parArea );
~TileIterator ( void ) = default;
private:
void increment ( void );
void decrement ( void );
void advance ( size_t parAdvance );
difference_type distance_to ( const TileIterator& parOther );
bool equal ( const TileIterator& parOther ) const;
reference dereference ( void ) const;
TileCoordsType m_tile_range;;
qualif_vector_type* m_data;
const PixelConv& m_pixel_conv;
};
template
Vector make_past_end_coords ( const Vector& parTo ) a_pure;
} //namespace dk
#include "doorkeeper/implem/tileiterator.inl"
#endif