/*=========================================================================
*
* CPABaseO.hpp		- CPA_BaseObject : definition
*
*
* Version			1.0
* Creation date		20.06.97
* Revision date
*
* Shaitan
*=======================================================================*/
 
#ifdef ACTIVE_EDITOR
 
#ifndef __BASE_OBJECT_HPP__
#define __BASE_OBJECT_HPP__
 
/****************************************/
#ifndef CPA_EXPORT
#if defined(CPA_WANTS_IMPORT)
#define CPA_EXPORT __declspec(dllimport)
#elif defined(CPA_WANTS_EXPORT)
#define CPA_EXPORT __declspec(dllexport)
#else
#define CPA_EXPORT
#endif
#endif
/****************************************/
 
class CPA_EditorBase;
class CPA_BaseObjectList;
class CPA_MainWorld;
 
typedef enum
{
	E_ss_Responsible,
	E_ss_Modify,
	E_ss_NoSave,
	E_ss_NoModif,
	E_ss_NoStatus
}
tdeSaveStatus;
 
typedef enum
{
	E_mc_None,
	E_mc_NoName,
	E_mc_TypeUnicity,
	E_mc_OwnerUnicity,
	E_mc_CustomUnicity,
	E_mc_ScriptCharacters,
	E_mc_Notification,
	E_mc_CustomValidity
}
tdeMissingCriteria;
 
typedef enum
{
    E_bc_BaseObject,
    E_bc_SaveObject,
    E_bc_ModifiableObject
}
tdeBaseClass;
 
/*#################################################################################*/
/* CPA_BaseObject*/
/*#################################################################################*/
 
class CPA_EXPORT CPA_BaseObject
{
private:
	/* editor*/
    CPA_EditorBase      * m_p_oEditor;
	/* identifier*/
    CPA_BaseObject      * m_p_oOwner;
    CString               m_csName;
	char				* m_p_szName;
	/* lists*/
	CPA_BaseObjectList  * m_p_oBaseObjectList;
	CPA_BaseObjectList  * m_p_oInvalidObjectList;
	/* validity*/
	BOOL				  m_bIsAvailable;
	BOOL				  m_bIsValid;
 
public:
    CPA_BaseObject  (CPA_EditorBase *pEditor, const CString csType, CPA_BaseObject *pOwner = NULL, BOOL bAvailable = TRUE);
    CPA_BaseObject  (CPA_BaseObject &r_oSource);
 
	~CPA_BaseObject (void);
 
private:
	/* add or remove in corresponding BaseObjectList*/
	BOOL fn_bRegister	(void);
	BOOL fn_bUnRegister (void);
 
 
protected:
	void fn_vDoRename	    (const CString csNewName);
 
public:
	/* access*/
    CString               GetName        (void) { return m_csName;    }
    CString               GetType        (void); /* { return m_p_oBaseObjectList->GetType(); }*/
    CPA_BaseObject      * GetOwner       (void) { return m_p_oOwner;  }
    CPA_EditorBase      * GetEditor		 (void) { return m_p_oEditor; }
	CPA_MainWorld		* GetMainWorld	 (void);
    CPA_BaseObjectList  * GetBaseObjectList    (void) { return m_p_oBaseObjectList; }
    CPA_BaseObjectList  * GetInvalidObjectList (void) { return m_p_oBaseObjectList; }
 
	BOOL fn_bIsAvailable (void)				{ return m_bIsAvailable; }
	void SetAvailable	 (BOOL bAvailable)	{ m_bIsAvailable = bAvailable; }
 
    virtual tdeBaseClass fn_eGetBaseClass   (void)  { return E_bc_BaseObject; }
    BOOL fn_bCanBeSaved                     (void)  { return ( (fn_eGetBaseClass() == E_bc_SaveObject) || (fn_eGetBaseClass() == E_bc_ModifiableObject) ); }
 
	/* name & type*/
	char * fn_p_szGetName (void) { return m_p_szName; }
	char * fn_p_szGetType (void); /* { return m_p_oBaseObjectList->fn_p_szGetType(); }*/
 
	/* set parameters*/
	BOOL fn_bSetOwner	(CPA_BaseObject *pNewOwner);
    virtual void fn_vUpdateData (void *pNewData);
 
 
	/* validity*/
	BOOL fn_bIsValid	(void) { return m_bIsValid; }
	BOOL fn_bValidate	(void);
	BOOL fn_bUnValidate (void);
 
	/* unicity*/
	CString GetDefaultUniqueName		(const CString csDefaultBaseName = "");
	void	SetDefaultUniqueName		(const CString csDefaultBaseName = "");
 
	BOOL fn_bIsOfType (const CString csTypeName);
 
	tdeMissingCriteria    fn_eCheckDefaultUnicity     (const CString csNewName);
    tdeMissingCriteria    fn_eCheckUnicityWithOwner   (const CString csNewName);
 
	/* name*/
    virtual tdeMissingCriteria fn_eRename (const CString csNewName);
 
    /* return Data*/
    virtual long   GetDataType	(void) = 0;
    virtual void * GetData		(void) = 0;
 
    /* to choose unicity criteria*/
    virtual tdeMissingCriteria fn_eCheckUnicity (const CString csNewName) { return fn_eCheckDefaultUnicity(csNewName); }
 
	/* for dialogs*/
	virtual CString GetNameToDraw	(void)	{ return GetName(); }
	virtual CString	GetTypeToDraw	(void)	{ return GetType(); }
	virtual CString GetOwnerToDraw	(void)	{ return ( (GetOwner()) ? GetOwner()->GetNameToDraw() : ""); }
};
 
#endif /* __BASE_OBJECT_HPP__*/
 
#endif /* ACTIVE_EDITOR*/
