SourcePro® 2024.1 |
SourcePro® API Reference Guide |
Defines a reference-counted pointer that provides reference counting semantics for types that do not directly support reference counting. More...
#include <rw/pointer/RWTCountingPointer.h>
Public Member Functions | |
RWTCountingPointer (Body *bodyP=rwnil) | |
RWTCountingPointer (const RWTCountingPointer< Body, Counter > &second) | |
RWTCountingPointer (RWStaticCtor) | |
~RWTCountingPointer (void) | |
Body & | operator* (void) const |
Body * | operator-> (void) const |
RWTCountingPointer< Body, Counter > & | operator= (Body *bodyP) |
RWTCountingPointer< Body, Counter > & | operator= (const RWTCountingPointer< Body, Counter > &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 |
Additional Inherited Members | |
Public Types inherited from RWTPointer< Body > | |
typedef Body | BodyType |
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) |
Defines a reference-counted pointer that provides reference counting semantics for types that do not directly support reference counting. Body
, the first template parameter, can be any type. For the second template parameter, Counter
, you will generally use RWAtomicCounter.
A user-defined counter class must provide the following interface:
RWTCountingPointer< Body, Counter >::RWTCountingPointer | ( | RWStaticCtor | ) |
Special constructor that performs no initialization.
RWTCountingPointer< Body, Counter >::RWTCountingPointer | ( | Body * | bodyP = rwnil | ) |
Constructs a pointer instance that manages references for the specified Body
instance. Parameter bodyP is the Body
instance to be managed by this pointer.
RWTCountingPointer< Body, Counter >::RWTCountingPointer | ( | const RWTCountingPointer< Body, Counter > & | second | ) |
Constructs a pointer instance that can access the body instance associated with another pointer instance, incrementing the underlying reference count for that instance by one.
RWTCountingPointer< Body, Counter >::~RWTCountingPointer | ( | void | ) |
Decrements the reference counter and deletes the body instance, if there are no other references.
Body & RWTCountingPointer< Body, Counter >::operator* | ( | void | ) | const |
Dereferences the handle to get a reference to the body. Throws exception RWTHRInvalidPointer if pointer is invalid.
Body * RWTCountingPointer< Body, Counter >::operator-> | ( | void | ) | const |
Dereferencing operator. This operator should always be used to dereference the handle as it will validate the pointer, throwing an exception if it is not valid. Returns a pointer to the body instance attached to this handle. Throws exception RWTHRInvalidPointer if no body instance has been attached to this handle instance.
RWTCountingPointer< Body, Counter > & RWTCountingPointer< Body, Counter >::operator= | ( | Body * | bodyP | ) |
Detaches from the current body (if any), decrements its associated reference count, and deletes it if there are no other associated references. It then attaches to the pointer bodyP, and increments its associated reference count. The new attached pointer must point to the dynamically allocated object. Throws no exceptions.
RWTCountingPointer< Body, Counter > & RWTCountingPointer< Body, Counter >::operator= | ( | const RWTCountingPointer< Body, Counter > & | second | ) |
Detaches from the current body (if any), decrements its associated reference count, and deletes it if there are no other associated references. It then attaches to second 's body, and increments its associated reference count.
Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |