30#ifndef _utility_ref_RefPtr_
31#define _utility_ref_RefPtr_
66 template <
class Other>
99 template <
class Other>
107 ptr_ =
dynamic_cast<T*
>(p);
108 if(p != NULL &&
ptr_ == NULL) {
110 (std::string(
"RefPtr::cast(Other): Failed dynamic cast from ")
111 + std::string(
typeid(Other).name()) + std::string(
" to ") +
112 std::string(
typeid(
Type).name()));
123 template <
class Other>
133 if(p != NULL &&
ptr_ == NULL) {
135 (std::string(
"RefPtr::cast(Other): Failed dynamic cast from ")
136 + std::string(
typeid(Other).name()) + std::string(
" to ") +
137 std::string(
typeid(
Type).name()));
148 std::cerr <<
"RefPtr<" <<
typeid(T).name()
149 <<
">::operator->() const invoked on a null pointer\n";
159 std::cerr <<
"RefPtr<" <<
typeid(T).name()
160 <<
">::operator*() const invoked on a null pointer\n";
202 template <
class Other>
213 ptr_->reference_grab();
221 if(
ptr_->reference_release() == 0)
Definition MyException.h:40
void grab()
Grab a reference to the current pointee if it is not NULL.
Definition RefPtr.h:211
RefPtr< T > & operator=(const RefPtr< T > &p)
Assign the value of this RefPtr to the pointee of the given RefPtr.
Definition RefPtr.h:87
RefPtr(const RefPtr< T > &p)
Construct a new RefPtr and initialize to the given RefPtr pointee.
Definition RefPtr.h:60
bool operator<(const RefPtr< Other > &p) const
Convenience routine to sort pointer values in standard containers.
Definition RefPtr.h:203
T * ptr_
Definition RefPtr.h:208
RefPtr()
Construct a new RefPtr and initialize the pointee to NULL.
Definition RefPtr.h:52
bool operator!=(const RefPtr< T > &p) const
Test inequality.
Definition RefPtr.h:192
bool operator==(const RefPtr< T > &p) const
Compare the value of this pointee with the pointee of the given RefPtr.
Definition RefPtr.h:182
bool operator==(const T *p) const
Compare the pointee of this RefPtr with the given pointer.
Definition RefPtr.h:177
RefPtr< T > & cast(Other *p)
Definition RefPtr.h:100
T & operator*() const
Definition RefPtr.h:157
T * operator->() const
Definition RefPtr.h:146
bool operator!=(const T *p) const
Test inequality.
Definition RefPtr.h:187
const T * pointee() const
Return the pointee of this RefPtr in a const context.
Definition RefPtr.h:172
void release()
Definition RefPtr.h:219
~RefPtr()
Destroy this RefPtr.
Definition RefPtr.h:72
RefPtr(T *p)
Construct a new RefPtr and initialize the pointee as given.
Definition RefPtr.h:55
T * pointee()
Return the pointee of this RefPtr.
Definition RefPtr.h:167
RefPtr< T > & cast(RefPtr< Other > p)
Definition RefPtr.h:124
RefPtr(RefPtr< Other > p)
Definition RefPtr.h:67
RefPtr< T > & operator=(T *p)
Assign the value of this RefPtr to the given pointee.
Definition RefPtr.h:77
bool operator<(const RefPtr< T > &p) const
Convenience routine to sort pointer values in standard containers.
Definition RefPtr.h:197
T Type
Make the typename that this pointer holds accessible to other objects.
Definition RefPtr.h:49