MPMA Framework 0.4
Public Member Functions | Protected Member Functions
MPMA::ReferenceCountedData< DataType > Class Template Reference

Deriving from this allows multiple instances of a class to share data, which will be automatically freed when the last instance is freed. More...

#include <ReferenceCount.h>

List of all members.

Public Member Functions

 ReferenceCountedData ()
 Creates a new instance of the data.
virtual ~ReferenceCountedData ()
 Removes a reference to the data.
 ReferenceCountedData (const ReferenceCountedData &other)
 Creates a new reference to existing data.
ReferenceCountedDataoperator= (const ReferenceCountedData &other)
 Removes the old reference and adds a new reference to existing data.
bool SharesDataWith (const ReferenceCountedData< DataType > &o)
 Returns whether one objects references the same data as another.

Protected Member Functions

DataType & Data ()
 Returns the data that is being reference counted.
const DataType & Data () const
 Returns the data that is being reference counted.
nuint ReferenceCount () const
 Returns the number of references left (intended for debugging purposes).
bool IsOnlyReference () const
 Returns true if this is the only reference to the shared data. This can be useful in the derived class's constructor/destructor to do any setup or cleanup.
void CreateNewData ()
 Remove the old reference from this object, and creates a new instance of the data which this objet then references.

Detailed Description

template<typename DataType>
class MPMA::ReferenceCountedData< DataType >

Deriving from this allows multiple instances of a class to share data, which will be automatically freed when the last instance is freed.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends