2014-12-09 21:30:06 +00:00
|
|
|
#ifndef id873715F57B504CCF8227CE03EA28CAFA
|
|
|
|
#define id873715F57B504CCF8227CE03EA28CAFA
|
|
|
|
|
2015-01-06 15:38:52 +00:00
|
|
|
#include "doorkeeper/primitivetypes.hpp"
|
|
|
|
#include "doorkeeper/implem/helpers.hpp"
|
2014-12-09 21:30:06 +00:00
|
|
|
#include <boost/iterator/iterator_facade.hpp>
|
|
|
|
#include <iterator>
|
2014-12-11 22:58:52 +00:00
|
|
|
#include <vector>
|
2014-12-30 16:53:15 +00:00
|
|
|
#include <type_traits>
|
2015-01-08 11:20:17 +00:00
|
|
|
#include <cstdint>
|
2015-05-24 15:19:10 +00:00
|
|
|
#include <cassert>
|
2014-12-09 21:30:06 +00:00
|
|
|
|
|
|
|
namespace dk {
|
2015-05-24 15:17:53 +00:00
|
|
|
template <typename T, uint32_t D, typename T1>
|
|
|
|
class TileIterator;
|
|
|
|
|
2014-12-12 19:04:48 +00:00
|
|
|
namespace implem {
|
2015-01-08 11:20:17 +00:00
|
|
|
template <uint32_t D>
|
2014-12-14 12:13:10 +00:00
|
|
|
size_t get_index_from_pos ( const Vector<CoordinateScalarType, D>& parPos, const Vector<CoordinateScalarType, D>& parSize ) a_pure;
|
2014-12-12 19:04:48 +00:00
|
|
|
|
2014-12-30 16:53:15 +00:00
|
|
|
template <typename I, typename O>
|
|
|
|
struct TypeWithQualifiers {
|
|
|
|
typedef typename std::conditional<std::is_volatile<I>::value && std::is_const<I>::value,
|
|
|
|
typename std::add_cv<O>::type,
|
|
|
|
typename std::conditional<std::is_volatile<I>::value,
|
|
|
|
typename std::add_volatile<typename std::remove_cv<O>::type>::type,
|
|
|
|
typename std::conditional<std::is_const<I>::value,
|
|
|
|
typename std::add_const<typename std::remove_cv<O>::type>::type,
|
|
|
|
typename std::remove_cv<O>::type
|
|
|
|
>::type
|
|
|
|
>::type
|
|
|
|
>::type result;
|
|
|
|
};
|
|
|
|
|
2014-12-12 19:04:48 +00:00
|
|
|
#if defined(NDEBUG)
|
|
|
|
template <>
|
2014-12-14 12:13:10 +00:00
|
|
|
size_t get_index_from_pos<2> ( const Vector<CoordinateScalarType, 2>& parPos, const Vector<CoordinateScalarType, 2>& parSize ) a_pure;
|
2014-12-12 19:04:48 +00:00
|
|
|
#endif
|
2014-12-14 12:13:10 +00:00
|
|
|
|
2015-01-08 11:20:17 +00:00
|
|
|
template <uint32_t D>
|
2014-12-14 12:13:10 +00:00
|
|
|
Vector<CoordinateScalarType, D> buildPastEndCoordinate ( const Vector<CoordinateScalarType, D>& parFrom, const Vector<CoordinateScalarType, D>& parTo ) a_pure;
|
2015-05-24 15:17:53 +00:00
|
|
|
|
|
|
|
template <typename T, uint32_t D, typename T1>
|
|
|
|
const Vector<CoordinateScalarType, D>& get_from_from_iterator ( const TileIterator<T, D, T1>& parIterator );
|
2014-12-12 19:04:48 +00:00
|
|
|
} //namespace implem
|
|
|
|
|
2015-01-08 11:20:17 +00:00
|
|
|
template <typename T, uint32_t D, typename T1=typename std::remove_cv<T>::type>
|
2014-12-12 19:04:48 +00:00
|
|
|
class TileIterator : public boost::iterator_facade<TileIterator<T, D>, T, boost::bidirectional_traversal_tag> {
|
2014-12-09 21:30:06 +00:00
|
|
|
friend class boost::iterator_core_access;
|
2015-05-24 15:17:53 +00:00
|
|
|
friend const Vector<CoordinateScalarType, D>& implem::get_from_from_iterator<> ( const TileIterator& parIterator );
|
2014-12-30 16:53:15 +00:00
|
|
|
typedef std::vector<T1> vector_type;
|
|
|
|
typedef typename implem::TypeWithQualifiers<T, vector_type>::result qualif_vector_type;
|
2014-12-09 21:30:06 +00:00
|
|
|
public:
|
|
|
|
typedef Vector<CoordinateScalarType, D> coords;
|
|
|
|
|
|
|
|
TileIterator ( void );
|
|
|
|
TileIterator ( const TileIterator& parOther ) = default;
|
2014-12-30 16:53:15 +00:00
|
|
|
TileIterator ( TileIterator&& parOther ) = default;
|
|
|
|
TileIterator ( qualif_vector_type* parData, const coords& parFrom, const coords& parTo );
|
|
|
|
TileIterator ( qualif_vector_type* parData, const coords& parFrom, const coords& parTo, const coords& parAreaFrom, const coords& parAreaTo );
|
2015-01-06 15:00:24 +00:00
|
|
|
TileIterator ( qualif_vector_type* parData, const coords& parFrom, const coords& parTo, const coords& parAreaFrom, const coords& parAreaTo, const coords& parSubdiv );
|
2014-12-09 21:30:06 +00:00
|
|
|
~TileIterator ( void ) = default;
|
|
|
|
|
2015-05-24 15:19:10 +00:00
|
|
|
const coords& abs_position ( void ) const { return m_pos; }
|
2014-12-12 19:04:48 +00:00
|
|
|
|
2014-12-09 21:30:06 +00:00
|
|
|
private:
|
|
|
|
void increment ( void );
|
|
|
|
void decrement ( void );
|
|
|
|
void advance ( size_t parAdvance );
|
2014-12-12 19:04:48 +00:00
|
|
|
ptrdiff_t distance_to ( const TileIterator& parOther );
|
|
|
|
bool equal ( const TileIterator& parOther ) const;
|
2015-05-24 15:18:46 +00:00
|
|
|
T& dereference ( void ) const;
|
2015-01-06 15:00:24 +00:00
|
|
|
size_t get_current_index ( void ) const { return implem::get_index_from_pos<D>(m_pos, m_subdivareasize) + m_subindex; }
|
2014-12-09 21:30:06 +00:00
|
|
|
|
|
|
|
coords m_pos;
|
|
|
|
coords m_from;
|
|
|
|
coords m_to;
|
2015-01-06 15:00:24 +00:00
|
|
|
coords m_subdivareasize;
|
2014-12-30 16:53:15 +00:00
|
|
|
qualif_vector_type* m_data;
|
2015-01-06 15:00:24 +00:00
|
|
|
CoordinateScalarType m_subindex;
|
|
|
|
CoordinateScalarType m_maxsubindex;
|
2014-12-09 21:30:06 +00:00
|
|
|
};
|
|
|
|
} //namespace dk
|
|
|
|
|
2015-01-06 15:38:52 +00:00
|
|
|
#include "doorkeeper/implem/tileiterator.inl"
|
2014-12-09 21:30:06 +00:00
|
|
|
|
|
|
|
#endif
|