wxArt2D
Public Types | Public Member Functions | Friends | List of all members
a2dSmrtPtr< Clss > Class Template Reference

A pointer class, that automatically calls SmrtPtrOwn/SmrtPtrRelease. More...

#include <smrtptr.h>

Inheritance diagram for a2dSmrtPtr< Clss >:
Inheritance graph
[legend]
Collaboration diagram for a2dSmrtPtr< Clss >:
Collaboration graph
[legend]

Public Types

typedef Clss TType
 

Public Member Functions

 a2dSmrtPtr (Clss *objc)
 
 a2dSmrtPtr (const a2dSmrtPtr &objc)
 
void operator= (const a2dSmrtPtr &objc)
 
void operator= (Clss *objc)
 
 operator Clss * () const
 
Clss * Get () const
 
Clss * operator-> () const
 
Clss & operator* () const
 
void PointerListInit ()
 
void AddToPointerList ()
 
void RmvFromPointerList ()
 

Friends

bool operator== (const a2dSmrtPtr &a, const a2dSmrtPtr &b)
 
bool operator!= (const a2dSmrtPtr &a, const a2dSmrtPtr &b)
 
bool operator== (const a2dSmrtPtr &a, const Clss *b)
 
bool operator!= (const a2dSmrtPtr &a, const Clss *b)
 
bool operator== (const Clss *a, const a2dSmrtPtr &b)
 
bool operator!= (const Clss *a, const a2dSmrtPtr &b)
 
bool operator== (const a2dSmrtPtr &a, Clss *b)
 
bool operator!= (const a2dSmrtPtr &a, Clss *b)
 
bool operator== (Clss *a, const a2dSmrtPtr &b)
 
bool operator!= (Clss *a, const a2dSmrtPtr &b)
 

Detailed Description

template<class Clss>
class a2dSmrtPtr< Clss >

A pointer class, that automatically calls SmrtPtrOwn/SmrtPtrRelease.

a2dSmrtPtr is a template class, that performs automatic reference counting.

It can be used like a usual C++ pointer. It can be used for any class, that has SmrtPtrOwn and SmrtPtrRelease functions, like this:

class XXX private:

how many references to this object do exist int m_refcount;

Call to have a new owner for this object This function should only be called by a2dSmrtPtr

Remarks
owning mean that the object calling this member needs to call Release at some time, in order to actually release/delete the object.
Returns
The return value is the object itself, which is now owned on time extra.

increment refcount by 1 ( use when adding a reference to this object)

    a2dLineSegment* SmrtPtrOwn() { m_refcount++; return this; }

To release the object, it is not longer owned by the calling object. This function should only be called by a2dSmrtPtr bool SmrtPtrRelease() { m_refcount–; wxASSERT_MSG( m_refcount >= 0, wxT("XXX object Own/Release not matched (extra Release calls)") ); if ( m_refcount <= 0 ) { delete this; return true; } return false; }

private: friend class a2dSmrtPtrBase;

Definition at line 20 of file a2dlist.h.


The documentation for this class was generated from the following files:
a2dSmrtPtr< Clss > Class Template Reference -- Sun Oct 12 2014 17:04:48 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation