/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2016 Raytrix GmbH. All rights reserved.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once

#include "DLLInterface.h"
#include "Pimpl.h"

#include "Calibration.h"
#include "RayImage.h"

#include "Rx.Core.Ex/RxImage.h"
#include "Rx.Core.Ex/RxMetaData.h"

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// namespace: Rx.LFR
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace Rx
{
	namespace LFR
	{
		class CRayFileReader_Impl;

		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>
		/// 	Provides methods for reading a ray image from a ray file.
		/// </summary>
		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		class RX_API CRayFileReader : public CPimpl<CRayFileReader_Impl, Interfaces::ERayFileReader::ID>
		{
		public:

			/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
			/// <summary>
			/// 	Reads from the given ray file. Reads the raw image, the calibration (with gray image) and the meta data.
			///
			/// 	Requires an authenticated dongle (Rx::LFR::CLightFieldRuntime::Authenticate).
			/// </summary>
			///
			/// <param name="sxFilename"> The file name. </param>
			/// <param name="xRayImg">    [out] The read ray image. </param>
			/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
			static void Read(const CRxString& sxFilename, CRayImage& xRayImg);

			/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
			/// <summary>
			/// 	Reads from the given gray image file.
			///
			/// 	Requires an authenticated dongle (Rx::LFR::CLightFieldRuntime::Authenticate).
			/// </summary>
			///
			/// <param name="sxFilename"> The file name. </param>
			/// <param name="xImg">		  [out] The read gray image. </param>
			/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
			static void ReadGrayImage(const CRxString& sxFilename, CRxImage& xImg);

			/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
			/// <summary>
			/// 	Gets the interface defined by Interfaces::ERayFileReader.
			/// </summary>
			///
			/// <param name="eData"> The interface type. </param>
			///
			/// <returns> Null if it fails, else the interface. </returns>
			/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
			static void* GetInterface(Interfaces::ERayFileReader::ID eData);

		private:

			/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
			CRayFileReader();
			~CRayFileReader();
			CRayFileReader(const CRayFileReader&);
			CRayFileReader& operator=(const CRayFileReader&);
		};
	}
}
