#pragma once

#include "..\\global\\IBlock.h"

#include "BlockItem.h"
#include "SchemeDoc.h"

class CBlockItem_Real : public CBlockItem
{
	DECLARE_SERIAL(CBlockItem_Real)
protected:
	CBlockItem_Real();
	virtual ~CBlockItem_Real();
private:
	BOOL m_bInited;
	HMODULE m_hModule;
	// rozhrani bloku
	IBlock *m_pBlock;
	CString m_strLibName;
	CString m_strBlockName;
	CString m_strDescription;
	IBlockConfig *m_pBlockConfig;
	IBlockAutoTrigger *m_pBlockAutoTrigger;

	CString *m_strInputPortNameArray;
	CString *m_strOutputPortNameArray;

	AUTOTRIGGERHANDLE m_hAutoTrig;

public:
	static CBlockItem_Real* CreateInstance();
	virtual CString GetName() const;
	virtual CString GetDescription() const;
	virtual CString GetStatus() const;
	virtual CString GetInputPortName(DWORD dwPort) const;
	virtual CString GetOutputPortName(DWORD dwPort) const;

	virtual BOOL SetInputCount(const DWORD dwPorts);
	virtual BOOL SetOutputCount(const DWORD dwPorts);

	virtual BOOL InitInstance();
	virtual BOOL ExitInstance();

	virtual BOOL Start();
	virtual BOOL Stop();

	virtual BOOL ShowProperties(BOOL bTest = FALSE);

	virtual const PORTDATA GetOutputPortData(DWORD dwPort) const;
	virtual LPCRITICAL_SECTION GetOutputCriticalSectionPtr(DWORD dwPort) const;
	virtual void Serialize(CArchive& ar);
	CString GetBlockPath();
	BOOL LoadInterface(LPCWSTR lpcLibName);
	BOOL ReleaseInterface();

	BOOL GetModifiedFlag();					// vraci, zda byl nektery z podrizenych realnych bloku zmenen
	VOID SetModifiedFlag(BOOL bModified);	// vraci, zda byl nektery z podrizenych realnych bloku zmenen

private:
	virtual BOOL ProcessRev(const DWORD dwProcessId, REVDATAMAP &rRevDataMap);
	virtual BOOL ClearRevMap(REVDATAMAP &rRevDataMapClean);
	virtual BOOL ProcessData(const LPBLOCKDATA pInputData);
};