King_DuckZ
701366bf86
This fixes the build on 64-bit machines, where size_t and uint32_t from vector.hpp would mismatch.
66 lines
2.2 KiB
C++
66 lines
2.2 KiB
C++
#ifndef id56E2396E102B4E10B20466D6B57A4C66
|
|
#define id56E2396E102B4E10B20466D6B57A4C66
|
|
|
|
#include "doorkeeper/mapreaders/mapstreambase.hpp"
|
|
#include "doorkeeper/implem/helpers.hpp"
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <algorithm>
|
|
#include <type_traits>
|
|
#include <istream>
|
|
|
|
namespace dk {
|
|
namespace implem {
|
|
template <typename T>
|
|
class HasMapDimensions {
|
|
class yes { char m; };
|
|
class nope { yes m[2]; };
|
|
static yes deduce ( int a, int b = T::MapDimensions );
|
|
static nope deduce ( ... );
|
|
public:
|
|
enum {
|
|
result = (sizeof(yes) == sizeof(deduce(1)))
|
|
};
|
|
};
|
|
|
|
template <uint32_t D, typename Device>
|
|
typename std::enable_if<Device::MapDimensions == D, uint32_t>::type err_mismatching_dimension ( const Device* ) noexcept a_pure;
|
|
|
|
template <uint32_t D, typename Device>
|
|
typename std::enable_if<HasMapDimensions<Device>::result == false, uint32_t>::type err_mismatching_dimension ( const Device* ) noexcept a_pure;
|
|
|
|
template <uint32_t D, typename Device>
|
|
typename std::enable_if<Device::MapDimensions == D, Vector<CoordinateScalarType, D>>::type retrieve_map_size_from_device ( Device* parDevice );
|
|
|
|
template <uint32_t D, typename Device>
|
|
typename std::enable_if<HasMapDimensions<Device>::result == false, Vector<CoordinateScalarType, D>>::type retrieve_map_size_from_device ( Device* parDevice );
|
|
} //namespace implem
|
|
|
|
//Customization point - specialize to enable map size retrieval for Device
|
|
template <uint32_t D, typename Device>
|
|
typename Device::coords get_map_size_from_device ( const Device* parDevice );
|
|
|
|
template <typename T, uint32_t D>
|
|
class MapStreamRaw : public MapStreamBase<D> {
|
|
public:
|
|
typedef typename MapStreamBase<D>::coords coords;
|
|
|
|
MapStreamRaw ( void ) = delete;
|
|
template <typename Device>
|
|
explicit MapStreamRaw ( Device& parDevice );
|
|
virtual ~MapStreamRaw ( void ) noexcept = default;
|
|
|
|
virtual bool isReadable ( void ) const { return true; }
|
|
virtual bool isWriteable ( void ) const { return false; }
|
|
|
|
private:
|
|
virtual std::size_t dataBlockRequested ( char* parOut, std::size_t parOutSize, const coords& parFrom, const coords& parTo );
|
|
|
|
std::istream m_istream;
|
|
const bool m_deviceHasDim;
|
|
};
|
|
} //namespace dk
|
|
|
|
#include "doorkeeper/implem/mapstreamraw.inl"
|
|
|
|
#endif
|