7 #ifndef __IPSMARTPTR_HPP__ 8 #define __IPSMARTPTR_HPP__ 13 #if IPOPT_CHECKLEVEL > 2 14 # define IP_DEBUG_SMARTPTR 167 #define ipopt_dbg_smartptr_verbosity 0 176 const SmartPtr<T>& copy
182 const SmartPtr<U>& copy
221 const SmartPtr<T>& rhs
231 const SmartPtr<U>& rhs);
236 template<
class U1,
class U2>
239 const SmartPtr<U1>& lhs,
240 const SmartPtr<U2>& rhs
246 template<
class U1,
class U2>
249 const SmartPtr<U1>& lhs,
256 template<
class U1,
class U2>
260 const SmartPtr<U2>& raw_rhs
266 template<
class U1,
class U2>
269 const SmartPtr<U1>& lhs,
270 const SmartPtr<U2>& rhs
276 template<
class U1,
class U2>
279 const SmartPtr<U1>& lhs,
286 template<
class U1,
class U2>
290 const SmartPtr<U2>& raw_rhs
299 const SmartPtr<U>& lhs,
300 const SmartPtr<U>& rhs
319 const SmartPtr<U>& smart_ptr
325 const SmartPtr<U>& smart_ptr
336 const SmartPtr<U>& smart_ptr
347 const SmartPtr<U>& smart_ptr
400 template<
class U1,
class U2>
406 template<
class U1,
class U2>
412 template<
class U1,
class U2>
418 template<
class U1,
class U2>
423 template<
class U1,
class U2>
429 template<
class U1,
class U2>
441 #ifdef IP_DEBUG_SMARTPTR 457 #ifdef IP_DEBUG_SMARTPTR 467 (void) SetFromSmartPtr_(copy);
477 #ifdef IP_DEBUG_SMARTPTR 487 (void) SetFromSmartPtr_(
GetRawPtr(copy));
496 #ifdef IP_DEBUG_SMARTPTR 506 (void) SetFromRawPtr_(ptr);
512 #ifdef IP_DEBUG_SMARTPTR 522 #ifdef IP_DEBUG_SMARTPTR 527 #if IPOPT_CHECKLEVEL > 0 537 #ifdef IP_DEBUG_SMARTPTR 542 #if IPOPT_CHECKLEVEL > 0 554 #ifdef IP_DEBUG_SMARTPTR 558 return SetFromRawPtr_(rhs);
566 #ifdef IP_DEBUG_SMARTPTR 568 "SmartPtr<T>& SmartPtr<T>::operator=(const SmartPtr<T>& rhs)",
572 return SetFromSmartPtr_(rhs);
581 #ifdef IP_DEBUG_SMARTPTR 583 "SmartPtr<T>& SmartPtr<T>::operator=(const SmartPtr<U>& rhs)",
595 #ifdef IP_DEBUG_SMARTPTR 618 #ifdef IP_DEBUG_SMARTPTR 620 "SmartPtr<T>& SmartPtr<T>::SetFromSmartPtr_(const SmartPtr<T>& rhs)",
632 #ifdef IP_DEBUG_SMARTPTR 634 "void SmartPtr<T>::ReleasePointer()",
640 ptr_->ReleaseRef(
this);
641 if( ptr_->ReferenceCount() == 0 )
653 #ifdef IP_DEBUG_SMARTPTR 655 "T* GetRawPtr(const SmartPtr<T>& smart_ptr)",
659 return smart_ptr.
ptr_;
676 return !
IsNull(smart_ptr);
684 #ifdef IP_DEBUG_SMARTPTR 686 "bool IsNull(const SmartPtr<T>& smart_ptr)",
690 return (smart_ptr.
ptr_ == 0);
693 template<
class U1,
class U2>
699 #ifdef IP_DEBUG_SMARTPTR 701 "bool ComparePtrs(const U1* lhs, const U2* rhs)",
712 return v_lhs == v_rhs;
715 template<
class U1,
class U2>
721 #ifdef IP_DEBUG_SMARTPTR 723 "bool operator==(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs)",
732 template<
class U1,
class U2>
738 #ifdef IP_DEBUG_SMARTPTR 740 "bool operator==(SmartPtr<U1>& lhs, U2* rhs)",
748 template<
class U1,
class U2>
754 #ifdef IP_DEBUG_SMARTPTR 756 "bool operator==(U1* raw_lhs, SmartPtr<U2>& rhs)",
764 template<
class U1,
class U2>
770 #ifdef IP_DEBUG_SMARTPTR 772 "bool operator!=(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs)",
780 template<
class U1,
class U2>
786 #ifdef IP_DEBUG_SMARTPTR 788 "bool operator!=(SmartPtr<U1>& lhs, U2* rhs)",
796 template<
class U1,
class U2>
802 #ifdef IP_DEBUG_SMARTPTR 804 "bool operator!=(U1* raw_lhs, SmartPtr<U2>& rhs)",
818 #ifdef IP_DEBUG_REFERENCED 863 #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...
This file contains a base class for all exceptions and a set of macros to help with exceptions...
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)
bool operator==(U1 *lhs, const SmartPtr< U2 > &raw_rhs)
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...
T & operator*() const
Overloaded dereference operator, allows the user to dereference the contained pointer.
#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 arrow operator, allows the user to call methods using the contained pointer.
bool operator!=(U1 *lhs, const SmartPtr< U2 > &raw_rhs)
bool operator==(const SmartPtr< U1 > &lhs, const SmartPtr< U2 > &rhs)
void swap(SmartPtr< T > &a, SmartPtr< T > &b)