Cocos2d-x  v4
Ref Class Reference

Ref is used for reference count management. More...

Inherited by Acceleration, Action, ActionManager, Animation, Animation3D, AnimationCache, AnimationCurve< componentSize >, AnimationFrame, Buffer, CommandBuffer, DepthStencilState, Device, Program, ProgramCache, RenderPipeline, ShaderCache, ShaderModule, TextureBackend, Bone3D, BundleReader, CameraBackgroundBrush, Configuration, Director, Event, EventDispatcher, EventListener, GLView, GridBase, GroupCommandManager, LuaStack, Material, Mesh, MeshIndexData, MeshSkin, MeshVertexData, HttpRequest, HttpResponse, SIOClient, Node, Pass, PhysicsShape, PointArray, RenderState, Scheduler, ScriptHandlerEntry, Skeleton3D, SpriteFrame, SpriteFrameCache, Technique, Texture2D, TextureAtlas, TextureCache, TextureCube, TMXObjectGroup, Touch, LayoutManager, LayoutParameter, RichElement, and VertexAttribBinding.

Public Member Functions

void retain ()
 Retains the ownership. More...
 
void release ()
 Releases the ownership immediately. More...
 
Ref * autorelease ()
 Releases the ownership sometime soon automatically. More...
 
unsigned int getReferenceCount () const
 Returns the Ref's current reference count. More...
 
virtual ~Ref ()
 Destructor. More...
 

Public Attributes

unsigned int _ID
 object id, ScriptSupport need public _ID
 
int _luaID
 Lua reference id.
 
void * _scriptObject
 scriptObject, support for swift
 
bool _rooted
 When true, it means that the object was already rooted.
 

Detailed Description

Ref is used for reference count management.

If a class inherits from Ref, then it is easy to be shared in different places. @js NA

Constructor & Destructor Documentation

◆ ~Ref()

virtual ~Ref ( )
virtual

Destructor.

@js NA @lua NA

Member Function Documentation

◆ retain()

void retain ( )

Retains the ownership.

This increases the Ref's reference count.

See also
release, autorelease @js NA

◆ release()

void release ( )

Releases the ownership immediately.

This decrements the Ref's reference count.

If the reference count reaches 0 after the decrement, this Ref is destructed.

See also
retain, autorelease @js NA

◆ autorelease()

Ref* autorelease ( )

Releases the ownership sometime soon automatically.

This decrements the Ref's reference count at the end of current autorelease pool block.

If the reference count reaches 0 after the decrement, this Ref is destructed.

Returns
The Ref itself.
See also
AutoreleasePool, retain, release @js NA @lua NA

◆ getReferenceCount()

unsigned int getReferenceCount ( ) const

Returns the Ref's current reference count.

Returns
The Ref's reference count. @js NA

The documentation for this class was generated from the following file: