2014-12-09 22:53:09 +00:00
|
|
|
namespace dk {
|
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) {
|
|
|
|
typename LayerBase<D>::coords::value_type retval(1);
|
|
|
|
for (size_t d = 0; d < D; ++d) {
|
|
|
|
retval *= parVec[d];
|
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-09 22:53:09 +00:00
|
|
|
///--------------------------------------------------------------------------
|
|
|
|
///--------------------------------------------------------------------------
|
|
|
|
template <size_t D>
|
2014-12-12 19:04:48 +00:00
|
|
|
LayerBase<D>::LayerBase (const coords& parCount, const coords& parTileSize, const coords& parMasterTileSize) :
|
|
|
|
m_count(parCount),
|
2014-12-11 22:58:52 +00:00
|
|
|
m_tilesize(parTileSize),
|
|
|
|
m_mastersize(parMasterTileSize)
|
2014-12-09 22:53:09 +00:00
|
|
|
{
|
2014-12-11 22:58:52 +00:00
|
|
|
DK_ASSERT((parMasterTileSize / parTileSize) * parTileSize == parMasterTileSize);
|
2014-12-09 22:53:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
///--------------------------------------------------------------------------
|
|
|
|
///--------------------------------------------------------------------------
|
|
|
|
template <typename T, size_t D>
|
2014-12-12 19:04:48 +00:00
|
|
|
Layer<T, D>::Layer (const coords& parCount, const coords& parTileSize, const coords& parMasterTileSize, streamer_type&& parStreamer) :
|
|
|
|
LayerBase<D>(parCount, parTileSize, parMasterTileSize),
|
2014-12-14 12:13:10 +00:00
|
|
|
m_streamer(std::move(parStreamer))
|
2014-12-09 22:53:09 +00:00
|
|
|
{
|
2014-12-13 03:50:23 +00:00
|
|
|
DK_ASSERT(m_streamer.tilesCount() == this->m_count);
|
2014-12-09 22:53:09 +00:00
|
|
|
}
|
2014-12-12 19:04:48 +00:00
|
|
|
|
|
|
|
///--------------------------------------------------------------------------
|
|
|
|
///--------------------------------------------------------------------------
|
|
|
|
template <typename T, size_t D>
|
|
|
|
typename Layer<T, D>::iterator Layer<T, D>::begin() {
|
|
|
|
return iterator(&m_tiles, coords(0), this->m_count);
|
|
|
|
}
|
|
|
|
|
|
|
|
///--------------------------------------------------------------------------
|
|
|
|
///--------------------------------------------------------------------------
|
|
|
|
template <typename T, size_t D>
|
2014-12-14 12:13:10 +00:00
|
|
|
typename Layer<T, D>::iterator Layer<T, D>::end() {
|
|
|
|
return iterator(&m_tiles, implem::buildPastEndCoordinate<D>(coords(0), this->m_count), this->m_count);
|
|
|
|
}
|
|
|
|
|
|
|
|
///--------------------------------------------------------------------------
|
|
|
|
///--------------------------------------------------------------------------
|
|
|
|
template <typename T, size_t D>
|
|
|
|
void Layer<T, D>::preload (const coords& parFrom, const coords& parTo) {
|
2014-12-12 19:04:48 +00:00
|
|
|
m_tiles.clear();
|
2014-12-14 12:13:10 +00:00
|
|
|
const auto area = implem::area<D>(parTo - parFrom);
|
2014-12-12 19:04:48 +00:00
|
|
|
m_tiles.reserve(area);
|
2014-12-14 12:13:10 +00:00
|
|
|
m_streamer.copy(m_tiles, parFrom, parTo);
|
2014-12-12 19:04:48 +00:00
|
|
|
}
|
2014-12-09 22:53:09 +00:00
|
|
|
}
|