7#ifndef __IPSMARTPTR_HPP__
8#define __IPSMARTPTR_HPP__
16# error "don't have header file for stddef"
23#if IPOPT_CHECKLEVEL > 2
24# define IP_DEBUG_SMARTPTR
177#define ipopt_dbg_smartptr_verbosity 0
246 template<
class U1,
class U2>
256 template<
class U1,
class U2>
266 template<
class U1,
class U2>
276 template<
class U1,
class U2>
286 template<
class U1,
class U2>
296 template<
class U1,
class U2>
410template<
class U1,
class U2>
416template<
class U1,
class U2>
422template<
class U1,
class U2>
428template<
class U1,
class U2>
433template<
class U1,
class U2>
439template<
class U1,
class U2>
451#ifdef IP_DEBUG_SMARTPTR
467#ifdef IP_DEBUG_SMARTPTR
487#ifdef IP_DEBUG_SMARTPTR
506#ifdef IP_DEBUG_SMARTPTR
522#ifdef IP_DEBUG_SMARTPTR
532#ifdef IP_DEBUG_SMARTPTR
537#if IPOPT_CHECKLEVEL > 0
547#ifdef IP_DEBUG_SMARTPTR
552#if IPOPT_CHECKLEVEL > 0
564#ifdef IP_DEBUG_SMARTPTR
568 return SetFromRawPtr_(rhs);
576#ifdef IP_DEBUG_SMARTPTR
578 "SmartPtr<T>& SmartPtr<T>::operator=(const SmartPtr<T>& rhs)",
582 return SetFromSmartPtr_(rhs);
591#ifdef IP_DEBUG_SMARTPTR
593 "SmartPtr<T>& SmartPtr<T>::operator=(const SmartPtr<U>& rhs)",
605#ifdef IP_DEBUG_SMARTPTR
628#ifdef IP_DEBUG_SMARTPTR
630 "SmartPtr<T>& SmartPtr<T>::SetFromSmartPtr_(const SmartPtr<T>& rhs)",
642#ifdef IP_DEBUG_SMARTPTR
644 "void SmartPtr<T>::ReleasePointer()",
650 ptr_->ReleaseRef(
this);
651 if( ptr_->ReferenceCount() == 0 )
664#ifdef IP_DEBUG_SMARTPTR
666 "T* GetRawPtr(const SmartPtr<T>& smart_ptr)",
670 return smart_ptr.
ptr_;
687 return !
IsNull(smart_ptr);
695#ifdef IP_DEBUG_SMARTPTR
697 "bool IsNull(const SmartPtr<T>& smart_ptr)",
701 return (smart_ptr.
ptr_ == 0);
704template<
class U1,
class U2>
710#ifdef IP_DEBUG_SMARTPTR
712 "bool ComparePtrs(const U1* lhs, const U2* rhs)",
723 return v_lhs == v_rhs;
726template<
class U1,
class U2>
732#ifdef IP_DEBUG_SMARTPTR
734 "bool operator==(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs)",
743template<
class U1,
class U2>
749#ifdef IP_DEBUG_SMARTPTR
751 "bool operator==(SmartPtr<U1>& lhs, U2* rhs)",
759template<
class U1,
class U2>
765#ifdef IP_DEBUG_SMARTPTR
767 "bool operator==(U1* raw_lhs, SmartPtr<U2>& rhs)",
775template<
class U1,
class U2>
781#ifdef IP_DEBUG_SMARTPTR
783 "bool operator!=(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs)",
791template<
class U1,
class U2>
797#ifdef IP_DEBUG_SMARTPTR
799 "bool operator!=(SmartPtr<U1>& lhs, U2* rhs)",
807template<
class U1,
class U2>
813#ifdef IP_DEBUG_SMARTPTR
815 "bool operator!=(U1* raw_lhs, SmartPtr<U2>& rhs)",
829#ifdef IP_DEBUG_REFERENCED
834 std::swap(a.prt_, b.
ptr_);
874#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
Storing the reference count of all the smart pointers that currently reference it.
Pseudo-class, from which everything has to inherit that wants to use be registered as a Referencer fo...
Template class for Smart Pointers.
T & operator*() const
Overloaded dereference operator, allows the user to dereference the contained pointer.
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 U * GetRawPtr(const SmartPtr< U > &smart_ptr)
Returns the raw pointer contained.
friend SmartPtr< const U > ConstPtr(const SmartPtr< U > &smart_ptr)
Returns a const pointer.
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 and 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...
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.
This file contains a base class for all exceptions and a set of macros to help with exceptions.
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)