RWTCountingPointer<Body,Counter=RWSafeCounter> RWTPointer<Body>
#include <rw/pointer/RWTCountingPointer.h>
Defines a reference-counted pointer that provides reference counting semantics for objects that do not directly support reference counting.
RWTCountingPointer<int> pointer = new int(10);
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(RWStaticCtor);
Special constructor that performs no initialization.
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(void);
Decrements the reference counter and deletes the body instance, if there are no other references.
Body* 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.
Body& operator*(void) const;
Dereferences the handle to get a reference to the body. Throws exception RWTHRInvalidPointer.
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>& 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 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.