#pragma once

// -------------------------------------------------------------------------
// Summary:
// 		内存中对象的唯一标识符。有了对象ID,就能访问对象
// -------------------------------------------------------------------------
class ARXDLL McDbObjectId
{
public:
	// -------------------------------------------------------------------------
	// Summary:
	// 		构造函数
	// -------------------------------------------------------------------------
	McDbObjectId();
	// -------------------------------------------------------------------------
	// Summary:
	// 		析构函数
	// -------------------------------------------------------------------------
	//virtual ~McDbObjectId();

	// -------------------------------------------------------------------------
	// Summary:
	// 		对象ID是否为空
	// -------------------------------------------------------------------------
	bool           isNull() const;

	// -------------------------------------------------------------------------
	// Summary:
	// 		设置D是为空
	// -------------------------------------------------------------------------
	void           setNull();

	// -------------------------------------------------------------------------
	// Summary:
	// 		把ID变成一个64 位的整形变量返回
	// -------------------------------------------------------------------------
	inline MxObjectId asOldId() const
	{
		return m_id;
	}

	// -------------------------------------------------------------------------
	// Summary:
	// 		把一个64 位的整形变量设置成ID
	// Parameters:
	// 		oldId	-	id值 
	// Returns:
	// 		如果成功返回Mcad::eOk，如果传递的数据非法则返回Mcad::eInvalidInput
	// -------------------------------------------------------------------------
	McDbObjectId&  setFromOldId(MxObjectId oldId);

	// -------------------------------------------------------------------------
	// Summary:
	// 		ID是否有效
	// -------------------------------------------------------------------------
	bool           isValid() const;

	bool           isObjectEraseSataus();
	
	//:Ignore



	bool           operator <  (const McDbObjectId&) const;
	bool           operator >  (const McDbObjectId&) const;
	bool           operator >= (const McDbObjectId&) const;
	bool           operator <= (const McDbObjectId&) const;
	bool           operator == (const McDbObjectId&) const;
	bool           operator != (const McDbObjectId&) const;

	static const   McDbObjectId  kNull;

	inline void* getPointer()  const {
		return reinterpret_cast<void*>(m_id);
	}
private:
	MxObjectIdDynSize      m_id;
	//:End Ignore
};




 
// -------------------------------------------------------------------------
// Summary:
// 		硬拥有者id
// -------------------------------------------------------------------------
class McDbHardOwnershipId : public McDbObjectId
{
public:
	// -------------------------------------------------------------------------
	// Summary:
	// 		构造函数
	// -------------------------------------------------------------------------
	McDbHardOwnershipId();

	// -------------------------------------------------------------------------
	// Summary:
	// 		构造函数
	// -------------------------------------------------------------------------
	McDbHardOwnershipId(const McDbObjectId&);

	McDbHardOwnershipId& operator =(const McDbHardOwnershipId&);
	McDbHardOwnershipId& operator =(const McDbObjectId&);

	bool           operator != (const McDbObjectId&) const;
	bool           operator == (const McDbObjectId&) const;
};
// -------------------------------------------------------------------------
// Summary:
// 		软拥有者id
// -------------------------------------------------------------------------
class McDbSoftOwnershipId : public McDbObjectId
{
public:
	McDbSoftOwnershipId();
	McDbSoftOwnershipId(const McDbObjectId&);


	McDbSoftOwnershipId& operator =(const McDbSoftOwnershipId&);
	McDbSoftOwnershipId& operator =(const McDbObjectId&);

	bool           operator != (const McDbObjectId&) const;

	bool           operator == (const McDbObjectId&) const;


};

// -------------------------------------------------------------------------
// Summary:
// 		硬指针id
// -------------------------------------------------------------------------
class McDbHardPointerId : public McDbObjectId
{
public:
	McDbHardPointerId();
	McDbHardPointerId(const McDbObjectId&);

	McDbHardPointerId& operator =(const McDbHardPointerId&);
	McDbHardPointerId& operator =(const McDbObjectId&);

	bool           operator != (const McDbObjectId&) const;

