/* 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 .
*/
namespace dk {
namespace implem {
template
class data_fetcher {
public:
typedef typename BaseMapSource::coords coords;
static void fetch ( std::vector& parOut, const coords& parFrom, const coords& parTo, std::size_t parCount, BaseMapSource& parMapSrc ) {
parOut.resize(parCount);
parMapSrc.fetch_raw(reinterpret_cast(parOut.data()), parFrom, parTo, sizeof(T) * parCount);
}
};
template
class data_fetcher {
public:
typedef typename BaseMapSource::coords coords;
static void fetch ( std::vector& parOut, const coords& parFrom, const coords& parTo, std::size_t parCount, BaseMapSource& parMapSrc ) {
parOut.reserve(parCount);
DK_ASSERT(false); //not implemented
(void)parOut;
(void)parFrom;
(void)parTo;
(void)parMapSrc;
}
};
} //namespace implem
template
template
void BaseMapSource::fetch (std::vector& parOut, const coords& parFrom, const coords& parTo) {
const auto tile_count = tile_volume(parTo - parFrom);
const std::size_t casted_tile_count = static_cast(tile_count);
DK_ASSERT(static_cast(casted_tile_count) == tile_count);
parOut.reserve(casted_tile_count);
parOut.clear();
implem::data_fetcher::fetch(parOut, parFrom, parTo, casted_tile_count, *this);
}
} //namespace dk