#pragma once


#include <windows.h>
//#include <afxwin.h>

class CDocument;

// {19615D2E-F617-498d-84E6-C095233E2577}
static const GUID IID_IBlock = 
{ 0x19615d2e, 0xf617, 0x498d, { 0x84, 0xe6, 0xc0, 0x95, 0x23, 0x3e, 0x25, 0x77 } };

// {B951EFD6-BF6C-4c68-87D6-230EEA69D3C0}
static const GUID IID_IBlockConfig = 
{ 0xb951efd6, 0xbf6c, 0x4c68, { 0x87, 0xd6, 0x23, 0xe, 0xea, 0x69, 0xd3, 0xc0 } };

// {F04B81EE-B5C6-4631-B375-E3B6082615DB}
static const GUID IID_IBlockAutoTrigger = 
{ 0xf04b81ee, 0xb5c6, 0x4631, { 0xb3, 0x75, 0xe3, 0xb6, 0x8, 0x26, 0x15, 0xdb } };


#include <map>

#define WM_CONFIGCLOSED		WM_USER + 7

typedef struct{
	DWORD dwDataLen;
	LPVOID pData;
}REVDATA, *LPREVDATA;

typedef std::map<DWORD, REVDATA> REVDATAMAP, *LPREVDATAMAP;

typedef struct{
	VOID ***pDataArrayArray;	// pouziti: ppDataArray[port][vrstva]
	DWORD *dwLayersArray;		// pocet vrstev v jednotlivych portech
	DWORD **dwDataLenArrayArray;// delka dat [port][vrstva]
}BLOCKDATA, *LPBLOCKDATA;

typedef struct{
	VOID **pDataArray;
	DWORD dwLayers;
	DWORD *dwDataLenArray;
}PORTDATA, *LPPORTDATA;

#ifndef __DEFCREATEPROC__
#define __DEFCREATEPROC__
typedef HRESULT (WINAPIV *CREATEPROC)(REFIID riid, void **ppv);
#endif

typedef BOOL (WINAPI* TRIGGERPROC)(HANDLE);

//#include "BlockItem.h"

class IBlock : public IUnknown
{
public:
	virtual STDMETHODIMP GetInputCount(DWORD *pdwTarget) = 0;
	virtual STDMETHODIMP GetOutputCount(DWORD *pdwTarget) = 0;
	virtual STDMETHODIMP GetName(CString& rstrName) = 0;
	virtual STDMETHODIMP GetDescription(CString& rstrName) = 0;
	virtual STDMETHODIMP GetInputPortName(DWORD dwPort, CString& rstrName) = 0;
	virtual STDMETHODIMP GetOutputPortName(DWORD dwPort, CString& rstrName) = 0;
	virtual STDMETHODIMP InitInstance() = 0;
	virtual STDMETHODIMP ExitInstance() = 0;
	virtual STDMETHODIMP ProcessRev(const DWORD dwProcessId, REVDATAMAP &rRevDataMap) = 0;
	virtual STDMETHODIMP ClearRevMap(REVDATAMAP &rRevDataMapClean) = 0;
	virtual STDMETHODIMP ProcessData(const LPBLOCKDATA pInputData) = 0;
	virtual STDMETHODIMP_(const PORTDATA) GetOutputPortData(DWORD dwPort) const = 0;
	virtual STDMETHODIMP GetBlockPath(CString &rstrPath) = 0;
	virtual STDMETHODIMP_(void) Serialize(CArchive &ar) = 0;
	virtual STDMETHODIMP_(LPCRITICAL_SECTION) GetCriticalSectionPtr() = 0;
	virtual STDMETHODIMP_(BOOL) GetModifiedFlag() = 0;
	virtual STDMETHODIMP_(VOID) SetModifiedFlag(BOOL bModified) = 0;
};

class IBlockConfig : public IUnknown
{
public:
	virtual STDMETHODIMP ShowConfig() = 0;
};

class IBlockAutoTrigger : public IUnknown
{
public:
	virtual STDMETHODIMP Start(TRIGGERPROC pTrigProc, HANDLE hBlock) = 0;
	virtual STDMETHODIMP Stop() = 0;
};