DoorKeeper/include/components/layer.hpp

65 lines
1.7 KiB
C++
Raw Normal View History

#ifndef idD3EDC396AA314474B3D909559FFC0247
#define idD3EDC396AA314474B3D909559FFC0247
#include "primitivetypes.hpp"
#include "components/tilestreamer.hpp"
2014-12-12 19:04:48 +00:00
#include "components/tileiterator.hpp"
#include <algorithm>
#include <vector>
namespace dk {
template <size_t D>
2014-12-12 19:04:48 +00:00
class Viewport;
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 );
virtual ~LayerBase ( void ) noexcept = default;
virtual void preload ( const coords& parFrom, const coords& parTo ) = 0;
coords count ( void ) const { return m_mastersize / m_tilesize * m_count; }
protected:
2014-12-12 19:04:48 +00:00
coords m_count;
coords m_tilesize;
coords m_mastersize;
};
template <typename T, size_t D>
class Layer : public LayerBase<D> {
friend class Viewport<D>;
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;
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 );
virtual ~Layer ( void ) noexcept = default;
Layer& operator= ( const Layer& ) = delete;
2014-12-12 19:04:48 +00:00
iterator begin ( void );
iterator end ( void );
virtual void preload ( const coords& parFrom, const coords& parTo );
2014-12-12 19:04:48 +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;
}
} //namespace dk
#include "implem/layer.inl"
#endif