Boost logo

Boost :

From: Hajo Kirchhoff (mailinglists_at_[hidden])
Date: 2004-12-05 18:19:32


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.

Hajo


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