194 OSSmartPtr<T>&
operator=(
const OSSmartPtr<T>& rhs);
198 template <
class U1,
class U2>
200 bool operator==(
const OSSmartPtr<U1>& lhs,
const OSSmartPtr<U2>& rhs);
204 template <
class U1,
class U2>
206 bool operator==(
const OSSmartPtr<U1>& lhs, U2* raw_rhs);
210 template <
class U1,
class U2>
212 bool operator==(U1* lhs,
const OSSmartPtr<U2>& raw_rhs);
216 template <
class U1,
class U2>
218 bool operator!=(
const OSSmartPtr<U1>& lhs,
const OSSmartPtr<U2>& rhs);
222 template <
class U1,
class U2>
224 bool operator!=(
const OSSmartPtr<U1>& lhs, U2* raw_rhs);
228 template <
class U1,
class U2>
230 bool operator!=(U1* lhs,
const OSSmartPtr<U2>& raw_rhs);
252 OSSmartPtr<const U>
ConstPtr(
const OSSmartPtr<U>& smart_ptr);
260 bool IsValid(
const OSSmartPtr<U>& smart_ptr);
268 bool IsNull(
const OSSmartPtr<U>& smart_ptr);
298 OSSmartPtr<const U>
ConstPtr(
const OSSmartPtr<U>& smart_ptr);
301 bool IsNull(
const OSSmartPtr<U>& smart_ptr);
304 bool IsValid(
const OSSmartPtr<U>& smart_ptr);
306 template <
class U1,
class U2>
307 bool operator==(
const OSSmartPtr<U1>& lhs,
const OSSmartPtr<U2>& rhs);
309 template <
class U1,
class U2>
310 bool operator==(
const OSSmartPtr<U1>& lhs, U2* raw_rhs);
312 template <
class U1,
class U2>
313 bool operator==(U1* lhs,
const OSSmartPtr<U2>& raw_rhs);
315 template <
class U1,
class U2>
316 bool operator!=(
const OSSmartPtr<U1>& lhs,
const OSSmartPtr<U2>& rhs);
318 template <
class U1,
class U2>
319 bool operator!=(
const OSSmartPtr<U1>& lhs, U2* raw_rhs);
321 template <
class U1,
class U2>
322 bool operator!=(U1* lhs,
const OSSmartPtr<U2>& raw_rhs);
335 const OSReferencedObject* trying_to_use_SmartPtr_with_an_object_that_does_not_inherit_from_ReferencedObject_
337 trying_to_use_SmartPtr_with_an_object_that_does_not_inherit_from_ReferencedObject_ = 0;
351 const ReferencedObject* trying_to_use_SmartPtr_with_an_object_that_does_not_inherit_from_ReferencedObject_
353 trying_to_use_SmartPtr_with_an_object_that_does_not_inherit_from_ReferencedObject_ = 0;
367 const ReferencedObject* trying_to_use_SmartPtr_with_an_object_that_does_not_inherit_from_ReferencedObject_
369 trying_to_use_SmartPtr_with_an_object_that_does_not_inherit_from_ReferencedObject_ = 0;
398 return SetFromRawPtr_(rhs);
405 return SetFromSmartPtr_(rhs);
442 ptr_->ReleaseRef(
this);
443 if (ptr_->ReferenceCount() == 0) {
454 return smart_ptr.ptr_;
458 OSSmartPtr<const U>
ConstPtr(
const OSSmartPtr<U>& smart_ptr)
467 return !
IsNull(smart_ptr);
471 bool IsNull(
const OSSmartPtr<U>& smart_ptr)
473 return (smart_ptr.ptr_ == 0);
477 template <
class U1,
class U2>
488 const void* v_lhs =
static_cast<const void*
>(lhs);
489 const void* v_rhs =
static_cast<const void*
>(rhs);
490 if (v_lhs == v_rhs) {
498 template <
class U1,
class U2>
499 bool operator==(
const OSSmartPtr<U1>& lhs,
const OSSmartPtr<U2>& rhs)
506 template <
class U1,
class U2>
513 template <
class U1,
class U2>
520 template <
class U1,
class U2>
521 bool operator!=(
const OSSmartPtr<U1>& lhs,
const OSSmartPtr<U2>& rhs)
527 template <
class U1,
class U2>
534 template <
class U1,
class U2>
bool ComparePointers(const U1 *lhs, const U2 *rhs)
U * GetRawPtr(const OSSmartPtr< U > &smart_ptr)
bool IsValid(const OSSmartPtr< U > &smart_ptr)
bool operator==(const OSSmartPtr< U1 > &lhs, const OSSmartPtr< U2 > &rhs)
bool IsNull(const OSSmartPtr< U > &smart_ptr)
OSSmartPtr< const U > ConstPtr(const OSSmartPtr< U > &smart_ptr)
bool operator!=(const OSSmartPtr< U1 > &lhs, const OSSmartPtr< U2 > &rhs)
Pseudo-class, from which everything has to inherit that wants to use be registered as a Referencer fo...
Template class for Smart Pointers.
void ReleasePointer_()
Release the currently referenced object.
T & operator*() const
Overloaded dereference operator, allows the user to dereference the contained pointer.
friend U * GetRawPtr(const OSSmartPtr< U > &smart_ptr)
Returns the raw pointer contained.
OSSmartPtr< T > & operator=(T *rhs)
Overloaded equals operator, allows the user to set the value of the OSSmartPtr from a raw pointer.
T * ptr_
Actual raw pointer to the object.
OSSmartPtr< T > & SetFromSmartPtr_(const OSSmartPtr< T > &rhs)
Set the value of the internal raw pointer from an OSSmartPtr, releasing the previously referenced obj...
~OSSmartPtr()
Destructor, automatically decrements the reference count, deletes the object if necessary.
T * operator->() const
Overloaded arrow operator, allows the user to call methods using the contained pointer.
friend bool IsValid(const OSSmartPtr< U > &smart_ptr)
Returns true if the OSSmartPtr is NOT NULL.
OSSmartPtr< T > & SetFromRawPtr_(T *rhs)
Set the value of the internal raw pointer from another raw pointer, releasing the previously referenc...
friend bool operator==(const OSSmartPtr< U1 > &lhs, const OSSmartPtr< U2 > &rhs)
Overloaded equality comparison operator, allows the user to compare the value of two OSSmartPtrs.
OSSmartPtr()
Default constructor, initialized to NULL.
friend bool IsNull(const OSSmartPtr< U > &smart_ptr)
Returns true if the OSSmartPtr is NULL.
friend OSSmartPtr< const U > ConstPtr(const OSSmartPtr< U > &smart_ptr)
Returns a const pointer.
friend bool operator!=(const OSSmartPtr< U1 > &lhs, const OSSmartPtr< U2 > &rhs)
Overloaded in-equality comparison operator, allows the user to compare the value of two OSSmartPtrs.