Base Class
#include <rw/pointer/RWHandleBase.h>
Base class for handle classes. Each time an instance of this class is bound to an instance of the RWBodyBase class, it increments the reference count maintained by that body. Each time an instance of this class detaches from a body instance, it decrements the body's reference count, until the last handle detaches, reaching zero, whereupon it deletes the body instance. The reference counting relieves clients of the burden of keeping track of when it is safe to delete a body instance.
When a handle is copy-constructed, the new handle attaches to the same body as the original. When one handle is assigned to another handle, the handle on the left side detaches from its current body and attaches to the body pointed to by the handle on the right side.
See HandleBodyEx1.cpp and HandleBodyEx2.cpp, located in the examples directory.
RWHandleBase(void);
Default constructor. Constructs an empty, invalid, handle instance. Throws no exceptions.
RWHandleBase(RWBodyBase* body);
Binds a new handle instance to a body instance.
RWHandleBase(RWStaticCtor);
Constructs a global static handle instance (may be used prior to construction). Throws no exceptions.
RWHandleBase(const RWHandleBase& second);
Binds a new handle instance to the same body instance, if any, that is pointed to by a second handle instance.
RWBodyBase& body(void) const;
Gets a reference for the body instance, if any; otherwise throws an RWTHRInvalidPointer exception.
RWHandleBase& operator=(const RWHandleBase& second);
Binds this handle instance to the same body instance, if any, that is pointed to by a second handle instance.
RWBoolean isValid(void) const;
Returns TRUE if this handle points to a valid body instance, and FALSE otherwise. Throws no exceptions.
RWBoolean operator!=(const RWHandleBase& second) const;
Returns TRUE if the handle points to different body instance, if any, than pointed to by a second handle, and otherwise FALSE. Throws no exceptions.
RWBoolean operator<(const RWHandleBase& second) const;
Required for collections based on Standard C++ Library collections. (This should be redefined in derived classes, as necessary.) Throws no exceptions.
RWBoolean operator==(const RWHandleBase& second) const;
Returns TRUE if the handle points to the same body instance, if any, as pointed to by a second handle, and FALSE otherwise. Two empty handles are equal. Throws no exceptions.
©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.