// Definition for the class of Editor Actors Models
/////////////////////////////////////////////////////
#ifndef _CPACMODL_HPP_
#define _CPACMODL_HPP_

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

#include <afxtempl.h>

#include "EDACActr.hpp"
#include "EDACInst.hpp"
#include "_Ainterf.hpp"
#include "Defines.hpp"

//CPA2 Stegaru Cristian 98/06/22
#define  REASON_ALL_INSTANCES			0
#define  REASON_STANDARD_INSTANCES		1
#define  REASON_INSTANCES_IN_THE_LIST	2
//End CPA2 Stegaru Cristian 98/06/22

//-----------------IR-------------------------
class CPA_EdIR_Brain;
//--------------------------------------------

//################################################################
//define this if you want models with unspecified name lists to fail their instanciation
//#define D_DoNotInstanciateIncompleteModels 

//################################################################
class EdActors_EditorActorModel : public EdActors_EditorActor
{
public:
	//Normal constructor
	EdActors_EditorActorModel(CPA_Family *pclFamily,CPA_Actor *pclActor);

	//"Empty" constructor (for loading)
	EdActors_EditorActorModel(CPA_Actor *pclActor);

	//Copy constructor
 	EdActors_EditorActorModel(EdActors_EditorActorModel *_pclSourceModel, CPA_Actor *_pclActor);

	//Destructor
	~EdActors_EditorActorModel();

	//CPA2 Stegaru Cristian 98/06/22
	void mfn_vUpdateInstances (CTL_Editor_Data *_pclSourceData, int nReason = REASON_ALL_INSTANCES, CStringList *pInstanceNames = NULL);
	void mfn_vGetStandardInstances (CTL_Editor_Data *pSourceData, CTL_Editor_Data *pModifiedData, CStringList &rlstStandardInstances);
	BOOL mfn_bIsAStandardInstance (EdActors_EditorActorInstance *pclInstance, CTL_Editor_Data *pSourceData, CTL_Editor_Data *pModifiedData);
	void mfn_vGetAllInstances (CStringList &rlstAllInstances);
	//End CPA2 Stegaru Cristian 98/06/22

//Attributes
public:
	//The List of Instances
	CPA_List<EdActors_EditorActorInstance> m_clInstancesList;

//-----------------IR-------------------------
	CPA_EdIR_Brain					*m_pclBrain;
	CTL_Editor_ControlList	m_clListOfDesignerVariableControl;
//--------------------------------------------

protected:

private:
	CString m_csBitmapName;

//Functions
public:
#if defined ( D_DoNotInstanciateIncompleteModels )
	BOOL m_bAllListsAreSpecified();
#endif /* D_DoNotInstanciateIncompleteModels */

	CString m_fn_csGetBitmapName();
	void m_fn_vSetBitmapName(CString);

	short m_fn_wGetRelatedInstancesCount();

	void m_fn_vUpdateAllInstances(CTL_Editor_Data *_pclSourceData,
																CTL_tdeUpdateReason _eReason = CTL_UPDATE_REASON__NO_REASON_GIVEN,
																long _lUserDefinedReason = 0);

	BOOL m_fn_bUpdateList(EdActors_ActorMiniStructureList *_pclDestList,		   
												EdActors_ActorMiniStructureList *_pclSourceList,
												CTL_Editor_Data *_pclSourceData,
												CTL_tdeUpdateReason _eReason = CTL_UPDATE_REASON__NO_REASON_GIVEN,
	//CPA2 Stegaru Cristian 98/06/24
												long _lUserDefinedReason = 0,
												BOOL bUsePropagate = FALSE);
	//End CPA2 Stegaru Cristian 98/06/24

	//Allocates MS and all corresponding MS in existing Instances
	BOOL m_fn_bAllocateMS(EdActors_ActorMiniStructure *pclAMS);

	void m_fn_vAllocateMSInInstances(EdActors_ActorMiniStructure *pclAMS);
	void m_fn_vUnallocateMSInInstances(EdActors_ActorMiniStructure *pclAMS);

	//Unallocates MS and all corresponding MS in existing Instances
	BOOL m_fn_bUnallocateMS(EdActors_ActorMiniStructure *pclAMS);

	//Saving & Loading functions
	void m_fn_vSaveActor(SCR_tdst_File_Description *p_stFile);

	void m_fn_vRemoveFromInstancesList(EdActors_EditorActorInstance *pclInstanceToRemove);
	void m_fn_vAddToInstancesList(EdActors_EditorActorInstance *pclInstanceToAdd);

	//Returns TRUE only if Data exists and belongs to an allocated MS
	BOOL m_fn_bDataBelongsToAnAllocatedMS(CString csDataName);

	//Updates all linked Data in given Instance, according to Model
	void m_pub_fn_vUpdateLinkedDataInInstance(CPA_Actor *_pclInstanceToUpdate);

	void m_pub_fn_vSetLink(CTL_Editor_Data *_pclSourceData,
												 BOOL _bMustLink);

// Shaitan FastC {
	void m_pub_fn_vNotifyBrain (void);
	static void	m_fn_vSaveEngineAI(SCR_tdst_File_Description *,char *,void *,SCR_tde_Ntfy_Action);
//End Shaitan FastC }

protected:

private:
	//This function allocates the MS which must always be Allocated
	void m_fn_vMinimalAllocation();

	//Links the Data to Instances
	void m_pri_fn_vLinkData(CTL_Editor_Data *pclData);

};

#endif //_CPACMODL_HPP_

