9 #ifndef __IPSMARTPTR_HPP__ 10 #define __IPSMARTPTR_HPP__ 18 # error "don't have header file for stddef" 25 #if COIN_IPOPT_CHECKLEVEL > 2 26 # define IP_DEBUG_SMARTPTR 29 # if defined(__GNUC__) 30 # define IPOPT_UNUSED __attribute__((unused)) 185 #define ipopt_dbg_smartptr_verbosity 0 225 SmartPtr<T>&
operator=(
const SmartPtr<T>& rhs);
231 SmartPtr<T>&
operator=(
const SmartPtr<U>& rhs);
235 template <
class U1,
class U2>
237 bool operator==(
const SmartPtr<U1>& lhs,
const SmartPtr<U2>& rhs);
241 template <
class U1,
class U2>
243 bool operator==(
const SmartPtr<U1>& lhs, U2* raw_rhs);
247 template <
class U1,
class U2>
249 bool operator==(U1* lhs,
const SmartPtr<U2>& raw_rhs);
253 template <
class U1,
class U2>
255 bool operator!=(
const SmartPtr<U1>& lhs,
const SmartPtr<U2>& rhs);
259 template <
class U1,
class U2>
261 bool operator!=(
const SmartPtr<U1>& lhs, U2* raw_rhs);
265 template <
class U1,
class U2>
267 bool operator!=(U1* lhs,
const SmartPtr<U2>& raw_rhs);
273 bool operator<(const SmartPtr<U>& lhs,
const SmartPtr<U>& rhs);
290 U*
GetRawPtr(
const SmartPtr<U>& smart_ptr);
295 SmartPtr<const U>
ConstPtr(
const SmartPtr<U>& smart_ptr);
303 bool IsValid(
const SmartPtr<U>& smart_ptr);
311 bool IsNull(
const SmartPtr<U>& smart_ptr);
349 template <
class U1,
class U2>
352 template <
class U1,
class U2>
355 template <
class U1,
class U2>
358 template <
class U1,
class U2>
361 template <
class U1,
class U2>
364 template <
class U1,
class U2>
375 #ifdef IP_DEBUG_SMARTPTR 391 #ifdef IP_DEBUG_SMARTPTR 399 (void) SetFromSmartPtr_(copy);
409 #ifdef IP_DEBUG_SMARTPTR 417 (void) SetFromSmartPtr_(
GetRawPtr(copy));
426 #ifdef IP_DEBUG_SMARTPTR 434 (void) SetFromRawPtr_(ptr);
440 #ifdef IP_DEBUG_SMARTPTR 451 #ifdef IP_DEBUG_SMARTPTR 456 #if COIN_IPOPT_CHECKLEVEL > 0 467 #ifdef IP_DEBUG_SMARTPTR 472 #if COIN_IPOPT_CHECKLEVEL > 0 483 #ifdef IP_DEBUG_SMARTPTR 487 return SetFromRawPtr_(rhs);
494 #ifdef IP_DEBUG_SMARTPTR 496 "SmartPtr<T>& SmartPtr<T>::operator=(const SmartPtr<T>& rhs)",
500 return SetFromSmartPtr_(rhs);
508 #ifdef IP_DEBUG_SMARTPTR 510 "SmartPtr<T>& SmartPtr<T>::operator=(const SmartPtr<U>& rhs)",
521 #ifdef IP_DEBUG_SMARTPTR 540 #ifdef IP_DEBUG_SMARTPTR 542 "SmartPtr<T>& SmartPtr<T>::SetFromSmartPtr_(const SmartPtr<T>& rhs)",
555 #ifdef IP_DEBUG_SMARTPTR 557 "void SmartPtr<T>::ReleasePointer()",
562 ptr_->ReleaseRef(
this);
563 if (ptr_->ReferenceCount() == 0)
572 #ifdef IP_DEBUG_SMARTPTR 574 "T* GetRawPtr(const SmartPtr<T>& smart_ptr)",
578 return smart_ptr.
ptr_;
591 return !
IsNull(smart_ptr);
597 #ifdef IP_DEBUG_SMARTPTR 599 "bool IsNull(const SmartPtr<T>& smart_ptr)",
603 return (smart_ptr.
ptr_ == 0);
607 template <
class U1,
class U2>
610 #ifdef IP_DEBUG_SMARTPTR 612 "bool ComparePtrs(const U1* lhs, const U2* rhs)",
623 return v_lhs == v_rhs;
626 template <
class U1,
class U2>
629 #ifdef IP_DEBUG_SMARTPTR 631 "bool operator==(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs)",
640 template <
class U1,
class U2>
643 #ifdef IP_DEBUG_SMARTPTR 645 "bool operator==(SmartPtr<U1>& lhs, U2* rhs)",
653 template <
class U1,
class U2>
656 #ifdef IP_DEBUG_SMARTPTR 658 "bool operator==(U1* raw_lhs, SmartPtr<U2>& rhs)",
666 template <
class U1,
class U2>
669 #ifdef IP_DEBUG_SMARTPTR 671 "bool operator!=(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs)",
679 template <
class U1,
class U2>
682 #ifdef IP_DEBUG_SMARTPTR 684 "bool operator!=(SmartPtr<U1>& lhs, U2* rhs)",
692 template <
class U1,
class U2>
695 #ifdef IP_DEBUG_SMARTPTR 697 "bool operator!=(U1* raw_lhs, SmartPtr<U2>& rhs)",
708 #ifdef IP_DEBUG_REFERENCED 720 return lhs.
ptr_ < rhs.ptr_;
729 template <
class T>
bool 732 return !( rhs < lhs );
735 template <
class T>
bool 738 return !( lhs < rhs );
742 #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.
U * GetRawPtr(const SmartPtr< U > &smart_ptr)
bool operator==(U1 *lhs, const SmartPtr< U2 > &raw_rhs)
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...
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)
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)
void swap(SmartPtr< T > &a, SmartPtr< T > &b)