ooc 1.3
Object Oriented tollkit fo ANSI C

refcounted.h File Reference

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

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

Defines

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

Functions

RefCounted refcnt_addref (RefCounted object)
 Increments the reference counter.

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.

Define 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()
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines