#pragma once

#include "NZSDK.h"

enum NZ_SDK_KIND
{
	NZ_SDK_NRS = 0,
	NZ_SDK_VMS,
	NZ_SDK_RTSP_DISPLAY
};

typedef HANDLE ( __stdcall *NZ_CREATE )		( NZ_SESSION_TYPE session_type );
typedef HANDLE ( __stdcall *NZ_CREATE_EX )	( NZ_SESSION_TYPE session_type, NZ_MODEL model );
typedef void   ( __stdcall *NZ_DELETE )		( HANDLE handle );
typedef BOOL   ( __stdcall *NZ_COMMAND )	( HANDLE handle, NZ_CMD cmd, DWORD_PTR arg1, DWORD_PTR arg2, DWORD_PTR arg3, DWORD_PTR arg4, DWORD_PTR arg5 );

typedef HANDLE ( __stdcall *NZ_VMS_CREATE ) ( );
typedef void   ( __stdcall *NZ_VMS_DELETE )	( HANDLE handle );
typedef BOOL   ( __stdcall *NZ_VMS_COMMAND ) ( HANDLE handle, NZ_CMD cmd, DWORD_PTR arg1, DWORD_PTR arg2, DWORD_PTR arg3, DWORD_PTR arg4, DWORD_PTR arg5 );
typedef void   ( __stdcall *NZ_VMS_RELEASEDATA ) (LPCSTR pBuffer);
typedef DWORD  ( __stdcall *NZ_VMS_GETLASTERROR ) ( HANDLE handle );


class CNZSDK
{
public:
	CNZSDK							( );
	virtual ~CNZSDK					( );

	NZ_SDK_KIND GetSdkKind			( ) { return m_eSdkKind; }
	void SetSdkKind(NZ_SDK_KIND eValue) { m_eSdkKind = eValue; }

	BOOL	Open					( LPCTSTR dll_dir );
	void	Close					( );
	BOOL	Command					( NZ_CMD cmd, DWORD_PTR arg1=0, DWORD_PTR arg2=0, DWORD_PTR arg3=0, DWORD_PTR arg4=0, DWORD_PTR arg5=0 );

#pragma region NRS Only Functions

	NZ_SESSION_TYPE GetNrsSessionType() { return m_eNrsSessionType; }
	void SetNrsSessionType(NZ_SESSION_TYPE eValue) { m_eNrsSessionType = eValue; }

	NZ_MODEL GetNrsModel() { return m_eNrsModel; }
	void SetNrsModel(NZ_MODEL eValue) { m_eNrsModel = eValue; }

#pragma endregion

#pragma region VMS Only Functions

	DWORD	GetLastError			( );
	void	ReleaseData				( LPCSTR pBuffer );

#pragma  endregion


protected:
	void	Init					( );

protected:
	HMODULE							m_lib;
	HANDLE							m_handle;
	NZ_SDK_KIND						m_eSdkKind;
	NZ_SESSION_TYPE					m_eNrsSessionType;
	NZ_MODEL						m_eNrsModel;

	FARPROC							m_fn_create;
	FARPROC							m_fn_create_ex;
	FARPROC							m_fn_delete;
	FARPROC							m_fn_command;
	FARPROC							m_fn_releasedata;
	FARPROC							m_fn_getlasterror;

};