	bool           operator == (const McDbObjectId&) const;

};
// -------------------------------------------------------------------------
// Summary:
// 		软指针id
// -------------------------------------------------------------------------
class McDbSoftPointerId : public McDbObjectId
{
public:
	McDbSoftPointerId();
	McDbSoftPointerId(const McDbObjectId&);

	McDbSoftPointerId& operator =(const McDbSoftPointerId&);
	McDbSoftPointerId& operator =(const McDbObjectId&);

	bool           operator != (const McDbObjectId&) const;

	bool           operator == (const McDbObjectId&) const;

};


inline
	McDbHardOwnershipId::McDbHardOwnershipId() {}

inline
	McDbHardOwnershipId::McDbHardOwnershipId(const McDbObjectId& id)
	: McDbObjectId(id) {}


inline
	McDbHardOwnershipId& McDbHardOwnershipId::operator  = (
	const McDbHardOwnershipId& id)
{ McDbObjectId::operator=(id); return *this; }

inline
	McDbHardOwnershipId& McDbHardOwnershipId::operator = (const McDbObjectId& id)
{ McDbObjectId::operator=(id); return *this; }



inline 
	bool McDbHardOwnershipId::operator != (const McDbObjectId& id) const
{ return McDbObjectId::operator!=(id); }



inline 
	bool McDbHardOwnershipId::operator == (const McDbObjectId& id) const
{ return McDbObjectId::operator==(id); }




//////////////////// McDbSoftOwnershipId inlines ////////////////////

inline
	McDbSoftOwnershipId::McDbSoftOwnershipId() {}

inline
	McDbSoftOwnershipId::McDbSoftOwnershipId(const McDbObjectId& id)
	: McDbObjectId(id) {}


inline
	McDbSoftOwnershipId& McDbSoftOwnershipId::operator = (
	const McDbSoftOwnershipId& id)
{ McDbObjectId::operator=(id); return *this; }

inline
	McDbSoftOwnershipId& McDbSoftOwnershipId::operator = (const McDbObjectId& id)
{ McDbObjectId::operator=(id); return *this; }


inline 
	bool McDbSoftOwnershipId::operator != (const McDbObjectId& id) const
{ return McDbObjectId::operator!=(id); }


inline 
	bool McDbSoftOwnershipId::operator == (const McDbObjectId& id) const
{ return McDbObjectId::operator==(id); }




//////////////////// McDbHardPointerId inlines ////////////////////

inline
	McDbHardPointerId::McDbHardPointerId() {}

inline
	McDbHardPointerId::McDbHardPointerId(const McDbObjectId& id)
	: McDbObjectId(id) {}


inline
	McDbHardPointerId& McDbHardPointerId::operator = (
	const McDbHardPointerId& id)
{ McDbObjectId::operator=(id); return *this; }

inline
	McDbHardPointerId& McDbHardPointerId::operator = (const McDbObjectId& id)
{ McDbObjectId::operator=(id); return *this; }


inline 
	bool McDbHardPointerId::operator != (const McDbObjectId& id) const
{ return McDbObjectId::operator!=(id); }


inline 
	bool McDbHardPointerId::operator == (const McDbObjectId& id) const
{ return McDbObjectId::operator==(id); }



//////////////////// McDbSoftPointerId inlines ////////////////////

inline
	McDbSoftPointerId::McDbSoftPointerId() {}

inline
	McDbSoftPointerId::McDbSoftPointerId(const McDbObjectId& id)
	: McDbObjectId(id) {}


inline
	McDbSoftPointerId& McDbSoftPointerId::operator = (const McDbSoftPointerId& id)
{ McDbObjectId::operator=(id); return *this; }

inline
	McDbSoftPointerId& McDbSoftPointerId::operator = (const McDbObjectId& id)
{ McDbObjectId::operator=(id); return *this; }


inline 
	bool McDbSoftPointerId::operator != (const McDbObjectId& id) const
{ return McDbObjectId::operator!=(id); }


inline 
	bool McDbSoftPointerId::operator == (const McDbObjectId& id) const
{ return McDbObjectId::operator==(id); }

typedef McArray<McDbObjectId> McDbObjectIdArray;

typedef mxuint32 McDbIndexId;
