[boost] Re: Visitor-based framework to describe classes with exampleofobjectdump in XML format
Alexander Nasonov wrote: class base_node // represent a base of a concrete class { // ... // virtual void* derived_to_base(void* base_ptr) const = 0; }; Oops, I made a little naming mistake: base_ptr should be derived_ptr. BTW, compile-time retrospection could be used to find library-specific constructor. For example, Driver could have it: class Driver : public Person { std::string licence_id; Date licence_issue_date; public: Driver(const raw_object raw) : Person(raw) , licence_id(raw.get(Driver::licence_id)) , licence_issue_date(raw.get(Driver::licence_issue_date)) { } // .. }; If this information isn't available at compile-time you have to tell the framework about the constructor: void describe_Driver(descriptorDriver class_) { class_(Driver).derived_fromPerson() [ constructorconst raw_object(), // here member(Driver::licence_id, licence_id), member(Driver::licence_issue_date, licence_issue_date) ]; } -- Alexander Nasonov Remove minus and all between minus and at from my e-mail for timely response ___ Unsubscribe other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
[boost] Re: Visitor-based framework to describe classes with exampleofobjectdump in XML format
David Abrahams wrote: A problem with this is that the introspection information is only available at runtime. A more-flexible system would use GCC-XML output to generate something like: template struct class_Driver { typedef mpl::vectorPerson bases; typedef mpl::vector memberint Driver::*, Driver::licence_id , memberDate Driver::*, Driver::licence_issue_date , membervoid (Driver::*)(), Driver::accelerate members; ... }; So all the introspection information could be available at compile-time. Sometimes it's fine to have an introspection only at runtime. I just want to avoid duplications of class descriptions by multiple libraries. For example, Python and luabind could share common introspection information. This is why I'm using visitors. Every intronspection elelemnt has correspondent node that can be visited. The challenge is to build a complete set of nodes with a complete set of operations. -- Alexander Nasonov Remove minus and all between minus and at from my e-mail for timely response ___ Unsubscribe other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
[boost] Re: Visitor-based framework to describe classes with exampleofobjectdump in XML format
Alexander Nasonov [EMAIL PROTECTED] writes: Well, sometimes it's needed at compile-time. Though, I don't know how useful it is. Can you give an example? Heh, you caught me! Well, if the (member) (function) pointers are available at compile time they can be inlined away so that using them becomes more efficient. Suppose I want to write serialization code? Can you serialize/deserialize with a runtime-only framework? Some other questions. How to map member pointers to names? Add a char const* const parameter? Have an additional parallel array of names? How to find a member? By name? By reverse-indexing whatever structure answers the previous question, of course! -- Dave Abrahams Boost Consulting www.boost-consulting.com ___ Unsubscribe other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
[boost] Re: Visitor-based framework to describe classes with exampleofobjectdump in XML format
Joel de Guzman [EMAIL PROTECTED] writes: Alexander Nasonov [EMAIL PROTECTED] wrote: From user point of view it's easy. Every class is described using intuitive class-decl-like style: void describe_Driver(descriptorDriver class_) { class_(Driver).derived_fromPerson() [ member(Driver::licence_id, licence_id), // note comma operator member(Driver::licence_issue_date, licence_issue_date) ]; } Cool syntax! Hmmm Reminds me of Boost.Python, luabind and ahem... Phoenix ;-) A problem with this is that the introspection information is only available at runtime. A more-flexible system would use GCC-XML output to generate something like: template struct class_Driver { typedef mpl::vectorPerson bases; typedef mpl::vector memberint Driver::*, Driver::licence_id , memberDate Driver::*, Driver::licence_issue_date , membervoid (Driver::*)(), Driver::accelerate members; ... }; So all the introspection information could be available at compile-time. -- Dave Abrahams Boost Consulting www.boost-consulting.com ___ Unsubscribe other changes: http://lists.boost.org/mailman/listinfo.cgi/boost