// Header for the definition of the class representing a Mechanical Card
//////////////////////////////////////////////////////////////////////////
#ifndef _CPA_MECA_CARD_HPP_
#define _CPA_MECA_CARD_HPP_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

#include <afxtempl.h>

#include "ACP_Base.h"
#include "ITF.h"
#include "IncMEC.h"
#define D_State_Define
#include "IncGAM.h"
#undef D_State_Define
#include "GLI.h"

//External Modules
#include "CTL.h"
//End of External Modules

class CPA_Meca_CardType;

class CPA_Meca_Card : public CPA_SaveObject
{
public:
	CPA_Meca_Card(CString csName,
								CPA_Meca_CardType *pclCardType,
								CString csEngineFileName, 
								CString csEngineActionName,
								void *pvBaseAddress,
								BOOL bCanbBeLoaded = FALSE);

	~CPA_Meca_Card();

//---------------------------------------
//Attributes
public:
	//The list of data
 	CTL_Editor_DataList m_clDataList;
 
	BOOL m_bDataCreated;

	//Undo Manager
	CPA_EditManager m_clUndoManager;

protected:

private:
	//The Name of the Card
//	CString m_csCardName;

	//The Base Address for Data (ie the address where the Structure is located)
	void *m_pvBaseAddress;

	//The base Card Type
	CPA_Meca_CardType *m_pclCardType;

	//
	CString m_pri_csActionName;
	CString m_pri_csCompleteFileName;
	CString m_pri_csReferencedFileName;

	//
	BOOL m_pri_bIsNotified;

//---------------------------------------
//Functions
public:
	void *GetEngineStruct();
 
	void *m_fn_pvGetBaseAddress();
	void m_fn_vSetBaseAddress(void *);

	CString m_fn_csGetCardName();
	void m_fn_vSetCardName(CString);
	
	CPA_Meca_CardType *m_fn_pclGetCardType();
	void m_fn_pclSetCardType(CPA_Meca_CardType *);

	//Virtual functions
	virtual long GetDataType(void);
	virtual void *GetData(void);
	virtual BOOL fn_bCanBeNotified(void);

	//For saving
	static void s_m_fn_vCallBackSaveMecaCard( SCR_tdst_File_Description *_p_stFile,
																						char *_p_szSectionName,
																						void *_p_vData,
																						SCR_tde_Ntfy_Action _eAction);
	
	void m_fn_vSaveMecaCard(SCR_tdst_File_Description *p_tdstFile,
													SCR_tde_Ntfy_Action _eAction);

	BOOL m_fn_bLoadIfUnloaded();

	//
	CString m_pub_fn_csGetActionName();
	void m_pub_fn_vSetActionName(CString);
	CString m_pub_fn_csGetReferencedFileName();
	CString m_pub_fn_csGetCompleteFileName();
	void m_pub_fn_vSetCompleteFileName(CString);

	//
	BOOL m_pub_fn_bIsNotified();

	//Notifications
	virtual void fn_vNotifySave(void);
	virtual void fn_vNotifyUnSave(void);
	virtual void fn_vNotifyRestore(void);
	virtual void fn_vNotifyRename(void);

//ANNECY jt {
	void m_pri_fn_vGetAllMotorValues();
//ENDANNECY jt }

protected:

private:
//ANNECY jt {
//	void m_pri_fn_vGetAllMotorValues();
//ENDANNECY jt }
	
	CString m_pri_fn_csComputeReferencedSectionName();
	CString m_pri_fn_csComputeCompleteSectionName();

};

//#####################################################################

// Definition of the class for the list of mini-structures
class CPA_Meca_CardList : public CList<CPA_Meca_Card *, CPA_Meca_Card *>
{
public:
	CPA_Meca_CardList();
	~CPA_Meca_CardList();

	CPA_Meca_Card* m_fn_pclAddElement(CString, 
																		CPA_Meca_CardType *,
																		void *,
																		CString csFileName = "",
																		CString csSectionName = "",
																		BOOL bCanbBeLoaded = FALSE);
	void m_fn_vEmptyList();

	//Returns the first available (i.e. loaded) Card in the List
	CPA_Meca_Card *m_pub_fn_pclGetFirstAvailableCard();
};

#endif //_CPA_MECA_CARD_HPP_

