9 #ifndef CoinSmartPtr_hpp 10 #define CoinSmartPtr_hpp 160 : reference_count_(0)
165 inline void AddRef()
const { ++reference_count_; }
169 mutable int reference_count_;
175 #if COIN_IPOPT_CHECKLEVEL > 2 176 #define IP_DEBUG_SMARTPTR 178 #ifdef IP_DEBUG_SMARTPTR 179 #include "IpDebug.hpp" 341 bool IsNull()
const {
return ptr_ == NULL; }
350 void ReleasePointer_()
354 if (ptr_->ReferenceCount() == 0) {
363 SmartPtr< T > &SetFromRawPtr_(T *rhs)
375 inline SmartPtr< T > &SetFromSmartPtr_(
const SmartPtr< T > &rhs)
377 SetFromRawPtr_(rhs.GetRawPtr());
384 #define dbg_smartptr_verbosity 0 398 (void)SetFromSmartPtr_(copy);
405 (void)SetFromRawPtr_(ptr);
422 #if COIN_COINUTILS_CHECKLEVEL > 0 432 #if COIN_IPOPT_CHECKLEVEL > 0 442 return SetFromRawPtr_(rhs);
450 return SetFromSmartPtr_(rhs);
455 template <
class U1,
class U2 >
460 template <
class U1,
class U2 >
465 template <
class U1,
class U2 >
470 template <
class U1,
class U2 >
475 template <
class U1,
class U2 >
480 template <
class U1,
class U2 >
485 template <
class U1,
class U2 >
494 return static_cast< const void *
>(lhs) == static_cast< const void * >(rhs);
504 template <
class U1,
class U2 >
510 template <
class U1,
class U2 >
516 template <
class U1,
class U2 >
522 template <
class U1,
class U2 >
528 template <
class U1,
class U2 >
534 template <
class U1,
class U2 >
541 #define CoinReferencedObject Coin::ReferencedObject 542 #define CoinSmartPtr Coin::SmartPtr 543 #define CoinComparePointers Coin::ComparePointers bool operator!=(const Coin::SmartPtr< U1 > &lhs, const Coin::SmartPtr< U2 > &rhs)
bool IsNull() const
Returns true if the SmartPtr is NULL.
T * GetRawPtr() const
Returns the raw pointer contained.
~SmartPtr()
Destructor, automatically decrements the reference count, deletes the object if necessary.
bool IsValid() const
Returns true if the SmartPtr is NOT NULL.
bool ComparePointers(const U1 *lhs, const U2 *rhs)
Template class for Smart Pointers.
SmartPtr()
Default constructor, initialized to NULL.
SmartPtr< T > & operator=(T *rhs)
Overloaded equals operator, allows the user to set the value of the SmartPtr from a raw pointer...
bool operator==(const Coin::SmartPtr< U1 > &lhs, const Coin::SmartPtr< U2 > &rhs)
SmartPtr(const SmartPtr< T > ©)
Copy constructor, initialized from copy.
T * operator->() const
Overloaded arrow operator, allows the user to call methods using the contained pointer.
int ReferenceCount() const
SmartPtr(T *ptr)
Constructor, initialized from T* ptr.
friend bool operator==(const SmartPtr< U1 > &lhs, const SmartPtr< U2 > &rhs)
Overloaded equality comparison operator, allows the user to compare the value of two SmartPtrs...
SmartPtr< T > & operator=(const SmartPtr< T > &rhs)
Overloaded equals operator, allows the user to set the value of the SmartPtr from another SmartPtr...
T & operator*() const
Overloaded dereference operator, allows the user to dereference the contained pointer.
friend bool operator!=(const SmartPtr< U1 > &lhs, const SmartPtr< U2 > &rhs)
Overloaded in-equality comparison operator, allows the user to compare the value of two SmartPtrs...
virtual ~ReferencedObject()