Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Threads Module Reference Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

RWTCountedPointer<Body>

Module:  Threads   Package:  Smart Pointer


RWTCountedPointer<Body> RWTPointer<Body>

Local Index

Members

Header File

#include <rw/pointer/RWTCountedPointer.h>

Description

RWTCountedPointer<Body> is a smart pointer class that is intended for use as a handle to a reference-counting body. Each time an instance of this class is bound to a body instance, it increments the reference count maintained by that body. Each time it detaches from a body instance, it decrements the body's reference count; and if the reference count reaches zero, it deletes the body instance. The reference counting relieves clients of the burden of having to keep track of when it is safe to delete a body instance. The class specified as a template parameter must provide member functions for incrementing and decrementing the reference count. These functions must be declared as void addReference() and unsigned removeReference(). The easiest way to achieve this is by deriving from class RWTCountingBody.

Example

Public Typedef

typedef Body BodyType; 

Public Constructors

RWTCountedPointer(Body* bodyP=rwnil);
RWTCountedPointer(RWStaticCtor);
RWTCountedPointer(const RWTCountedPointer<Body>& second);

Public Destructor

~RWTCountedPointer();

Public Member Operators

Body&
operator*() const;
Body*
operator->() const;  
RWTCountedPointer<Body>&
operator=(Body* ptr);
RWTCountedPointer<Body>&
operator=(const RWTCountedPointer<Body>& second);

Public Member Function

void
orphan();

Protected Member Function

void
transfer(Body* bodyP=rwnil);

See Also

RWTCountingBody



Previous fileTop of DocumentContentsIndex pageNext file

© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.