Boost logo

Boost :

From: Edward Diener (eddielee_at_[hidden])
Date: 2004-12-05 22:42:17


Hajo Kirchhoff wrote:
> Edward Diener wrote:
>> Yes, I am interested in it. It appears to provide a way to do
>> reflection on a limited basis by using a name to create an object.
>> Hajo Kirchhoff in his LitWindow library also provides a way to do
>> reflection based on names although I do not believe he has the
>> ability which you have to dynamically create objects based on names.
>> The general ideas that you both use,
>
> Yes I do. The Lit Window Library allows this.
>
> // get the type definition for the class foobar
> prop_t aType = get_prop_type_by_name("foobar");
>
> // create an object on the heap
> accessor a = create_object(aType);
>
> // access member variable foobar.m_string
> cout << a.get_aggregate()["m_string"] << endl;
>
> // cast the generic accessor to a typed accessor
> typed_accessor<foobar> fbar=dynamic_cast_accessor<foobar>(a);
> assert(fbar.is_valid());
>
> // copy the contents of the object to a different object
> foobar someObject;
> fbar.get(someObject);
>
> // destroy the object
> destroy_object(a);
> // a.destroy() is an alternative way of destroying it
>
> BTW, the base part of the lit window library does not contain any GUI
> code at all and is meant to be used independently for any kind of
> generic programming.
>
>> any general mechanism which provides reflection capabilities, where
>> a name can be used to find out type information or variable
>> information at run-time, or where an object can be created based on
>> its name at run-time.
>
> http://www.litwindow.com/library does this. The documentation is
> certainly not yet up to par, but the functionality is there and is
> pretty mature already, except for container support. This is still
> pretty spotty for any container other than stl::vector.
>
> Regards and I'd love to hear any comments on my code.

I am interested in the data accessor part of your library from the end-user
perspective so I would encourage you to document that fully. I understand
that you are using that functionality for your GUI library but, as you have
discovered through packaging it as a base library, it holds general interest
and functionality outside of its use in your GUI environment for those who
are interested in a run-time reflection mechanism.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk