// Definition for the class of Editor Actors
//////////////////////////////////////////////////
#ifndef _CPACACTR_HPP_
#define _CPACACTR_HPP_

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

#include "CPA_DatO.hpp"
#include "EDACMStA.hpp"
#include "EDACDef.hpp"
#include "Defines.hpp"

class 	EdActors_EditorActorInstance;
class 	EdActors_EditorActorModel;
class 	CPA_Actor;
class		EdtList;
class		CPA_Family;
class CPA_ZonesActivatingList;

class CPA_EdIR_DesignerVariableList;
class	CTL_Editor_DataList;

typedef enum eCarActorType
{
	EDCAR_ACTOR_TYPE_INSTANCE = 0,
	EDCAR_ACTOR_TYPE_MODEL,

} tdeCarActorType;

//################################################################
class EdActors_EditorActor
{
public:
	EdActors_EditorActor(tdeCarActorType tdeType);
	virtual ~EdActors_EditorActor();

//Attributes
public:
	//The list of actor's MS
	EdActors_AMSListList m_clListOfAMSLists;

	//The current MS List
	EdActors_ActorMiniStructureList *m_pclActorCurrentMSList;

	//Associated Editor Object
	CPA_Actor *m_pclActor;

	//Undo Manager
	CPA_EditManager m_clUndoManager;

//-----------------IR-------------------------
	CTL_Editor_DataList						*m_pclListOfDesignerVariableType;
	CPA_EdIR_DesignerVariableList	*m_pclListOfDesignerVariables;
//--------------------------------------------

protected:

private:
	//The pointer on actor structure
	//For an instance : represents the motor actor
	//For a model : it's a virtual actor (present only for editor)
	CAR_EDIT_TDSTACTOR *m_ptdstActor;

	//Editor specific actor's datas
	////////////////////////////////
	//The index of the current list of MS in editor
	unsigned char m_ucCurrentMSListIndex;

	//The type of the Actor (Modl or Instance)
	tdeCarActorType m_tdeType;

	//
	CTL_Editor_EnumDescriptor *m_pclEnumDescriptorForObjectsTables;

//Functions
public:
	CString m_fn_csGetActorName();

	CAR_EDIT_TDSTACTOR *m_fn_ptdstGetMotorActor();
	void m_fn_vSetMotorActor(CAR_EDIT_TDSTACTOR *);

	unsigned char m_fn_ucGetCurrentMSListIndex();
	void m_fn_vSetCurrentMSListIndex(unsigned char);

	CTL_Editor_Data *m_fn_p_oFindDataByName(CString csName);
	CPA_tdoNameList *m_fn_p_oGetNameList(CString csName);
	EdtList *m_fn_p_oGetObjectList(CString csName);
  CPA_ZonesActivatingList *m_fn_p_oGetZAList(CString csName);
	void m_fn_vSetObjectList(CString csName, EdtList *p_oList);
	BOOL m_fn_bBelongsToAnInstance();

	//Indicates wether the searched Data is owned by the Actor
	// If not, return -1,
	// else returns the Index of the list in which this Data has been found
	char m_fn_cDoesActorOwnData(CTL_Editor_Data *pclDataToSearch);
	//This version fills "pclAMS" with a pointer on the Actor MS in
	//which the Data has been found
	char m_fn_cDoesActorOwnData(CTL_Editor_Data *pclDataToSearch,
															EdActors_ActorMiniStructure *&pclAMS);

	tdeCarActorType m_fn_tdeGetActorType();
	BOOL m_fn_bIsAnInstance();

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

	//
	CTL_Editor_EnumDescriptor *m_pub_fn_pclGetEnumDescriptorForObjectsTables();

 	void m_fn_vUpdateDatas(	EdActors_EditorActor *pclSourceActor,
													BOOL _bMustUpdateUnlinkedData = TRUE,
													CTL_tdeUpdateReason eReason = CTL_UPDATE_REASON__NO_REASON_GIVEN,
													long _lUserDefinedReason = 0);

	//Pure virtual
	virtual void m_pub_fn_vSetLink(CTL_Editor_Data *_pclSourceData,
																 BOOL _bMustLink) = 0;

protected:
	void m_fn_vCreateActorMSDataList();
 	void m_fn_vSetMSPointersToNULL();
	void m_fn_vDeleteAllMS();
 	void m_fn_vAllocateMSAsInModel(EdActors_EditorActorModel *pclSourceModel);

	void m_fn_vUpdateDataInList(EdActors_ActorMiniStructureList *pclDestMSList,
															EdActors_ActorMiniStructureList *pclSourceMSList,
															BOOL _bMustUpdateUnlinkedData = TRUE,
															CTL_tdeUpdateReason eReason = CTL_UPDATE_REASON__NO_REASON_GIVEN,
															long _lUserDefinedReason = 0);

	//Saving
	BOOL m_fn_bSaveMSList(SCRIPT_tdstSaveFile *,
												EdActors_ActorMiniStructureList *);


private:
	void m_fn_vConstructListOfMS();

	BOOL m_fn_bLookForAData(EdActors_ActorMiniStructureList *pclActorMSList,
													CTL_Editor_Data *pclDataToSearch,
													EdActors_ActorMiniStructure *&pclAMS);

	void m_fn_vSetCurrentMSList(EdActors_ActorMiniStructureList *pclActorNewCurrentMSList);


friend class EdActors_ListOfActors;
};

//a macro to quickly access the named namelist of the specified actor
#define M_p_oGetNameListOfActor(p_oCarEditorActor, csName) ((CPA_Editor_ObjectListData *) (p_oCarEditorActor->m_fn_p_oFindDataByName(csName))->m_p_oNameList)

#endif //_CPACACTR_HPP_

