#pragma once

#include "Mcdb.h"
#include "McDbObjectId.h"

//:Ignore

class McRxClass;
class  McDbSubentId
{
public:
	McDbSubentId();
	McDbSubentId(McDb::SubentType type, int index);
	McDbSubentId(McRxClass* pTypeClass, int index);

	bool               operator ==(const McDbSubentId& id) const;
	bool               operator !=(const McDbSubentId& id) const;

	McDb::SubentType   type () const;
	void               setType(McDb::SubentType);
	McRxClass*         typeClass () const;
	void               setTypeClass(McRxClass* pClass);
	int                index() const;
	void               setIndex(int);

private:
	McDb::SubentType mType;
	int              mIndex;
	McRxClass*       mpTypeClass;
};


class  McDbFullSubentPath
{
public:
	McDbFullSubentPath();
	McDbFullSubentPath(McDb::SubentType type, int index);

	void                objectIds(McDbObjectIdArray& objectIds) const;
	McDbObjectIdArray&  objectIds();
	const McDbObjectIdArray&  objectIds() const;
	const McDbSubentId  subentId () const;
	McDbSubentId&       subentId ();

public:
	static const McDbFullSubentPath ARXDLL kNullSubent;
private:                            
	McDbObjectIdArray mObjectIds;
	McDbSubentId      mSubentId;
};

const int kMxNullSubentIndex = 0;


// inlines
inline McDb::SubentType
	McDbSubentId::type () const
{
	return mType;
}

inline void
	McDbSubentId::setType(McDb::SubentType type)
{
	mType = type;
	if (mType != McDb::kClassSubentType)
		mpTypeClass = NULL;
}

inline int
	McDbSubentId::index() const
{
	return mIndex;
}

inline void  
	McDbSubentId::setIndex(int index)
{
	mIndex = index;
}

inline McRxClass* 
	McDbSubentId::typeClass() const
{
	return mpTypeClass;
}

inline void
	McDbSubentId::setTypeClass(McRxClass* pTypeClass)
{
	mpTypeClass = pTypeClass;
	if (mpTypeClass != NULL)
		mType = McDb::kClassSubentType;
}

inline
	McDbSubentId::McDbSubentId() 
	: mType(McDb::kNullSubentType), mIndex(kMxNullSubentIndex), mpTypeClass(NULL)
{
}

inline
	McDbSubentId::McDbSubentId(McDb::SubentType t, int i) 
	: mType(t), mIndex(i), mpTypeClass(NULL)
{
}

inline
	McDbSubentId::McDbSubentId(McRxClass* pTypeClass, int i) 
	: mType(McDb::kClassSubentType), mIndex(i), mpTypeClass(pTypeClass)
{
}

inline bool
	McDbSubentId::operator ==(const McDbSubentId& id) const
{
	return ((mIndex == id.mIndex) 
		&& (mType == id.mType) 
		&& (mpTypeClass == id.mpTypeClass));
}


inline bool
	McDbSubentId::operator !=(const McDbSubentId& id) const
{
	return ((mIndex != id.mIndex) 
		|| (mType != id.mType)
		|| (mpTypeClass != id.mpTypeClass));
}

//

inline
	McDbFullSubentPath::McDbFullSubentPath() 
{
}

inline
	McDbFullSubentPath::McDbFullSubentPath(McDb::SubentType type, int index)
	: mSubentId(type, index)
{
}

inline void
	McDbFullSubentPath::objectIds(McDbObjectIdArray& objectIds) const
{
	objectIds = mObjectIds;
}

inline McDbObjectIdArray&
	McDbFullSubentPath::objectIds()
{
	return mObjectIds;
}

inline const McDbObjectIdArray&
	McDbFullSubentPath::objectIds() const
{
	return mObjectIds;
}

inline const McDbSubentId
	McDbFullSubentPath::subentId () const
{
	return mSubentId;
}

inline McDbSubentId&
	McDbFullSubentPath::subentId ()
{
	return mSubentId;
}

//:End Ignore