$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: [boost] [intro] Preview: Introspection library
From: Stefan Strasser (strasser_at_[hidden])
Date: 2010-06-28 08:00:55
Hi,
I'd be interested in comments on an introspection library I've been
developing.
there has been no "Is there any interest..."-e-mail yet, as it was
started out of necessity in "namespace detail" of another library, so
you're also welcome to express interest/disinterest in a library like
this, without any specific comments.
source code:
https://svn.boost.org/trac/boost/browser/sandbox/intro/boost/intro/
the library defines a concept that exposes the members of a class, for
introspection algorithms to work with.
e.g. the "print" algorithm applied to a simple object implementing the
concept yields the following results:
intro::print(a,std::cout);
----
{
A_base = {
int member_of_base = 789;
};
int a = 123;
float b = 456.7;
vector<int,class std::allocator<int> > vec = {2, 4, 6, 8, 10};
}
---
other algorithms that are currently implemented:
- apply_members[_binary]: apply a user-supplied functor to each member
- apply_recursive: follow pointers, references, STL container elements, etc.
- serialize:
serialization of an object tree of 1M objects:
80 ms. Boost.Serialization: 330 ms.
serialization of an object graph of 1M objects:
410 ms. Boost.Serialization: 2700 ms.
- move: move-construct an object
- reset_shared
planned or not yet in the sandbox are deserialize, print_recursive,
copy_deep, copy_shallow, equal_deep, equal_shallow.
an implementation of the concept looks like this:
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>())
();
}
members can also be associated with tags or data, and can be assigned
semantics (e.g. polymorphic, shared/unique for pointers), but I won't
go into too much detail for now.
Best,
Stefan