SourcePro® 2024.1 |
SourcePro® API Reference Guide |
Simplifies the use of pointers that refer to objects on the heap, automatically destroying the object when the pointer object is itself destroyed. More...
#include <rw/pointer/RWTOnlyPointer.h>
Public Types | |
typedef Body | BodyType |
Public Types inherited from RWTPointer< Body > | |
typedef Body | BodyType |
Public Member Functions | |
RWTOnlyPointer (Body *bodyP=rwnil) | |
RWTOnlyPointer (const RWTOnlyPointer< Body > &second) | |
RWTOnlyPointer (RWStaticCtor) | |
~RWTOnlyPointer (void) | |
operator Body * (void) | |
Body & | operator* (void) const |
Body * | operator-> (void) const |
RWTOnlyPointer< Body > & | operator= (Body *ptr) |
RWTOnlyPointer< Body > & | operator= (const RWTOnlyPointer< Body > &second) |
Public Member Functions inherited from RWTPointer< Body > | |
~RWTPointer (void) | |
bool | isValid (void) const |
bool | operator!= (const Body *ptr) const |
bool | operator!= (const RWTPointer< Body > &second) const |
bool | operator== (const Body *ptr) const |
bool | operator== (const RWTPointer< Body > &second) const |
void | swapWith (RWTPointer< Body > &second) |
void | validate (void) const |
Protected Member Functions | |
Body * | orphan (void) |
void | transfer (Body *bodyP=rwnil) |
Protected Member Functions inherited from RWTPointer< Body > | |
RWTPointer (Body *bodyP) | |
RWTPointer (const RWTPointer< Body > &second) | |
RWTPointer (RWStaticCtor) | |
RWTPointer (void) | |
Body * | get (void) const |
RWTPointer< Body > & | operator= (Body *ptr) |
RWTOnlyPointer is an abstraction that simplifies the use of pointers referring to objects (that is, bodies) on the heap. It doesn't do reference counting on the body; rather, it is based on the idea of strict ownership semantics. Strict ownership means that if the assignment operator or the copy constructor is called, then the right-hand instance is invalidated (its body pointer is set to rwnil), and the left-hand instance assumes responsibility for deleting the body.
This class is useful for ensuring the recovery of dynamically allocated memory, especially in the presence of exceptions. This class provides functionality equivalent to that provided by the C++ Standard Library class std::auto_ptr.
typedef Body RWTOnlyPointer< Body >::BodyType |
The type of the body.
|
inline |
Special constructor that performs no initialization. Throws no exceptions.
|
inline |
Assumes responsibility for a new body. This pointer manages an instance parameter bodyP. Throws no exceptions.
|
inline |
Assumes responsibility for another handle's body.
|
inline |
Deletes the current body.
|
inline |
Body pointer conversion operator for the handle (required for handle conversions). Gives up responsibility for deleting the body.
|
inline |
Pointer dereference operator. Dereferences the handle to get a reference to the body. Throws the exception RWTHRInvalidPointer if the pointer is not valid.
|
inline |
Pointer dereference operator. This operator should always be used to dereference the handle as it first validates the pointer. If the pointer is not valid, throws an RWTHRInvalidPointer exception.
|
inline |
Assigns a new pointer value to the handle (required for handle conversions). Throws no exceptions.
|
inline |
Assumes responsibility for another handle's body.
|
inlineprotected |
Relinquishes control over the current body (if any).
|
inlineprotected |
Deletes the current body (if any), and assumes control of another body (if any).
Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |