/* Copyright 2015, Michele Santullo * This file is part of DoorKeeper. * * DoorKeeper is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * DoorKeeper is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with DoorKeeper. If not, see . */ #ifndef idD3EDC396AA314474B3D909559FFC0247 #define idD3EDC396AA314474B3D909559FFC0247 #include "doorkeeper/primitivetypes.hpp" #include "doorkeeper/components/tileiterator.hpp" #include "doorkeeper/components/basemapsource.hpp" #include "doorkeeper/components/viewport.hpp" #include "doorkeeper/implem/helpers.hpp" #include #include #include #include #if !defined(NDEBUG) #include #endif #include namespace dk { template class LayerBase { public: typedef Vector coords; LayerBase ( const coords& parCount, const coords& parTileSize ); virtual ~LayerBase ( void ) noexcept = default; void preload ( const coords& parFrom, const coords& parTo ); const coords& map_size ( void ) const { return m_count; } const coords& tile_size ( void ) const { return m_tilesize; } virtual void each_tile ( const Viewport& parViewport ) const = 0; protected: coords m_count; coords m_tilesize; private: virtual void onPreload ( const coords& parFrom, const coords& parTo ) = 0; coords m_haveFrom; coords m_haveTo; }; template class Layer : public LayerBase { friend class Viewport; public: typedef typename LayerBase::coords coords; typedef TileIterator iterator; typedef TileIterator const_iterator; Layer ( const Layer& ) = delete; Layer ( Layer&& ) = default; explicit Layer ( BaseMapSource* parTilemap ); virtual ~Layer ( void ) noexcept = default; virtual void each_tile ( const Viewport& parViewport ) const; Layer& operator= ( const Layer& ) = delete; iterator begin ( void ); iterator end ( void ); private: virtual void onPreload ( const coords& parFrom, const coords& parTo ); std::vector m_tiles; BaseMapSource* m_tilemap; }; namespace implem { template bool at_least_one ( const Vector& parLeft, const Vector& parRight, O parOp ) a_pure; } //namespace implem } //namespace dk #include "doorkeeper/implem/layer.inl" #endif