$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] interest in properties library
From: Daniel Oberhoff (daniel.oberhoff_at_[hidden])
Date: 2008-12-20 07:46:57
Hi,
On Fri, Dec 19, 2008 at 5:50 AM, Daniel Oberhoff <
daniel.oberhoff_at_[hidden]> wrote:
 > Hi,
 >
 > I am thinking about submitting a library proposal and would like to  
query
 > 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  
with
 > 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  
of the
 > instance should not need to be known at compile time, other than  
that it
 > derives from a suitable base class describing the property  
mechanisms.
 >
 > There is a rough implementation existing and used in a product  
environment.
 > Setting and getting is done using appropriate boost functions. Type
 > resolution is done using RTTI (especially dynamic cast). Complex  
inheritance
 > hierarchies are supported through virtual inheritance from the base  
class,
 > such that several classes along the hierarchy can contribute  
property slots.
 > CRTP and static initialization is used to register properties.  
Convenient
 > setter/getter function generators are provided as is a mechanism to  
access
 > nested properties using dot notation.
I'm not sure I follow exactly what you mean, could you give a small  
example
of the interface and usage? It sounds like you are referring to  
something
along the lines of C# properties though I don't immediately see what  
you are
using dynamic casting for or what exactly this provides as a benefit  
over
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?
Daniel
-- -Matt Calabrese