www.pudn.com > DirectX source.zip > CObject.h


/*! 
	@file : CObject.h 
	Contains the header of class CObject. 
 
	@author Sarmad Kh. Abdulla 
*/ 
//------------------------------------------------------------------------------ 
 
 
//! The link tree class. 
/*! This class provides a link tree mechanism to the classes derived from it. */ 
class CObject 
{ 
// construction, destruction 
public: 
	//! Initializes the link tree variables of this object 
	CObject(); 
	//! Removes the object from the tree 
	virtual ~CObject(); 
 
// The virtual functions 
public: 
	//! Destroy the object 
	virtual void Destroy( void ) {} 
	//! Delete all the child objects 
	void DeleteChilds( void ); 
 
// Link tree related functions 
public: 
	//! Attach an object as a child to this object 
	void AttachChild( CObject & object ); 
	//! Detach a child object from this object's childs list 
	void DetachChild( CObject & object ); 
	//! Get the next sibling of this object. 
	CObject * GetNextSibling( void ) 
	{ 
		return pNextSibling; 
	} 
	//! Get the previous sibling of this object. 
	CObject * GetPrevSibling( void ) 
	{ 
		return pPrevSibling; 
	} 
	//! Get the owner of this object 
	CObject * GetOwner( void ) 
	{ 
		return pOwner; 
	} 
	//! Get a pointer to the first child of this object 
	CObject * GetFirstChild( void ) 
	{ 
		return pFirstChild; 
	} 
	//! Get a pointer to the last child of this object 
	CObject * GetLastChild( void ) 
	{ 
		return pLastChild; 
	} 
 
private: 
	// these two functions are not implemented. They are provided to prevent the user 
	// from copying objects. 
	CObject( const CObject & srcobject ); 
	void operator =( const CObject & srcobject ); 
 
// member variables 
protected: 
	CObject * pOwner;		//!< Pointer to the owner of this object 
	CObject * pPrevSibling;	//!< Pointer to the previous sibling 
	CObject * pNextSibling;	//!< Pointer to the next sibling 
	CObject * pFirstChild;	//!< Pointer to the first child 
	CObject * pLastChild;	//!< Pointer to the last child 
};