carb::ObjectPtr
Defined in carb/IObject.h
- 
template<class T>
 class ObjectPtr
- Smart pointer type for ref counting - IObject.- It automatically controls reference count for the underlying - IObjectpointer.- Public Types - Public Functions - 
inline ObjectPtr()
- Default Constructor. 
 - 
inline explicit ObjectPtr(T *object)
- Constructor. - Parameters
- object – The raw pointer to an object. If not - nullptr, it will be “borrowed”; that is, the reference count will be increased as long as- *thiscontains it.
 
 - 
inline ObjectPtr(T *object, InitPolicy policy)
- Constructor. - Parameters
- object – The raw pointer to an object. 
- policy – Directive on whether the reference count should be increased or not. 
 
 
 - 
inline ObjectPtr(const ObjectPtr<T> &other)
- Copy constructor. - Always increases the reference count. - Parameters
- other – The smart pointer from which to copy a reference. 
 
 - 
template<class U>
 inline ObjectPtr(const ObjectPtr<U> &other)
- Copy constructor. - Always increases the reference count. - Parameters
- other – The smart pointer from which to copy a reference. 
 
 - 
inline ObjectPtr(ObjectPtr<T> &&other)
- Move constructor. - Steals the reference count from - otherand leaves it empty.- Parameters
- other – The smart pointer from which to steal a reference. 
 
 - 
template<class U>
 inline ObjectPtr(ObjectPtr<U> &&other)
- Move constructor. - Steals the reference count from - otherand leaves it empty.- Parameters
- other – The smart pointer from which to steal a reference. 
 
 - 
inline ~ObjectPtr()
- Destructor. 
 - 
inline T *get() const
- Converts the smart pointer to a raw pointer. - Returns
- The raw pointer referenced by the smart pointer. May be - nullptr.
 
 - 
inline T *operator->() const
- Pointer dereference operator. - Returns
- The raw pointer referenced by the smart pointer. 
 
 - 
inline explicit operator bool() const
- Boolean conversion operator. - Returns
- trueif the smart pointer is not empty;- falseif the smart pointer is empty.
 
 - 
inline T *const *getAddressOf() const
- Returns the address of the internal reference. - Returns
- The address of the internal reference. 
 
 - 
inline T **getAddressOf()
- Returns the address of the internal reference. - Returns
- The address of the internal reference. 
 
 - 
inline T **releaseAndGetAddressOf()
- Helper function to release any current reference and return the address of the internal reference pointer. - Returns
- The address of the internal reference. 
 
 - 
inline T *detach()
- Resets this smart pointer to - nullptrand returns the previously reference object without releasing the held reference.- Returns
- The previously referenced object. 
 
 - 
inline void attach(T *other)
- Releases the reference on any held object and instead steals the given object. - Parameters
- other – The object to steal a reference to. 
 
 - 
inline ObjectPtr &operator=(decltype(nullptr))
- Assignment to nullptr. - Releases any previously held reference. - Returns
- *this 
 
 - 
inline ObjectPtr &operator=(T *other)
- Releases any previously held reference and copies a reference to - other.- Parameters
- other – The object to reference. 
- Returns
- *this 
 
 - 
template<typename U>
 inline ObjectPtr &operator=(U *other)
- Assignment to nullptr. - Releases any previously held reference. - Returns
- *this 
 
 - 
inline ObjectPtr &operator=(const ObjectPtr &other)
- Assignment to nullptr. - Releases any previously held reference. - Returns
- *this 
 
 - 
template<class U>
 inline ObjectPtr &operator=(const ObjectPtr<U> &other)
- Assignment to nullptr. - Releases any previously held reference. - Returns
- *this 
 
 - 
inline ObjectPtr &operator=(ObjectPtr &&other)
- Releases any previously held reference and steals the reference from - other.- Parameters
- other – The reference to steal. Will be swapped with *this. 
- Returns
- *this 
 
 - 
template<class U>
 inline ObjectPtr &operator=(ObjectPtr<U> &&other)
- Releases any previously held reference and steals the reference from - other.- Parameters
- other – The reference to steal. Will be swapped with *this. 
- Returns
- *this 
 
 - 
template<class U>
 inline bool operator==(const ObjectPtr<U> &other) const
- Compares equality of this object and another one of the same type. - Parameters
- other – [in] The other object to compare this one to. 
- Returns
- trueif the two objects identify the same underlying object. Returns- falseotherwise.
 
 - 
template<class U>
 inline bool operator!=(const ObjectPtr<U> &other) const
- Compares inequality of this object and another one of the same type. - Parameters
- other – [in] The other object to compare this one to. 
- Returns
- trueif the two objects do not identify the same underlying object. Returns- falseotherwise.
 
 
- 
inline ObjectPtr()