|
Boost : |
Subject: Re: [boost] [intro] Preview: Introspection library
From: Matus Chochlik (chochlik_at_[hidden])
Date: 2010-06-28 10:01:12
On Mon, Jun 28, 2010 at 3:32 PM, Sohail Somani <sohail_at_[hidden]> wrote:
> On 10-06-28 8:00 AM, Stefan Strasser wrote:
>>
>> template<class Mapping>
>> friend void introspect(Mapping mapping,type<A>){
>> Â mapping
>> Â Â (base_class<A_base>() Â Â Â Â Â Â Â Â Â )
>>   (member<A,int       ,&A::m_a>()  )
>>   (member<A,float      ,&A::m_b>()  )
>> Â Â (member<A,std::vector<int>,&A::m_vec>())
>> Â ();
>> }
>
> I think a library like this would be useful.
Just FYI there is also another introspection/reflection library being developed
for boost called Mirror. It can be downloaded from sourceforge here:
http://sourceforge.net/projects/mirror-lib/files/
or from the boost vault.
There are actually two versions: pre-c++0x (which is currently on hold)
and c++0x (being actively developed)
The current (work-in-progress) docs for the c++0x version can be found here:
http://kifri.fri.uniza.sk/~chochlik/mirror-lib/html/index.html
To get some idea on how the library is used I suggest looking here:
http://kifri.fri.uniza.sk/~chochlik/mirror-lib/html/examples.html
The registering process is explained here:
http://kifri.fri.uniza.sk/~chochlik/mirror-lib/html/mirror__registering.html
although much more can be found in the docs.
>
> Isn't it simpler to specialize a template? Why does this need to be done at
> run-time? How do you introspect a type's constructors?
Mirror allows to introspect constructors and actually there is a utility called
factory generator, which uses this meta-information to generate factory
classes for various product types.The docs for this utility can be found here:
http://kifri.fri.uniza.sk/~chochlik/mirror-lib/html/mirror__factory__generator__utility.html
but they are not finished.
>
[snip]
BR, Matus
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk