#include <reference.h>
Public Member Functions | |
Reference (T *_pointer=NULL) | |
Create a reference to the object pointed to by the given pointer. | |
Reference (const Reference< T > &other) | |
A copy constructor. | |
Reference & | operator= (T *_ptr) |
Assigns the pointer this instance of Reference holds. | |
Reference & | operator= (const Reference< T > &other) |
Have this reference the object held by other. | |
T * | operator-> () const |
Return the underlying pointer. | |
operator bool () const | |
Convert the the reference to a boolean, which is true if the underlying object is not NULL. | |
bool | operator== (T *_ptr) const |
Check whether this holds the given pointer. | |
bool | operator!= (T *_ptr) const |
Check whether this holds a difference pointer than the given pointer. | |
bool | operator== (const Reference< T > &other) const |
Check whether this holds the same object as other does. | |
bool | operator!= (const Reference< T > &other_) const |
Check whether this holds a difference object than other does. | |
bool | operator< (T *_ptr) const |
Compere this with the given pointer. | |
bool | operator< (const Reference< T > &other) |
Compare the pointer this holds with the one other holds. | |
virtual | ~Reference () |
Destroy the reference by setting the pointer it holds to NULL. | |
T * | get_pointer () |
Return the underlying pointer. | |
Private Attributes | |
T * | pointer_ |
the pointer to a reference-counted object. |
Reference holds a pointer to objects of class ReferenceCounted. When you assign such a pointer to Reference, the reference count is automatically increased. Also, when the pointer Reference holds changes, Reference automatically decreases the reference count of the old pointer, thereby facilitating automatic destruction of the object.
Reference behaves like other "smart pointer" objects in C++ such as boost::shared_ptr
. You assign, compare, and use the ->
operator on Reference.
Create a reference to the object pointed to by the given pointer.
_pointer | a pointer to a reference-counted object or NULL. It is defaulted to NULL. |
A copy constructor.
Notes that this constructor increases the reference count of the object other holds by one.
Destroy the reference by setting the pointer it holds to NULL.
This would cause the reference count to the held object to be decremented, thereby facilitating automatic desctruction of the held object.
T* Reference< T >::get_pointer | ( | ) | [inline] |
Return the underlying pointer.
Reference< T >::operator bool | ( | ) | const [inline] |
Convert the the reference to a boolean, which is true if the underlying object is not NULL.
Check whether this holds a difference object than other does.
bool Reference< T >::operator!= | ( | T * | _ptr | ) | const [inline] |
Check whether this holds a difference pointer than the given pointer.
T* Reference< T >::operator-> | ( | ) | const [inline] |
Return the underlying pointer.
Use this method to access the underlying object's fields or invoking methods.
Compare the pointer this holds with the one other holds.
bool Reference< T >::operator< | ( | T * | _ptr | ) | const [inline] |
Compere this with the given pointer.
Have this reference the object held by other.
Assigns the pointer this instance of Reference holds.
The method also automatically decreases the reference of the old object held if it is neither NULL nor equal to to the new object being assigned.
Check whether this holds the same object as other does.
bool Reference< T >::operator== | ( | T * | _ptr | ) | const [inline] |
Check whether this holds the given pointer.