12 #ifndef OSSMARTPTR_HPP 13 #define OSSMARTPTR_HPP 198 template <
class U1,
class U2>
204 template <
class U1,
class U2>
210 template <
class U1,
class U2>
216 template <
class U1,
class U2>
222 template <
class U1,
class U2>
228 template <
class U1,
class U2>
288 void ReleasePointer_();
306 template <
class U1,
class U2>
309 template <
class U1,
class U2>
312 template <
class U1,
class U2>
315 template <
class U1,
class U2>
318 template <
class U1,
class U2>
321 template <
class U1,
class U2>
333 #ifdef CHECK_SMARTPTR 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;
349 #ifdef CHECK_SMARTPTR 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;
356 (void) SetFromSmartPtr_(copy);
365 #ifdef CHECK_SMARTPTR 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;
372 (void) SetFromRawPtr_(ptr);
398 return SetFromRawPtr_(rhs);
405 return SetFromSmartPtr_(rhs);
442 ptr_->ReleaseRef(
this);
443 if (ptr_->ReferenceCount() == 0) {
454 return smart_ptr.ptr_;
467 return !
IsNull(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>
506 template <
class U1,
class U2>
513 template <
class U1,
class U2>
520 template <
class U1,
class U2>
527 template <
class U1,
class U2>
534 template <
class U1,
class U2>
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...
Pseudo-class, from which everything has to inherit that wants to use be registered as a Referencer fo...
bool ComparePointers(const U1 *lhs, const U2 *rhs)
T * operator->() const
Overloaded arrow operator, allows the user to call methods using the contained pointer.
T & operator*() const
Overloaded dereference operator, allows the user to dereference the contained pointer.
bool IsValid(const OSSmartPtr< U > &smart_ptr)
bool operator!=(const OSSmartPtr< U1 > &lhs, const OSSmartPtr< U2 > &rhs)
U * GetRawPtr(const OSSmartPtr< U > &smart_ptr)
bool operator==(const OSSmartPtr< U1 > &lhs, const OSSmartPtr< U2 > &rhs)
friend bool IsValid(const OSSmartPtr< U > &smart_ptr)
Returns true if the OSSmartPtr is NOT NULL.
friend U * GetRawPtr(const OSSmartPtr< U > &smart_ptr)
Returns the raw pointer contained.
~OSSmartPtr()
Destructor, automatically decrements the reference count, deletes the object if necessary.
bool IsNull(const OSSmartPtr< U > &smart_ptr)
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...
Template class for Smart Pointers.
OSSmartPtr< T > & operator=(T *rhs)
Overloaded equals operator, allows the user to set the value of the OSSmartPtr from a raw pointer...
OSSmartPtr< const U > ConstPtr(const OSSmartPtr< U > &smart_ptr)
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.