namespace dk { namespace implem { ///---------------------------------------------------------------------- ///---------------------------------------------------------------------- template typename LayerBase::coords::value_type area (const typename LayerBase::coords& parVec) { typename LayerBase::coords::value_type retval(1); for (size_t d = 0; d < D; ++d) { retval *= parVec[d]; } return retval; } } ///-------------------------------------------------------------------------- ///-------------------------------------------------------------------------- template LayerBase::LayerBase (const coords& parCount, const coords& parTileSize, const coords& parMasterTileSize) : m_count(parCount), m_tilesize(parTileSize), m_mastersize(parMasterTileSize) { DK_ASSERT((parMasterTileSize / parTileSize) * parTileSize == parMasterTileSize); } ///-------------------------------------------------------------------------- ///-------------------------------------------------------------------------- template Layer::Layer (const coords& parCount, const coords& parTileSize, const coords& parMasterTileSize, streamer_type&& parStreamer) : LayerBase(parCount, parTileSize, parMasterTileSize), m_streamer(std::move(parStreamer)), m_activeViewport(*this) { DK_ASSERT(m_streamer.tilesCount() == this->m_count); setActiveViewport(coords(0), parCount); } ///-------------------------------------------------------------------------- ///-------------------------------------------------------------------------- template typename Layer::iterator Layer::begin() { return iterator(&m_tiles, coords(0), this->m_count); } ///-------------------------------------------------------------------------- ///-------------------------------------------------------------------------- template void Layer::setActiveViewport (const coords& parFrom, const coords& parCount) { m_tiles.clear(); const auto area = implem::area(parCount); m_tiles.reserve(area); m_streamer.copy(m_tiles, parFrom, parFrom + parCount); m_activeViewport.setFrom(parFrom); m_activeViewport.setSize(parCount); } }