DoorKeeper/include/doorkeeper/implem/basemapsource.inl

39 lines
1.4 KiB
Text
Raw Normal View History

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) {
2015-08-16 20:29:34 +00:00
const auto tile_count = tile_volume<D>(parTo - parFrom + 1);
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