DoorKeeper/include/doorkeeper/mapreaders/mapstreamraw.hpp

65 lines
2.2 KiB
C++

#ifndef id56E2396E102B4E10B20466D6B57A4C66
#define id56E2396E102B4E10B20466D6B57A4C66
#include "doorkeeper/mapreaders/mapstreambase.hpp"
#include "doorkeeper/implem/helpers.hpp"
#include <cstddef>
#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 <std::size_t D, typename Device>
typename std::enable_if<Device::MapDimensions == D, std::size_t>::type err_mismatching_dimension ( const Device* ) noexcept a_pure;
template <std::size_t D, typename Device>
typename std::enable_if<HasMapDimensions<Device>::result == false, std::size_t>::type err_mismatching_dimension ( const Device* ) noexcept a_pure;
template <std::size_t D, typename Device>
typename std::enable_if<Device::MapDimensions == D, Vector<CoordinateScalarType, D>>::type retrieve_map_size_from_device ( Device* parDevice );
template <std::size_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 <std::size_t D, typename Device>
typename Device::coords get_map_size_from_device ( const Device* parDevice );
template <typename T, std::size_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