Subject: Re: [boost] interest in properties library
From: Daniel Oberhoff (daniel.oberhoff_at_[hidden])
Date: 2008-12-20 07:46:57
On Fri, Dec 19, 2008 at 5:50 AM, Daniel Oberhoff <
> I am thinking about submitting a library proposal and would like to
> wether there is any interest in such a library and chance of
success of such
> a proposal.
> The basic idea is to implement the possibility to decorate a class
> named properties, such that given a pointer to an instance
properties can be
> accessed by name rather than using set/get methods. Also the type
> instance should not need to be known at compile time, other than
> derives from a suitable base class describing the property
> There is a rough implementation existing and used in a product
> Setting and getting is done using appropriate boost functions. Type
> resolution is done using RTTI (especially dynamic cast). Complex
> hierarchies are supported through virtual inheritance from the base
> such that several classes along the hierarchy can contribute
> CRTP and static initialization is used to register properties.
> setter/getter function generators are provided as is a mechanism to
> nested properties using dot notation.
I'm not sure I follow exactly what you mean, could you give a small
of the interface and usage? It sounds like you are referring to
along the lines of C# properties though I don't immediately see what
using dynamic casting for or what exactly this provides as a benefit
get/set methods. Thanks.
Well, yes, it is in one way like c# (or ObjC 2.0) properties, in that
you can have direct access to the variables first, and then override
setters/getters later. But the difference is, that properties are
accessed by name, and the type of the object does not need to be
known. That is set/get methods of the object would never be visible.
You only need to know, that the object derives from a
HasPropertiesBase class. That is also where dynamic cast comes in, in
order to hand the right pointer to the setter method (you may be
surprised, but in the case of virtual inheritance the pointer returned
by dynamic cast actually points to a different address).
I use it in a setting where I generate objects from a factory, and
they are returned as pointers to an abstract base class, and the
actual type is never exposed. Also accessing properties by name makes
scripting very easy.
btw, I hope I got this reply addressed right. the problem is I thought
this list is identical to boost.users on gmane, so I turned of mail
reply, but it seems this is a different list.
anyhow, is there general interest in such a library?
-- -Matt Calabrese
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk