2014-12-09 22:53:09 +00:00
|
|
|
#ifndef idD3EDC396AA314474B3D909559FFC0247
|
|
|
|
#define idD3EDC396AA314474B3D909559FFC0247
|
|
|
|
|
|
|
|
#include "primitivetypes.hpp"
|
|
|
|
#include "components/tilestreamer.hpp"
|
2014-12-12 19:04:48 +00:00
|
|
|
#include "components/tileiterator.hpp"
|
2014-12-09 22:53:09 +00:00
|
|
|
#include <algorithm>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace dk {
|
2014-12-14 12:13:10 +00:00
|
|
|
template <size_t D>
|
2014-12-12 19:04:48 +00:00
|
|
|
class Viewport;
|
|
|
|
|
2014-12-09 22:53:09 +00:00
|
|
|
template <size_t D>
|
|
|
|
class LayerBase {
|
|
|
|
public:
|
|
|
|
typedef Vector<CoordinateScalarType, D> coords;
|
|
|
|
|
2014-12-12 19:04:48 +00:00
|
|
|
LayerBase ( const coords& parCount, const coords& parTileSize, const coords& parMasterTileSize );
|
2014-12-09 22:53:09 +00:00
|
|
|
virtual ~LayerBase ( void ) noexcept = default;
|
|
|
|
|
2014-12-14 12:13:10 +00:00
|
|
|
virtual void preload ( const coords& parFrom, const coords& parTo ) = 0;
|
|
|
|
coords count ( void ) const { return m_mastersize / m_tilesize * m_count; }
|
|
|
|
|
2014-12-09 22:53:09 +00:00
|
|
|
protected:
|
2014-12-12 19:04:48 +00:00
|
|
|
coords m_count;
|
2014-12-11 22:58:52 +00:00
|
|
|
coords m_tilesize;
|
|
|
|
coords m_mastersize;
|
2014-12-09 22:53:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, size_t D>
|
|
|
|
class Layer : public LayerBase<D> {
|
2014-12-14 12:13:10 +00:00
|
|
|
friend class Viewport<D>;
|
|
|
|
|
2014-12-09 22:53:09 +00:00
|
|
|
public:
|
|
|
|
typedef typename LayerBase<D>::coords coords;
|
|
|
|
typedef TileStreamer<T, D> streamer_type;
|
2014-12-12 19:04:48 +00:00
|
|
|
typedef TileIterator<T, D> iterator;
|
2014-12-09 22:53:09 +00:00
|
|
|
|
|
|
|
Layer ( const Layer& ) = delete;
|
|
|
|
Layer ( Layer&& ) = default;
|
2014-12-12 19:04:48 +00:00
|
|
|
Layer ( const coords& parCount, const coords& parTileSize, const coords& parMasterTileSize, streamer_type&& parStreamer );
|
2014-12-09 22:53:09 +00:00
|
|
|
virtual ~Layer ( void ) noexcept = default;
|
|
|
|
|
|
|
|
Layer& operator= ( const Layer& ) = delete;
|
|
|
|
|
2014-12-12 19:04:48 +00:00
|
|
|
iterator begin ( void );
|
2014-12-14 12:13:10 +00:00
|
|
|
iterator end ( void );
|
|
|
|
virtual void preload ( const coords& parFrom, const coords& parTo );
|
2014-12-12 19:04:48 +00:00
|
|
|
|
2014-12-09 22:53:09 +00:00
|
|
|
private:
|
|
|
|
streamer_type m_streamer;
|
|
|
|
std::vector<T> m_tiles;
|
|
|
|
};
|
2014-12-12 19:04:48 +00:00
|
|
|
|
|
|
|
namespace implem {
|
|
|
|
template <size_t D>
|
|
|
|
typename LayerBase<D>::coords::value_type area ( const typename LayerBase<D>::coords& parVec ) a_pure;
|
|
|
|
}
|
2014-12-09 22:53:09 +00:00
|
|
|
} //namespace dk
|
|
|
|
|
|
|
|
#include "implem/layer.inl"
|
|
|
|
|
|
|
|
#endif
|