object.h
来自「这个是symbian下的一个蛮庞大的3D游戏源代码!对于学习3D开发的人有很大的」· C头文件 代码 · 共 77 行
H
77 行
#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 + =
减小字号Ctrl + -
显示快捷键?