ooc  1.3c
Object Oriented tollkit fo ANSI C
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
refcounted.h File Reference

RefCounted class - a reference counted Object. More...

#include "ooc.h"
Include dependency graph for refcounted.h:

Macros

#define refcnt_inc(object)   ( refcnt_addref( (RefCounted) object ), object )
 Increments the reference counter. More...
 

Functions

RefCounted refcnt_addref (RefCounted object)
 Increments the reference counter. More...
 

Detailed Description

RefCounted class - a reference counted Object.

RefCounted serves as a base class for reference counted Objects.

Note
The initial value for the counter is one.
Warning
RefCounted overrides the delete operator: do not override the delete operator for inherited classes!
Current implementation of RefCounted is not thread safe.

Macro Definition Documentation

#define refcnt_inc (   object)    ( refcnt_addref( (RefCounted) object ), object )

Increments the reference counter.

This is a macro version, which is more convenient since there is no need for manual type casting.

Parameters
objectThe Object to be counted.
Returns
The object.
See Also
refcnt_addref()
Warning
Pass a pure Object pointer only! This macro has a side effect otherwise! (e.g. passing a function as a parameter that returns the object is called twice!)

Function Documentation

RefCounted refcnt_addref ( RefCounted  object)

Increments the reference counter.

Parameters
objectThe Object to be counted.
Returns
The object.
Note
To decrement the reference counter, simply ooc_delete() the object. ooc_delete() decrements the counter, and does not delete it until zero. The last ooc_delete will destroy the object.
See Also
refcnt_inc()