DoorKeeper/include/doorkeeper/components/layer.hpp

71 lines
1.8 KiB
C++
Raw Normal View History

#ifndef idD3EDC396AA314474B3D909559FFC0247
#define idD3EDC396AA314474B3D909559FFC0247
#include "doorkeeper/primitivetypes.hpp"
#include "doorkeeper/components/tileiterator.hpp"
#include "doorkeeper/components/tilemapdata.hpp"
#include "doorkeeper/implem/helpers.hpp"
#include <algorithm>
#include <vector>
#include <memory>
#include <cstdint>
namespace dk {
template <uint32_t D>
2014-12-12 19:04:48 +00:00
class Viewport;
template <uint32_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;
void preload ( const coords& parFrom, const coords& parTo );
coords count ( void ) const { return m_mastersize / m_tilesize * m_count; }
const coords& mapSize ( void ) const { return m_count; }
protected:
2014-12-12 19:04:48 +00:00
coords m_count;
coords m_tilesize;
coords m_mastersize;
private:
virtual void onPreload ( const coords& parFrom, const coords& parTo ) = 0;
coords m_haveFrom;
coords m_haveTo;
};
template <typename T, uint32_t D>
class Layer : public LayerBase<D> {
friend class Viewport<D>;
public:
typedef typename LayerBase<D>::coords coords;
2014-12-12 19:04:48 +00:00
typedef TileIterator<T, D> iterator;
typedef TileIterator<const T, D> const_iterator;
Layer ( const Layer& ) = delete;
Layer ( Layer&& ) = default;
Layer ( const coords& parTileSize, const coords& parMasterTileSize, TileMapData<T, D>& parTilemap );
virtual ~Layer ( void ) noexcept = default;
Layer& operator= ( const Layer& ) = delete;
2014-12-12 19:04:48 +00:00
iterator begin ( void );
iterator end ( void );
2014-12-12 19:04:48 +00:00
private:
virtual void onPreload ( const coords& parFrom, const coords& parTo );
std::vector<T> m_tiles;
TileMapData<T, D>& m_tilemap;
};
} //namespace dk
#include "doorkeeper/implem/layer.inl"
#endif