template<typename T>
class cocos2d::RefPtr< T >
Wrapper class which maintains a strong reference to a cocos2dx cocos2d::Ref* type object.
Similar in concept to a boost smart pointer.
Enables the use of the RAII idiom with Cocos2dx objects and helps automate some of the more mundane tasks of pointer initialization and cleanup.
The class itself is modelled on C++ 11 std::shared_ptr, and trys to keep some of the methods and functionality consistent with std::shared_ptr.
void weakAssign |
( |
const RefPtr< T > & |
other | ) |
|
|
inline |
This function assigns to this RefPtr<T> but does not increase the reference count of the object pointed to.
Useful for assigning an object created through the 'new' operator to a RefPtr<T>. Basically used in scenarios where the RefPtr<T> has the initial ownership of the object.
E.G: RefPtr<cocos2d::Image> image; image.weakAssign(new cocos2d::Image());
Instead of: RefPtr<cocos2d::Image> image; image = new cocos2d::Image(); image->release(); // Required because new'd object already has a reference count of '1'.
var weakAssign |
( |
var |
other | ) |
|
|
inline |
This function assigns to this RefPtr<T> but does not increase the reference count of the object pointed to.
Useful for assigning an object created through the 'new' operator to a RefPtr<T>. Basically used in scenarios where the RefPtr<T> has the initial ownership of the object.
E.G: RefPtr<cocos2d::Image> image; image.weakAssign(new cocos2d::Image());
Instead of: RefPtr<cocos2d::Image> image; image = new cocos2d::Image(); image->release(); // Required because new'd object already has a reference count of '1'.
local weakAssign |
( |
local |
other | ) |
|
|
inline |
This function assigns to this RefPtr<T> but does not increase the reference count of the object pointed to.
Useful for assigning an object created through the 'new' operator to a RefPtr<T>. Basically used in scenarios where the RefPtr<T> has the initial ownership of the object.
E.G: RefPtr<cocos2d::Image> image; image.weakAssign(new cocos2d::Image());
Instead of: RefPtr<cocos2d::Image> image; image = new cocos2d::Image(); image->release(); // Required because new'd object already has a reference count of '1'.