|  | overview |  | wiki |  | api reference |  | download

- Main Page
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Functions Variables Typedefs Enumerations Enumerator
Public Member Functions | Protected Member Functions
gameplay::Ref Class Reference

`#include <Ref.h>`

Inheritance diagram for gameplay::Ref:

List of all members.

## Public Member Functions

void | addRef ()
void | release ()
unsigned int | getRefCount () const

## Protected Member Functions

| Ref ()
| Ref (const Ref &copy)
virtual | ~Ref ()

## Detailed Description

Defines the base class for game objects that require lifecycle management.

This class provides reference counting support for game objects that contain system resources or data that is normally long lived and referenced from possibly several sources at the same time. The built-in reference counting eliminates the need for programmers to manually keep track of object ownership and having to worry about when to safely delete such objects.

## Constructor & Destructor Documentation

gameplay::Ref::Ref | ( |  | ) | `[protected]`

Constructor.

gameplay::Ref::Ref | ( | const Ref & | copy | ) | `[protected]`

Copy constructor.

Parameters:

  copy | The Ref object to copy.

virtual gameplay::Ref::~Ref | ( |  | ) | `[protected, virtual]`

Destructor.

## Member Function Documentation

void gameplay::Ref::addRef | ( |  | ) |

Increments the reference count of this object.

The release() method must be called when the caller relinquishes its handle to this object in order to decrement the reference count.

unsigned int gameplay::Ref::getRefCount | ( |  | ) | const

Returns the current reference count of this object.

Returns:
  This object's reference count.

void gameplay::Ref::release | ( |  | ) |

Decrements the reference count of this object.

When an object is initially created, its reference count is set to 1. Calling addRef() will increment the reference and calling release() will decrement the reference count. When an object reaches a reference count of zero, the object is destroyed.

All Classes Functions Variables Typedefs Enumerations Enumerator