Smart Pointer Class Architecture
The Smart Pointer package includes handle-body, singleton, smart pointer, and helper classes.
In the smart pointer category are the generic template classes for pointer-like object creation. Using these classes, you can create objects that act like pointers but provide some special behavior, such as reference-counting.
All classes in the smart pointer category derive from the abstract template class
RWTPointer, as shown in
Figure 43.
RWTPointer is an
opaque pointer, a pointer wrapper without dereferencing operations. Dereferencing operations are implemented in the derived concrete types, so they can have specialized behavior.
RWTPointer provides a minimal common set of operations, such as the
isValid() function.
Handle-body implementations built with the Smart Pointer package are based on the
RWHandleBase and
RWBodyBase classes (see
Figure 44). These classes implement the basic functionality required for reference-counting.
RWHandleBase provides constructors, destructor, assignment operator, equality and inequality operators, and the
isValid() member, while
RWBodyBase maintains the multithread-safe reference count.
The
helper category contains accessory classes used by the smart pointer and handle-body classes (shown in
Figure 45). For example, the implementation of reference counting falls in this category.