/*
 * This file implements the non-virtual methods of the class atc::RawIOBase.
 */

#include "RawIOBase.hpp"
#include "RawIO.hpp"

namespace atc {
	
	template<typename ftype>
	std::unique_ptr<RawIOBase<ftype>> RawIOBase<ftype>::create(DataType dtype) {
		switch (dtype) {
		case DataType::uint8:
			return std::make_unique<RawIO<ftype, uint8_t>>();
		case DataType::uint16:
			return std::make_unique<RawIO<ftype, uint16_t>>();
		case DataType::uint32:
			return std::make_unique<RawIO<ftype, uint32_t>>();
		case DataType::uint64:
			return std::make_unique<RawIO<ftype, uint64_t>>();
		case DataType::int8:
			return std::make_unique<RawIO<ftype, int8_t>>();
		case DataType::int16:
			return std::make_unique<RawIO<ftype, int16_t>>();
		case DataType::int32:
			return std::make_unique<RawIO<ftype, int32_t>>();
		case DataType::int64:
			return std::make_unique<RawIO<ftype, int64_t>>();
		case DataType::float32:
			return std::make_unique<RawIO<ftype, float>>();
		case DataType::float64:
			return std::make_unique<RawIO<ftype, double>>();
		}
		throw std::runtime_error("Invalid DataType");
	}
	
	template<typename ftype>
	std::unique_ptr<RawIOBase<ftype>> RawIOBase<ftype>::create(uint8_t data_type_id) {
		return RawIOBase<ftype>::create(id_to_data_type(data_type_id));
	}
	
	// Explicit instantiations
	template class RawIOBase<float>;
	template class RawIOBase<double>;
	
}
