Reference counted base class.
More...
#include <scim_object.h>
|
template<typename T > |
class | Pointer |
|
Reference counted base class.
ReferencedObject is a reference counting base class. it has an integer reference counter so that dynamic objects can have their memory allocation handled by the scim smart pointer: Pointer<>. This keeps the memory management in scim consistent across all classes. If you derive a class from ReferencedObject and allocate it on the heap, you free the memory and destroy the object by calling unref(), not delete.
◆ ReferencedObject()
scim::ReferencedObject::ReferencedObject |
( |
| ) |
|
|
protected |
◆ ~ReferencedObject()
virtual scim::ReferencedObject::~ReferencedObject |
( |
| ) |
|
|
protectedpure virtual |
◆ set_referenced()
void scim::ReferencedObject::set_referenced |
( |
bool |
reference | ) |
|
|
protected |
Set the internal referenced flag.
- Parameters
-
reference | - true if the initial reference count must be removed by owner. |
Called by derived classes to set the referenced flag. A object sets this flag to true , indicating that it owns the initial reference count and unref() must be called.
◆ is_referenced()
bool scim::ReferencedObject::is_referenced |
( |
| ) |
const |
The referenced flag setting.
- Returns
- true if unref() must be explicitly called on this object.
◆ ref()
void scim::ReferencedObject::ref |
( |
| ) |
|
Increase an object's reference count by one.
◆ unref()
void scim::ReferencedObject::unref |
( |
| ) |
|
Decrease an object's reference count by one. When the reference count becomes zero delete is called. Remember, with ReferencedObject you must call unref() on dynmaically allocated objects, not delete.
◆ Pointer
The documentation for this class was generated from the following file: