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>
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;
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;
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>
~OSSmartPtr()
Destructor, automatically decrements the reference count, deletes the object if necessary.
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...
bool ComparePointers(const U1 *lhs, const U2 *rhs)
bool IsValid(const OSSmartPtr< U > &smart_ptr)
Template class for Smart Pointers.
bool operator==(const BCP_obj_change &ch0, const BCP_obj_change &ch1)
OSSmartPtr< T > & SetFromSmartPtr_(const OSSmartPtr< T > &rhs)
Set the value of the internal raw pointer from an OSSmartPtr, releasing the previously referenced obj...
OSSmartPtr< T > & operator=(T *rhs)
Overloaded equals operator, allows the user to set the value of the OSSmartPtr from a raw pointer...
void ReleasePointer_()
Release the currently referenced object.
friend bool IsNull(const OSSmartPtr< U > &smart_ptr)
Returns true if the OSSmartPtr is NULL.
bool IsNull(const OSSmartPtr< U > &smart_ptr)
OSSmartPtr< const U > ConstPtr(const OSSmartPtr< U > &smart_ptr)
U * GetRawPtr(const OSSmartPtr< U > &smart_ptr)
OSSmartPtr< T > & SetFromRawPtr_(T *rhs)
Set the value of the internal raw pointer from another raw pointer, releasing the previously referenc...
T * ptr_
Actual raw pointer to the object.
T & operator*() const
Overloaded dereference operator, allows the user to dereference the contained pointer.
bool operator!=(const BCP_obj_change &ch0, const BCP_obj_change &ch1)
friend U * GetRawPtr(const OSSmartPtr< U > &smart_ptr)
Returns the raw pointer contained.
OSSmartPtr()
Default constructor, initialized to NULL.
friend bool IsValid(const OSSmartPtr< U > &smart_ptr)
Returns true if the OSSmartPtr is NOT NULL.
friend OSSmartPtr< const U > ConstPtr(const OSSmartPtr< U > &smart_ptr)
Returns a const pointer.
Pseudo-class, from which everything has to inherit that wants to use be registered as a Referencer fo...
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...
T * operator->() const
Overloaded arrow operator, allows the user to call methods using the contained pointer.