#include "msg.h"
#include "typedef.h"

class CoreInterface
{
public:
	virtual BOOL DoReact	(React&) = 0;
	virtual BOOL NotifyEvent(Event&) = 0;
	virtual void SetupACDevice(LPCTSTR objtype, LPCTSTR objid, LPCTSTR objtype_reader) = 0;

	virtual	BOOL	 IsObjectExist(LPCTSTR objtype, LPCTSTR id) = 0;
	virtual	BOOL	 IsObjectDisabled(LPCTSTR objtype, LPCTSTR id) = 0;

	virtual Msg FindPersonInfoByCard(LPCTSTR facility_code, LPCTSTR card) = 0;
	virtual Msg FindPersonInfoByExtID(LPCTSTR external_id) = 0;
	virtual	CString GetObjectName (LPCTSTR objtype, LPCTSTR id) = 0;
	virtual	CString	GetObjectState(LPCTSTR objtype, LPCTSTR id) = 0;
	virtual	void	SetObjectState(LPCTSTR objtype, LPCTSTR id, LPCTSTR state) = 0;
	virtual	BOOL	 IsObjectState(LPCTSTR objtype, LPCTSTR id, CString state) = 0;

	virtual	CString					 GetObjectParam    (LPCTSTR objtype, LPCTSTR id, LPCTSTR param) = 0;
	virtual	int						 GetObjectParamInt (LPCTSTR objtype, LPCTSTR id, LPCTSTR param) = 0;
	virtual	CMapStringToStringArray* GetObjectParamList(LPCTSTR objtype, LPCTSTR id, LPCTSTR param) = 0;
	virtual	CStringArray*			 GetObjectParamList(LPCTSTR objtype, LPCTSTR id, LPCTSTR param, LPCTSTR name) = 0;
	virtual	void					 GetObjectParams   (LPCTSTR objtype, LPCTSTR id, Msg& msg) = 0;
	virtual	void					 SetObjectParamInt (LPCTSTR objtype, LPCTSTR id, LPCTSTR param, int val) = 0;
	virtual	CString GetObjectIdByParam(LPCTSTR type, LPCTSTR param, LPCTSTR val) = 0;
	virtual	CString GetObjectIdByName(LPCTSTR type, LPCTSTR name) = 0;
	virtual	CString GetObjectParentId(LPCTSTR objtype, LPCTSTR id, LPCTSTR parent) = 0;
	virtual	int GetObjectIds(LPCTSTR objtype, CStringArray& list, LPCTSTR main_id = NULL) = 0;
	virtual	int GetObjectChildIds(LPCTSTR objtype, LPCTSTR objid, LPCTSTR childtype, CStringArray& list) = 0;
};

class NissObjectDLLExt
{
protected:
	CoreInterface* m_pCore;
public:
	NissObjectDLLExt(CoreInterface* core) { m_pCore = core; }

	virtual CString GetObjectType() = 0;
	virtual CString GetParentType() = 0;
	virtual int GetPos()  { return -1; }
	virtual CString GetPort() { return CString(); }
	virtual CString GetProcessName() { return CString(); }
	virtual CString GetDeviceType() { return CString(); }

	virtual BOOL HasChild() { return FALSE; }
	virtual UINT HasSetupPanel()  { return FALSE; }
	virtual void OnPanelInit(CWnd*) {}
	virtual void OnPanelLoad(CWnd*,Msg&) {}
	virtual void OnPanelSave(CWnd*,Msg&) {}
	virtual void OnPanelExit(CWnd*) {}
	virtual void OnPanelButtonPressed(CWnd*,UINT) {}
	virtual BOOL IsRegionObject()   { return FALSE; }
	virtual BOOL IsProcessObject()  { return FALSE; }
	virtual BOOL IsIncludeParentId()	{ return 0; }
	virtual BOOL IsWantAllEvents()		{ return 0; }
	virtual CString DescribeSubscribeObjectsList() { return CString(); }
	virtual CString GetIncludeIdParentType(){ return CString(); }
	virtual CString DescribeParamLists(){ return CString(); }

	virtual void OnCreate(Msg&) {}
	virtual void OnChange(Msg&,Msg&) {}
	virtual void OnDelete(Msg&) {}
	virtual void OnInit(Msg&)	{}
	virtual void OnEnable(Msg&)  {}
	virtual void OnDisable(Msg&) {}
	virtual BOOL OnEvent(Event&) { return FALSE; }
	virtual BOOL OnReact(React&) { return FALSE; }
};

#define CNissObjectDLLExtArray CArray<NissObjectDLLExt*,NissObjectDLLExt*>

