⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 object.h

📁 这个是symbian下的一个蛮庞大的3D游戏源代码!对于学习3D开发的人有很大的帮助!
💻 H
字号:
#ifndef _LANG_OBJECT_H
#define _LANG_OBJECT_H


#include <lang/Ptr.h>


namespace lang
{


/**
 * Object class has functionality for reference counting.
 * If an Object is created in stack then special care
 * must be taken that the object reference count 
 * is not affected anywhere as it will result in crash
 * when the object goes out of scope in the stack.
 * 
 * @ingroup lang
 */
class Object
{
public:
	/** 
	 * Initializes reference count to zero. 
	 */
	Object();

	/** 
	 * Initializes reference count to zero. 
	 */
	Object( const Object& );

	/** 
	 * Ensures that the reference count is zero. 
	 */
	virtual ~Object();

	/** 
	 * Does nothing. 
	*/
	Object&			operator=( const Object& )		{return *this;}

	/** 
	 * Increments reference count by one. 
	 * DO NOT USE THIS METHOD ON OBJECTS
	 * WHICH ARE CREATED IN STACK!
	 */
	void			addReference()					{++m_refs;}

	/** 
	 * Decrements reference count and 
	 * uses operator delete to the object when
	 * the count reaches zero. 
	 * DO NOT USE THIS METHOD ON OBJECTS
	 * WHICH ARE CREATED IN STACK!
	 */
	void			release()						{if ( --m_refs == 0 ) delete this;}

	/**
	 * Returns number of references left.
	 * For DEBUG use only.
	 */
	int				references() const				{return m_refs;}

private:
	int				m_refs;
};


} // lang


#endif // _LANG_OBJECT_H


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -