一个symbian 冒险游戏代码

源代码在线查看: object.h

软件大小: 13597 K
上传用户: jun604001464
关键词: symbian 冒险游戏 代码
下载地址: 免注册下载 普通下载 VIP

相关代码

				#ifndef _LANG_OBJECT_H
				#define _LANG_OBJECT_H
				
				
				#include 
				
				
				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
				
				
							

相关资源