|
Boost : |
Subject: Re: [boost] Reflection?
From: Jeremy Pack (rostovpack_at_[hidden])
Date: 2008-11-03 12:25:13
Jean-Louis,
Boost.Reflection handles multiple and virtual inheritance fine.
The main difference between the approaches is that Boost.Reflection does not
require any global structures.
A basic example similar to yours would look something like:
map<string, reflection> reflections;
reflections["animal"].reflect<animal>()
// doSomething's parameters are deduced automatically if possible.
.function(&animal::doSomething, "doSomething")
.data(&someData, "someData"); // etc.
reflections["baboon"].reflect<baboon>()
.constructor() // use the default constructor
.constructor<int, const char*>() // provide a parameterized constructor
.inherits<animal>("animal")
.function(&baboon::someAnimalThing, "someAnimalThing");
reflection& baboon_reflection = reflections["baboon"];
instance_constructor baboon_factory = baboon_reflection.get_constructor();
instance baboon_instance = baboon_factory.create();
reflected_function<> someAnimalThing =
baboon_reflection.get_function("someAnimalThing");
// Call someAnimalThing
someAnimalThing(baboon_instance);
reflected_function<int, const string&> doSomething =
baboon_reflection.get_function("doSomething");
doSomething(baboon_instance, 5, "hello");
// etc.
I wrote that from memory so some of the syntax may be off (I don't have
enough time today to do more with it).
The library interface is changing a bit over the next few weeks as I prepare
to submit the Boost.Extension library (of which this is a part) for review.
The code will be moving from the libs/reflection directory to the
libs/extension directory, switching namespaces, etc.
Jeremy
On Sat, Nov 1, 2008 at 9:05 PM, Jean-Louis Leroy <jl_at_[hidden]> wrote:
> Jeremy Pack wrote:
>
>> I'm working on Boost.Reflection - see http://boost-extension.blogspot.com.
>> I
>> gave a presentation on it at BoostCon this year.
>>
>
> Thanks. I have looked at the code in the svn repo (which I had not found
> when browsing the boost website).
>
> Do you have an example of how it's used? Is it similar to my example? Can
> it cope with multiple or virtual inheritance? In your code I don't see where
> address adjustment is done...
>
>
> Jean-Louis
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk