Table Of Contents

Previous topic

Rect2DDouble

Next topic

Region

This Page

phoenix_title RefCounter

This class is used to manage reference-counting providing a simple interface and a counter.

RefCounter can be easily used together with ObjectDataPtr to ensure that no calls to RefCounter.DecRef are missed - thus avoiding memory leaks.

ObjectRefData is a typedef to RefCounter and is used as the built-in reference counted storage for Object-derived classes.

See also

Object, ObjectRefData, ObjectDataPtr, Reference Counting


class_hierarchy Inheritance Diagram

Inheritance diagram for class RefCounter

Inheritance diagram of RefCounter


sub_classes Known Subclasses

DataViewModel


method_summary Methods Summary

__init__ Default constructor.
DecRef Decrements the reference count associated with this shared data and, if it reaches zero, destroys this instance of RefCounter releasing its memory.
GetRefCount Returns the reference count associated with this shared data.
IncRef Increments the reference count associated with this shared data.
~wxRefCounter Destructor.

property_summary Properties Summary

RefCount See GetRefCount

api Class API



class RefCounter(object)

This class is used to manage reference-counting providing a simple interface and a counter.

Possible constructors:

RefCounter()

Methods



__init__(self)

Default constructor.

Initialises the internal reference count to 1.



DecRef(self)

Decrements the reference count associated with this shared data and, if it reaches zero, destroys this instance of RefCounter releasing its memory.

Please note that after calling this function, the caller should absolutely avoid to use the pointer to this instance since it may not be valid anymore.



GetRefCount(self)

Returns the reference count associated with this shared data.

When this goes to zero during a DecRef call, the object will auto-free itself.

Return type:int


IncRef(self)

Increments the reference count associated with this shared data.



~wxRefCounter(self)

Destructor.

It’s declared protected so that RefCounter instances will never be destroyed directly but only as result of a DecRef call.


Properties



RefCount

See GetRefCount