
Caleb Epstein wrote:
On Tue, 09 Nov 2004 22:29:06 +0200, John Torjo <john.lists@torjo.com> wrote:
I'd prefer a way of storing the type information for each reflectable class statically, and in a generic way, e.g. something like std::map<std::string, property>. This would enable the reflection code could be decoupled from the reflected classes entirely and just operate on this property meta-data. It would also allow client code to lookup individual properties (e.g. by name) instead of having to visit all of them.
Not sure if I understood you correctly, but if I did, why not do this:
// define globals in a source file
// etc. reflected_property r1(&window::get_enabled, &window::set_enabled, "enabled"); reflected_property r2(&window::get_visible, &window::set_visible, "visible");
How would one go about associating all of the reflected_properties with the "window" class regardless of their type? I am imagining a repository of properties that users can query and enumerate, e.g.:
Of course. It all happens in the (templated) constructor of reflected_property. There, you can easily add this property to an array of reflected properties. Then, at runtime, you can query them (much like I've done with win32gui events). Best, John -- John Torjo, Contributing editor, C/C++ Users Journal -- "Win32 GUI Generics" -- generics & GUI do mix, after all -- http://www.torjo.com/win32gui/ -- v1.5 - tooltips at your fingertips (work for menus too!) + bitmap buttons (work for MessageBox too!) + tab dialogs, hyper links, lite html