Thursday, September 6, 2007

What is Boost.Reflection?

Boost.Reflection is similar to, and can be used together with, Boost.Extension. However, it allows for creating and using objects without having access to the definition of the class or one of its base classes (Boost.Extension requires having access to one of a class's base classes).

Features:
  1. Use arbitrary information to describe a class
  2. Instantiate a class
  3. Call its methods by arbitrary identifiers (although you can use strings to identify methods, it is possible to use any arbitrary information to select them)
  4. Fast function calls - you only have the overhead of two functions called by function pointers.
  5. Call functions without knowing what parameters they require.
  6. Containers indexed by type.
Information about Boost.Reflection is currently contained in the Extension docs. Especially check out the following:

reflection.hpp reference
reflector reference
Extension/Reflection interoperability

2 comments:

Remi said...

You may like this library which has similar goals as yours: http://sourceforge.net/projects/crd
Its priority is mostly serialization of any form (files, xdr, database), given a description list of a struct/class. It is not-intrusive, and has run-time and compile-time modes.

Jeremy Pack said...

I think that Boost.Serialization is more similar to crd than Boost.Reflection is. I have actually looked at crd before, but notice that major restructuring has occurred in the past week or so. I'll have to look at it in more detail.