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
235 template <
class U1,
class U2>
241 template <
class U1,
class U2>
247 template <
class U1,
class U2>
253 template <
class U1,
class U2>
259 template <
class U1,
class U2>
265 template <
class U1,
class U2>
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
409 #ifdef IP_DEBUG_SMARTPTR
426 #ifdef IP_DEBUG_SMARTPTR
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
729 template <
class T>
bool
732 return !( rhs < lhs );
735 template <
class T>
bool
738 return !( lhs < rhs );
742 #undef ipopt_dbg_smartptr_verbosity
#define DBG_START_FUN(__func_name, __verbose_level)
#define DBG_START_METH(__func_name, __verbose_level)
#define ipopt_dbg_smartptr_verbosity
Psydo-class, from which everything has to inherit that wants to use be registered as a Referencer for...
Template class for Smart Pointers.
T & operator*() const
Overloaded dereference operator, allows the user to dereference the contained pointer.
friend U * GetRawPtr(const SmartPtr< U > &smart_ptr)
Returns the raw pointer contained.
friend bool operator!=(const SmartPtr< U1 > &lhs, U2 *raw_rhs)
Overloaded in-equality comparison operator, allows the user to compare the value of a SmartPtr with a...
SmartPtr< T > & SetFromSmartPtr_(const SmartPtr< T > &rhs)
Set the value of the internal raw pointer from a SmartPtr, releasing the previously referenced object...
SmartPtr()
Default constructor, initialized to NULL.
SmartPtr(const SmartPtr< U > ©)
Copy constructor, initialized from copy of type U.
friend bool operator!=(U1 *lhs, const SmartPtr< U2 > &raw_rhs)
Overloaded in-equality comparison operator, allows the user to compare the value of a SmartPtr with a...
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 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.
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 bool operator==(U1 *lhs, const SmartPtr< U2 > &raw_rhs)
Overloaded equality comparison operator, allows the user to compare the value of a raw pointer with a...
friend bool operator==(const SmartPtr< U1 > &lhs, U2 *raw_rhs)
Overloaded equality comparison operator, allows the user to compare the value of a SmartPtr with a ra...
SmartPtr(T *ptr)
Constructor, initialized from T* ptr.
SmartPtr< T > & operator=(const SmartPtr< T > &rhs)
Overloaded equals operator, allows the user to set the value of the SmartPtr from another SmartPtr.
~SmartPtr()
Destructor, automatically decrements the reference count, deletes the object if necessary.
SmartPtr< T > & operator=(T *rhs)
Overloaded equals operator, allows the user to set the value of the SmartPtr from a raw pointer.
friend bool IsValid(const SmartPtr< U > &smart_ptr)
Returns true if the SmartPtr is NOT NULL.
void ReleasePointer_()
Release the currently referenced object.
SmartPtr< T > & SetFromRawPtr_(T *rhs)
Set the value of the internal raw pointer from another raw pointer, releasing the previously referenc...
friend SmartPtr< const U > ConstPtr(const SmartPtr< U > &smart_ptr)
Returns a const pointer.
SmartPtr< T > & operator=(const SmartPtr< U > &rhs)
Overloaded equals operator, allows the user to set the value of the SmartPtr from another SmartPtr of...
SmartPtr(const SmartPtr< T > ©)
Copy constructor, initialized from copy of type T.
T * operator->() const
Overloaded arrow operator, allows the user to call methods using the contained pointer.
T * ptr_
Actual raw pointer to the object.
SmartPtr< const U > ConstPtr(const SmartPtr< U > &smart_ptr)
bool IsValid(const SmartPtr< U > &smart_ptr)
U * GetRawPtr(const SmartPtr< U > &smart_ptr)
bool ComparePointers(const U1 *lhs, const U2 *rhs)
bool operator<=(const SmartPtr< T > &lhs, const SmartPtr< T > &rhs)
bool operator!=(const SmartPtr< U1 > &lhs, const SmartPtr< U2 > &rhs)
void swap(SmartPtr< T > &a, SmartPtr< T > &b)
bool operator>(const SmartPtr< T > &lhs, const SmartPtr< T > &rhs)
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 operator==(const SmartPtr< U1 > &lhs, const SmartPtr< U2 > &rhs)