#include <CTBownedObjPtr.hxx>
Inheritance diagram for CTBownedObjPtr:
Public Methods | |
CTBownedObjPtr () | |
CTBownedObjPtr (CTBownedObjPtr< T > &rhs) | |
CTBownedObjPtr (T *p) | |
~CTBownedObjPtr () | |
T * | Release () |
bool | Equal (const CTBownedObjPtr< T > &rhs) const |
void | ToStream (ostream &os) const |
CTBownedObjPtr< T > & | operator= (CTBownedObjPtr< T > &rhs) |
CTBownedObjPtr< T > & | operator= (T *rhs) |
T & | operator * () const |
T * | operator-> () const |
bool | operator! () const |
operator void * () const | |
Protected Attributes | |
T * | mp |
Related Functions | |
(Note that these are not member functions.) | |
bool | operator== (const CTBownedObjPtr< T > &lhs, const CTBownedObjPtr< T > &rhs) |
ostream & | operator<< (ostream &os, const CTBownedObjPtr< T > &obj) |
This is the base class of a set of `smart pointers' which maintain a one-to-one correspondence between a pointer and an object on the heap. The copy constructor and the assignment operator are defined as grabs, they transfer the object reference from the source pointer and clear the source pointer afterwards. The controled object is deleted when the controling pointer is destroyed or assigned with another value.
For obvious reasons there is no operator T *()
method. But sometimes it is necessary to have an explicit pointer to the controlled object. Use &(*p)
at your own risk, it can compromise the lifetime control of CTBownedObjPtr
.
T
. It doesn't require a copy constructor and can thus be used for abstract base classes.~T()
Definition at line 17 of file CTBownedObjPtr.hxx.
|
Default constructor.
Definition at line 47 of file CTBownedObjPtr.icc. |
|
Copy constructor (grab controlled object of The reference to the object controlled by rhs is transfered and the pointer rhs is zeroed. Definition at line 59 of file CTBownedObjPtr.icc. |
|
Construct from pointer. The object refered to by p becomes the controlled object. Definition at line 72 of file CTBownedObjPtr.icc. |
|
Destructor. The controlled object will be deleted. Definition at line 83 of file CTBownedObjPtr.icc. |
|
Release controlled object.
Returns the pointer to the controlled object and clears the Definition at line 96 of file CTBownedObjPtr.icc. |
|
Returns
Definition at line 107 of file CTBownedObjPtr.icc. Referenced by operator==().
|
|
ostream insertion.
Definition at line 116 of file CTBownedObjPtr.icc. |
|
Grab controlled object of The reference to the object controlled by rhs is transfered and the pointer rhs is zeroed. Definition at line 130 of file CTBownedObjPtr.icc. Referenced by CTBclonedObjPtr::operator=().
|
|
Make
Reimplemented in CTBclonedObjPtr. Definition at line 144 of file CTBownedObjPtr.icc. |
|
Dereference pointer (access controlled object).
Definition at line 155 of file CTBownedObjPtr.icc. |
|
Access member of controlled object.
Definition at line 164 of file CTBownedObjPtr.icc. |
|
Returns
Definition at line 172 of file CTBownedObjPtr.icc. |
|
Returns non-zero pointer if pointer not null.
Definition at line 181 of file CTBownedObjPtr.icc. |
|
Returns
Note, that the Definition at line 198 of file CTBownedObjPtr.icc. |
|
ostream insertion operator.
Definition at line 211 of file CTBownedObjPtr.icc. |
|
pointer to controlled object.
Definition at line 41 of file CTBownedObjPtr.hxx. |