wxArt2D
Public Member Functions | Protected Attributes | Friends | List of all members
a2dRefCount Class Reference

simple ref counted class to maintain a wxObject* as if it is a smart pointer More...

#include <gen.h>

Public Member Functions

 a2dRefCount (wxObject *theObjectToWrap)
 constructor
 
virtual ~a2dRefCount ()
 destructor
 
wxObject * GetObj ()
 

Protected Attributes

int m_refcount
 how many references to this object do exist
 
wxObject * m_object
 the wxObject that is maintained using Smart pointer within here.
 

Friends

class a2dSmrtPtrBase
 

Detailed Description

simple ref counted class to maintain a wxObject* as if it is a smart pointer

If you want to store wxObject pointers in a STL template list ( like a2dlist ), that becomes a problem. STL stores object by value, and does not delete the object pointed to when removing a pointer from the list. The trick is to store a2dSmrtPtr< wxObject> in the list, which will automatically delete wxObject when a smart pointer. But a a2dSmrtPtr< wxObject> can not be created since wxObject has no refcounting as needed for a2dSmrtPtr. Now this class wraps the wxObject into a class which does have the refcounting, so one stores a2dSmrtPtr< a2dRefCount > in the STL list instead, and all will be oke.

Definition at line 1648 of file gen.h.


The documentation for this class was generated from the following file:
a2dRefCount Class Reference -- Sun Oct 12 2014 17:04:47 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation