SAMRAI::tbox::ConstPointer< TYPE > Class Template Reference
#include <source/toolbox/memory/ConstPointer.h>
Inheritance diagram for SAMRAI::tbox::ConstPointer< TYPE >:
[legend]List of all members.
Detailed Description
template<class TYPE>
class SAMRAI::tbox::ConstPointer< TYPE >
Class ConstPointer<TYPE> defines a smart const pointer to TYPE. It frees the user from explicitly deleting and tracking aliases for object pointers. It manages all reference counting and deallocation of the pointer (even if the data was originally allocated from a memory arena). When the reference count on a ConstPointer<TYPE> object goes to zero, the object is automatically deallocated. A block with a references count and arena pointer is allocated for all non-NULL pointers. These reference counted blocks are freed at the end of the lifetime of the pointer.
Const pointers can be created from either const or non-const pointers. The non-const and const pointer classes have been designed so that an attempted conversion from a const pointer into a non-const pointer causes a compile-time error.
Class ConstPointer<TYPE> performs type-checking when assigning pointers of different TYPEs. If a bad type conversion is performed, then the destination pointer is set to NULL.
- See also:
- tbox::Array
tbox::ConstPointerBase
tbox::ReferenceCounter
tbox::PointerBase
tbox::Pointer
Constructor & Destructor Documentation
|
The default constructor creates a null pointer. |
|
Create a smart pointer with value ptr. If managed is true, then deallocation of the object pointed to by ptr will be taken care of by the smart pointer. This form assumes the pointer was allocated using the standard new operator. |
|
Create a smart pointer for which the data was allocated from pool. When the pointer is destroyed, the object is deallocated from the specified memory pool. |
|
The pointer const constructor creates a smart pointer reference aliased to the argument. |
|
Create a pointer by attempting to type-cast the argument to TYPE. If the type-cast fails, then the destination pointer will be set to NULL. |
|
The pointer destructor frees the pointer data if the reference count drops to zero. The object is deallocated from the memory pool (if it was specified in the constructor call). |
Member Function Documentation
|
Smart pointer assignment. The left hand side points to the right hand side and the reference count is incremented by one. |
|
Create a managed smart pointer with value ptr. The object pointed to by ptr will be deallocated via delete when the reference count goes to zero. |
|
Attempt to convert the argument pointer to a ConstPointer<TYPE>. If the type conversion fails, then the destination pointer will be set to NULL. |
|
Check whether two smart pointers point to the same object. |
|
Check whether two smart pointers point to different objects. |
|
Delegate member operations to the pointed-to object. C++ defines the ``->'' operator in a funny way to support delegation. The statement ptr->foo() acts as if ptr where actually a pointer to an object with member function foo() instead of a class that holds that pointer. |
|
Dereference the smart pointer. The pointer returned is a const pointer to the object. |
|
Implicit conversion of the smart pointer to the pointed-to object. The pointer returned is a const pointer to the object. |
|
Explicitly convert the smart pointer to the pointed-to object. The pointer returned is a const pointer to the object. |
|
Check whether the smart pointer points to NULL. |
|
Return true if the pointer is non-NULL. |
|
Return true if the pointer is NULL and false otherwise. This operator mimics the semantics of !p applied to a (regular) pointer p. |
|
Set the smart pointer to NULL. |
|
Return a pointer to the internal reference counter. This routine should not be called by the casual user. |
The documentation for this class was generated from the following files:
Generated on Fri Dec 2 11:33:21 2005 for SAMRAI by
1.4.2