DoorKeeper/include/components/layer.hpp

64 lines
1.7 KiB
C++

#ifndef idD3EDC396AA314474B3D909559FFC0247
#define idD3EDC396AA314474B3D909559FFC0247
#include "primitivetypes.hpp"
#include "components/tilestreamer.hpp"
#include "components/tileiterator.hpp"
#include <algorithm>
#include <vector>
namespace dk {
template <size_t D>
class Viewport;
template <size_t D>
class LayerBase {
public:
typedef Vector<CoordinateScalarType, D> coords;
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:
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;
typedef TileIterator<T, D> iterator;
Layer ( const Layer& ) = delete;
Layer ( Layer&& ) = default;
Layer ( const coords& parCount, const coords& parTileSize, const coords& parMasterTileSize, streamer_type&& parStreamer );
virtual ~Layer ( void ) noexcept = default;
Layer& operator= ( const Layer& ) = delete;
iterator begin ( void );
iterator end ( void );
virtual void preload ( const coords& parFrom, const coords& parTo );
private:
streamer_type m_streamer;
std::vector<T> m_tiles;
};
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