DoorKeeper/include/doorkeeper/implem/basemapsource.inl

38 lines
1.4 KiB
C++

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