Re: weak pointers, cbdata, refcounting

From: Henrik Nordstrom <hno@dont-contact.us>
Date: Fri, 26 Aug 2005 22:02:48 +0200 (CEST)

On Mon, 22 Aug 2005, Alex Rousskov wrote:

> That's good to know! Apparently, I do not use cbdata correctly
> because it does not seem to work for me. Could you please point me to the
> updated (with respect to classes) cbdata docs or notes? Perhaps I just need
> to add more #define-driven glue to base (or all?) classes...

In each class which needs to support cbdata you need to use the
CBDATA_CLASS2() macro in the private section. (the brother macro
CBDATA_CLASS can also be used but you must then manually define new/delete
methods)

In a suitable .cc file you need to have the CBDATA_CLASS_INIT() macro call
at global scope.

This works for classes with simple inheritance only, or the leaf classes
when there is multiple inheritance. It won't work for the inherited
classes in multiple inheritance.

Classes inheriting a cbdata class must themselves also be defined as an
cbdata class.

It should perhaps be noted in this discussion that the cbdataReference
pointer is only meant to be used as an opaqueue pointer. If you need to
access the members/methods then cbdata is not the proper tool for the job
(refcounting with invalidation would be).

Regards
Henrik
Received on Fri Aug 26 2005 - 14:02:51 MDT

This archive was generated by hypermail pre-2.1.9 : Wed Aug 31 2005 - 12:00:06 MDT