#include "rlTypes.h"

#ifndef _CORRECTION_FILE_H_
#define _CORRECTION_FILE_H_

typedef int64_t rlCFHandle;
typedef int64_t rlInverseCFHandle;

// NOTE: rlCFOpen is deprecated and will be removed in a later release. Please use rlCFOpenWrite (current behaviour) or rlCFOpenRead instead
extern "C" DLLEXPORT rlCFHandle __stdcall rlCFOpen( const char* fileName );
extern "C" DLLEXPORT rlCFHandle __stdcall rlCFOpenRead( const char* fileName );
extern "C" DLLEXPORT rlCFHandle __stdcall rlCFOpenWrite( const char* fileName );
extern "C" DLLEXPORT rlCFHandle __stdcall rlCFCreate( const char* fileName, const rlOpticalParameters * param, char** correctionTables, uint32_t * correctionLen, uint32_t tableCount );
extern "C" DLLEXPORT rlCFHandle __stdcall rlCFCreateWithExtraInfo( const char* fileName, const rlOpticalParameters * param, char** correctionTables, uint32_t * correctionLen, uint32_t tableCount, const char* extraInfo );

extern "C" DLLEXPORT rlResult __stdcall rlCFClose( rlCFHandle fileHandle );
extern "C" DLLEXPORT rlResult __stdcall rlCFGetOpticalParameters( rlCFHandle fileHandle, rlOpticalParameters * out );
extern "C" DLLEXPORT rlResult __stdcall rlCFTableReadByte( rlCFHandle fileHandle, char* buffer, uint32_t bufferLen, uint32_t offset, uint32_t count, std::uint32_t table );
extern "C" DLLEXPORT rlResult __stdcall rlCFTableReadUInt64( rlCFHandle fileHandle, uint64_t * buffer, uint32_t bufferLen, uint32_t offset, uint32_t count, std::uint32_t table );
extern "C" DLLEXPORT rlResult __stdcall rlCFGetTableLen( rlCFHandle fileHandle, std::uint32_t * outLen, std::uint32_t table );
extern "C" DLLEXPORT rlResult __stdcall rlCFGetTableCount( rlCFHandle fileHandle, std::uint32_t * outCount );
extern "C" DLLEXPORT rlResult __stdcall rlCFHasExtraInfo( rlCFHandle fileHandle, bool* out );
extern "C" DLLEXPORT rlResult __stdcall rlCFGetExtraInfo( rlCFHandle fileHandle, char* buffer, uint32_t bufferSize, uint32_t * stringLength );
extern "C" DLLEXPORT rlResult __stdcall rlCFSetExtraInfo( rlCFHandle fileHandle, const char* extraInfo );
extern "C" DLLEXPORT rlResult __stdcall rlCFAppendExtraInfo( rlCFHandle fileHandle, const char* extraInfo );

extern "C" DLLEXPORT rlResult __stdcall rlCFToScanner3D( rlCFHandle fileHandle, const rlPoint3D * field, rlPoint3DInt * scannerOut );
extern "C" DLLEXPORT rlResult __stdcall rlCFToScanner4D( rlCFHandle fileHandle, const rlPoint4D * field, rlPoint4DInt * scannerOut );

extern "C" DLLEXPORT rlInverseCFHandle __stdcall rlCFGetInverse( rlCFHandle fileHandle );
extern "C" DLLEXPORT rlInverseCFHandle __stdcall rlInverseCFLoad( const char* fileName );

extern "C" DLLEXPORT rlResult __stdcall rlInverseCFClose( rlInverseCFHandle fileHandle );

extern "C" DLLEXPORT rlResult __stdcall rlInverseCFIsInverseOf( rlInverseCFHandle fileHandle, rlCFHandle correctionFile, bool* isInverseOut );
extern "C" DLLEXPORT rlResult __stdcall rlInverseCFIsInverseOfOpticalParameters( rlInverseCFHandle fileHandle, const rlOpticalParameters * param, bool* isInverseOut );
extern "C" DLLEXPORT rlResult __stdcall rlInverseCFIsInverseOfCorrectionFile( rlInverseCFHandle fileHandle, const char* fileName, bool* isInverseOut );

extern "C" DLLEXPORT rlResult __stdcall rlInverseCFStore( rlInverseCFHandle fileHandle, const char* fileName );

extern "C" DLLEXPORT rlResult __stdcall rlInverseCFFromScanner3D( rlInverseCFHandle fileHandle, const rlPoint3DInt * scanner, rlPoint3D * fieldOut );
extern "C" DLLEXPORT rlResult __stdcall rlInverseCFFromScanner4D( rlInverseCFHandle fileHandle, const rlPoint4DInt * scanner, rlPoint4D * fieldOut );

extern "C" DLLEXPORT void __stdcall rlCFGetLastError( char* buffer, int32_t bufferLen );
extern "C" DLLEXPORT int32_t __stdcall rlCFGetLastErrorLen();
#endif // _CORRECTION_FILE_H_
