|
wxArt2D
|
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 |
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.