7 #ifndef __IPSMARTPTR_HPP__
8 #define __IPSMARTPTR_HPP__
13 #if COIN_IPOPT_CHECKLEVEL > 2
14 # define IP_DEBUG_SMARTPTR
17 # if defined(__GNUC__)
18 # define IPOPT_UNUSED __attribute__((unused))
174 #define ipopt_dbg_smartptr_verbosity 0
183 const SmartPtr<T>& copy
189 const SmartPtr<U>& copy
228 const SmartPtr<T>& rhs
237 const SmartPtr<U>& rhs);
242 template<
class U1,
class U2>
245 const SmartPtr<U1>& lhs,
246 const SmartPtr<U2>& rhs
252 template<
class U1,
class U2>
255 const SmartPtr<U1>& lhs,
262 template<
class U1,
class U2>
266 const SmartPtr<U2>& raw_rhs
272 template<
class U1,
class U2>
275 const SmartPtr<U1>& lhs,
276 const SmartPtr<U2>& rhs
282 template<
class U1,
class U2>
285 const SmartPtr<U1>& lhs,
292 template<
class U1,
class U2>
296 const SmartPtr<U2>& raw_rhs
305 const SmartPtr<U>& lhs,
306 const SmartPtr<U>& rhs
325 const SmartPtr<U>& smart_ptr
331 const SmartPtr<U>& smart_ptr
342 const SmartPtr<U>& smart_ptr
353 const SmartPtr<U>& smart_ptr
406 template<
class U1,
class U2>
412 template<
class U1,
class U2>
418 template<
class U1,
class U2>
424 template<
class U1,
class U2>
429 template<
class U1,
class U2>
435 template<
class U1,
class U2>
447 #ifdef IP_DEBUG_SMARTPTR
462 #ifdef IP_DEBUG_SMARTPTR
481 #ifdef IP_DEBUG_SMARTPTR
499 #ifdef IP_DEBUG_SMARTPTR
514 #ifdef IP_DEBUG_SMARTPTR
524 #ifdef IP_DEBUG_SMARTPTR
529 #if COIN_IPOPT_CHECKLEVEL > 0
539 #ifdef IP_DEBUG_SMARTPTR
544 #if COIN_IPOPT_CHECKLEVEL > 0
556 #ifdef IP_DEBUG_SMARTPTR
560 return SetFromRawPtr_(rhs);
568 #ifdef IP_DEBUG_SMARTPTR
570 "SmartPtr<T>& SmartPtr<T>::operator=(const SmartPtr<T>& rhs)",
574 return SetFromSmartPtr_(rhs);
583 #ifdef IP_DEBUG_SMARTPTR
585 "SmartPtr<T>& SmartPtr<T>::operator=(const SmartPtr<U>& rhs)",
597 #ifdef IP_DEBUG_SMARTPTR
620 #ifdef IP_DEBUG_SMARTPTR
622 "SmartPtr<T>& SmartPtr<T>::SetFromSmartPtr_(const SmartPtr<T>& rhs)",
634 #ifdef IP_DEBUG_SMARTPTR
636 "void SmartPtr<T>::ReleasePointer()",
642 ptr_->ReleaseRef(
this);
643 if( ptr_->ReferenceCount() == 0 )
655 #ifdef IP_DEBUG_SMARTPTR
657 "T* GetRawPtr(const SmartPtr<T>& smart_ptr)",
661 return smart_ptr.
ptr_;
678 return !
IsNull(smart_ptr);
686 #ifdef IP_DEBUG_SMARTPTR
688 "bool IsNull(const SmartPtr<T>& smart_ptr)",
692 return (smart_ptr.
ptr_ == 0);
695 template<
class U1,
class U2>
701 #ifdef IP_DEBUG_SMARTPTR
703 "bool ComparePtrs(const U1* lhs, const U2* rhs)",
714 return v_lhs == v_rhs;
717 template<
class U1,
class U2>
723 #ifdef IP_DEBUG_SMARTPTR
725 "bool operator==(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs)",
734 template<
class U1,
class U2>
740 #ifdef IP_DEBUG_SMARTPTR
742 "bool operator==(SmartPtr<U1>& lhs, U2* rhs)",
750 template<
class U1,
class U2>
756 #ifdef IP_DEBUG_SMARTPTR
758 "bool operator==(U1* raw_lhs, SmartPtr<U2>& rhs)",
766 template<
class U1,
class U2>
772 #ifdef IP_DEBUG_SMARTPTR
774 "bool operator!=(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs)",
782 template<
class U1,
class U2>
788 #ifdef IP_DEBUG_SMARTPTR
790 "bool operator!=(SmartPtr<U1>& lhs, U2* rhs)",
798 template<
class U1,
class U2>
804 #ifdef IP_DEBUG_SMARTPTR
806 "bool operator!=(U1* raw_lhs, SmartPtr<U2>& rhs)",
820 #ifdef IP_DEBUG_REFERENCED
865 #undef ipopt_dbg_smartptr_verbosity
~SmartPtr()
Destructor, automatically decrements the reference count and 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...
bool operator<(const SmartPtr< T > &lhs, const SmartPtr< T > &rhs)
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)
friend bool operator<(const SmartPtr< U > &lhs, const SmartPtr< U > &rhs)
Overloaded less-than comparison operator, allows the user to compare the value of two SmartPtrs...
Template class for Smart Pointers.
Storing the reference count of all the smart pointers that currently reference it.
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.
Pseudo-class, from which everything has to inherit that wants to use be registered as a Referencer fo...
#define ipopt_dbg_smartptr_verbosity
#define DBG_START_FUN(__func_name, __verbose_level)
bool operator<=(const SmartPtr< T > &lhs, const SmartPtr< T > &rhs)
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)