Boost logo

Boost :

Subject: Re: [boost] [mirror] -- RFC
From: Matus Chochlik (chochlik_at_[hidden])
Date: 2009-03-30 11:49:44


On Mon, Mar 30, 2009 at 3:59 PM, Mathias Gaunard
<mathias.gaunard_at_[hidden]> wrote:
> Matus Chochlik wrote:
>
[snip]
>
> From a quick reading of the documentation, I can see this library allows:
> - to register members of a class and to be able to iterate them later at
> compile-time. That kind of thing is already provided by Boost.Fusion
> somehow.

Yes, Boost.Fusion allows this, but I can't imagine any complex
application using just Fusion tuples instead of any regular classes.
Furthermore Mirror can work with existing third-party classes and
with classes that have private members accessible only by get/set member
functions.

> - to demangle the result of std::type_info::name
> - to remove the namespace information from the demangled name
> - to do some tests on namespaces which seem quite arcane and not very useful
> to me.

Well, these are just the very basic use-cases of Mirror, I have to
admit that the examples
in the documentation don't cover any more complex cases, yet.

Just to mention some of the more useful features:

- namespace member iteration and traversals, which provide means to
iterate through
nested namespaces and/or classes in a reflected namespace
(http://tinyurl.com/cg8f74)
or to traverse them recursively by custom visitors.

- class traversals which allow to go through the class' structure (base classes,
member attributes) recursively by a custom visitor and optionally to work just
on the static structure itself or work on actual instances of the
traversed class.

This way generic serialization-like algorithms or algorithms doing
object-relational
mapping which have a lot of useful meta-data available, can be easily written.
Since Mirror registers and allows to work with the names of class
member attributes
it can work with data formats using the attribute names (like JSON,
XML, etc.) more
conveniently than Boost.Serialzation does (but obviously Mirror is not seeking
to replace Boost.Serialization ;-)).
(see for example here: http://tinyurl.com/d5ywwb, here
http://tinyurl.com/ccf2rq
or here http://tinyurl.com/ccoagk)

- intrinsic functions and iterators allow to iterate through class' members and
base-classes or to search for meta-objects satisfying compile-time
predicates (http://tinyurl.com/dk4d2a)

- algorithms like 'for_each' allow to execute custom functors on meta-objects
reflecting namespace members, class member attributes, base-classes, etc.

- meta-data provided by class' constructor reflection allow to construct
generic class factories (an example an automatically generated wxWidgets-based
class factory which can construct any type with constructors registerd
with Mirror
can be found here: http://tinyurl.com/crqyxs).

>
> So I don't see anything really compelling in it. Maybe a few use cases of
> your library would make me more interested?

> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>

Best regards,
________________
::matus_chochlik


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