
Jeremy Pack wrote:
Jean-Louis, Boost.Reflection handles multiple and virtual inheritance fine.
Does the version from http://boost-extension.blogspot.com/2008/07/latest-release-downloadable.html contain support for inheritance already? My primary interest is not in reflection per se, for me it's just a tool upon which one can build generic object-processing tools like dumping objects to text descriptions or XML or implementing object-relational mapping. Once we have reflection, we need a way to deal with fields in a generic manner, whatever their type: int, vector<int>, vector< vector<int> > etc. One solution is to reflect the structure of the field's type as well: make the field class contain a pointer to a polymorphic type object, from which one derives int_type, a vector_type - which contains in turn a pointer to the element's type - etc. Pattern freaks will call it a composite ;-) The next step is multimethods. Once we have them we can write code like this: // using BS's proposed syntax in D&E void process_type(virtual type&, virtual processor&, void*); void process(instance i, processor& p) for each field (i) process_type(*field->type, p, field->address(i)) class text_dumper : public processor { ... }; void process_type(virtual int_type& t, virtual text_processor& p, char* pv) { p << *reinterpret_cast<int*>(pv); } void process_type(virtual vector_type& t, virtual text_processor& p, char* pv) { p.indent(); char *iter = t.begin(pv), last = t.end(pv); while (iter != last) { process_type(t.element_type, p, iter); t.forward(iter); } p.outdent(); } What do you think of the idea? Jean-Louis