9 #ifndef __IPSMARTPTR_HPP__
10 #define __IPSMARTPTR_HPP__
15 #if COIN_IPOPT_CHECKLEVEL > 2
16 # define IP_DEBUG_SMARTPTR
19 # if defined(__GNUC__)
20 # define IPOPT_UNUSED __attribute__((unused))
175 #define ipopt_dbg_smartptr_verbosity 0
215 SmartPtr<T>&
operator=(
const SmartPtr<T>& rhs);
221 SmartPtr<T>&
operator=(
const SmartPtr<U>& rhs);
225 template <
class U1,
class U2>
227 bool operator==(
const SmartPtr<U1>& lhs,
const SmartPtr<U2>& rhs);
231 template <
class U1,
class U2>
233 bool operator==(
const SmartPtr<U1>& lhs, U2* raw_rhs);
237 template <
class U1,
class U2>
239 bool operator==(U1* lhs,
const SmartPtr<U2>& raw_rhs);
243 template <
class U1,
class U2>
245 bool operator!=(
const SmartPtr<U1>& lhs,
const SmartPtr<U2>& rhs);
249 template <
class U1,
class U2>
251 bool operator!=(
const SmartPtr<U1>& lhs, U2* raw_rhs);
255 template <
class U1,
class U2>
257 bool operator!=(U1* lhs,
const SmartPtr<U2>& raw_rhs);
263 bool operator<(const SmartPtr<U>& lhs,
const SmartPtr<U>& rhs);
280 U*
GetRawPtr(
const SmartPtr<U>& smart_ptr);
285 SmartPtr<const U>
ConstPtr(
const SmartPtr<U>& smart_ptr);
293 bool IsValid(
const SmartPtr<U>& smart_ptr);
301 bool IsNull(
const SmartPtr<U>& smart_ptr);
339 template <
class U1,
class U2>
342 template <
class U1,
class U2>
345 template <
class U1,
class U2>
348 template <
class U1,
class U2>
351 template <
class U1,
class U2>
354 template <
class U1,
class U2>
365 #ifdef IP_DEBUG_SMARTPTR
381 #ifdef IP_DEBUG_SMARTPTR
399 #ifdef IP_DEBUG_SMARTPTR
416 #ifdef IP_DEBUG_SMARTPTR
430 #ifdef IP_DEBUG_SMARTPTR
441 #ifdef IP_DEBUG_SMARTPTR
446 #if COIN_IPOPT_CHECKLEVEL > 0
457 #ifdef IP_DEBUG_SMARTPTR
462 #if COIN_IPOPT_CHECKLEVEL > 0
473 #ifdef IP_DEBUG_SMARTPTR
477 return SetFromRawPtr_(rhs);
484 #ifdef IP_DEBUG_SMARTPTR
486 "SmartPtr<T>& SmartPtr<T>::operator=(const SmartPtr<T>& rhs)",
490 return SetFromSmartPtr_(rhs);
498 #ifdef IP_DEBUG_SMARTPTR
500 "SmartPtr<T>& SmartPtr<T>::operator=(const SmartPtr<U>& rhs)",
511 #ifdef IP_DEBUG_SMARTPTR
530 #ifdef IP_DEBUG_SMARTPTR
532 "SmartPtr<T>& SmartPtr<T>::SetFromSmartPtr_(const SmartPtr<T>& rhs)",
545 #ifdef IP_DEBUG_SMARTPTR
547 "void SmartPtr<T>::ReleasePointer()",
552 ptr_->ReleaseRef(
this);
553 if (ptr_->ReferenceCount() == 0)
562 #ifdef IP_DEBUG_SMARTPTR
564 "T* GetRawPtr(const SmartPtr<T>& smart_ptr)",
568 return smart_ptr.
ptr_;
581 return !
IsNull(smart_ptr);
587 #ifdef IP_DEBUG_SMARTPTR
589 "bool IsNull(const SmartPtr<T>& smart_ptr)",
593 return (smart_ptr.
ptr_ == 0);
597 template <
class U1,
class U2>
600 #ifdef IP_DEBUG_SMARTPTR
602 "bool ComparePtrs(const U1* lhs, const U2* rhs)",
613 return v_lhs == v_rhs;
616 template <
class U1,
class U2>
619 #ifdef IP_DEBUG_SMARTPTR
621 "bool operator==(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs)",
630 template <
class U1,
class U2>
633 #ifdef IP_DEBUG_SMARTPTR
635 "bool operator==(SmartPtr<U1>& lhs, U2* rhs)",
643 template <
class U1,
class U2>
646 #ifdef IP_DEBUG_SMARTPTR
648 "bool operator==(U1* raw_lhs, SmartPtr<U2>& rhs)",
656 template <
class U1,
class U2>
659 #ifdef IP_DEBUG_SMARTPTR
661 "bool operator!=(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs)",
669 template <
class U1,
class U2>
672 #ifdef IP_DEBUG_SMARTPTR
674 "bool operator!=(SmartPtr<U1>& lhs, U2* rhs)",
682 template <
class U1,
class U2>
685 #ifdef IP_DEBUG_SMARTPTR
687 "bool operator!=(U1* raw_lhs, SmartPtr<U2>& rhs)",
698 #ifdef IP_DEBUG_REFERENCED
710 return lhs.
ptr_ < rhs.ptr_;
719 template <
class T>
bool
722 return !( rhs < lhs );
725 template <
class T>
bool
728 return !( lhs < rhs );
732 #undef ipopt_dbg_smartptr_verbosity
~SmartPtr()
Destructor, automatically decrements the reference count, deletes the object if necessary.
bool IsValid(const SmartPtr< U > &smart_ptr)
SmartPtr< T > & operator=(T *rhs)
Overloaded equals operator, allows the user to set the value of the SmartPtr from a raw pointer...
SmartPtr< T > & SetFromRawPtr_(T *rhs)
Set the value of the internal raw pointer from another raw pointer, releasing the previously referenc...
#define DBG_START_METH(__func_name, __verbose_level)
bool IsNull(const SmartPtr< U > &smart_ptr)
bool operator>(const SmartPtr< T > &lhs, const SmartPtr< T > &rhs)
bool operator>=(const SmartPtr< T > &lhs, const SmartPtr< T > &rhs)
bool ComparePointers(const U1 *lhs, const U2 *rhs)
Template class for Smart Pointers.
bool operator!=(const SmartPtr< U1 > &lhs, const SmartPtr< U2 > &rhs)
U * GetRawPtr(const SmartPtr< U > &smart_ptr)
T * ptr_
Actual raw pointer to the object.
Psydo-class, from which everything has to inherit that wants to use be registered as a Referencer for...
#define ipopt_dbg_smartptr_verbosity
#define DBG_START_FUN(__func_name, __verbose_level)
friend bool IsNull(const SmartPtr< U > &smart_ptr)
Returns true if the SmartPtr is NULL.
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...
friend U * GetRawPtr(const SmartPtr< U > &smart_ptr)
Returns the raw pointer contained.
SmartPtr< const U > ConstPtr(const SmartPtr< U > &smart_ptr)
SmartPtr()
Default constructor, initialized to NULL.
void ReleasePointer_()
Release the currently referenced object.
SmartPtr< T > & SetFromSmartPtr_(const SmartPtr< T > &rhs)
Set the value of the internal raw pointer from a SmartPtr, releasing the previously referenced object...
friend bool IsValid(const SmartPtr< U > &smart_ptr)
Returns true if the SmartPtr is NOT NULL.
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...
friend SmartPtr< const U > ConstPtr(const SmartPtr< U > &smart_ptr)
Returns a const pointer.
T & operator*() const
Overloaded dereference operator, allows the user to dereference the contained pointer.
T * operator->() const
Overloaded arrow operator, allows the user to call methods using the contained pointer.
bool operator==(const SmartPtr< U1 > &lhs, const SmartPtr< U2 > &rhs)
void swap(SmartPtr< T > &a, SmartPtr< T > &b)