Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #ifndef _BOOST_REFLECT_HPP_
00008 #define _BOOST_REFLECT_HPP_
00009
00010 #include <boost/static_assert.hpp>
00011 #include <boost/preprocessor/seq/for_each_i.hpp>
00012 #include <boost/preprocessor/seq/seq.hpp>
00013 #include <boost/preprocessor/stringize.hpp>
00014 #include <boost/preprocessor/tuple/elem.hpp>
00015 #include <boost/preprocessor/facilities/empty.hpp>
00016 #include <boost/type_traits/remove_const.hpp>
00017 #include <boost/type_traits/remove_reference.hpp>
00018 #include <boost/type_traits/remove_pointer.hpp>
00019 #include <string>
00020 #include <typeinfo>
00021 #include <vector>
00022 #include <list>
00023 #include <set>
00024 #include <map>
00025 #include <stdint.h>
00026 #include <boost/fusion/container/vector.hpp>
00027 #include <boost/reflect/void.hpp>
00028 #include <boost/reflect/vtable.hpp>
00029 #include <boost/reflect/typeinfo.hpp>
00030
00031 namespace boost { namespace reflect {
00032
00033
00034
00035
00036
00037
00038
00039
00040 template<typename T>
00041 struct reflector{
00042 typedef T type;
00043 typedef boost::fusion::vector<> base_class_types;
00044 typedef boost::false_type is_defined;
00045 template<typename Visitor>
00046 static inline void visit( const Visitor& ){};
00047 };
00048
00049 } }
00050
00051 #ifndef DOXYGEN
00052
00053 #define BOOST_REFLECT_VISIT_BASE(r, visitor, base) \
00054 boost::reflect::reflector<base>::visit( visitor );
00055
00056 #define BOOST_REFLECT_VISIT_MEMBER( r, visitor, elem ) \
00057 visitor.template operator()<BOOST_TYPEOF(type::elem),type,&type::elem>( BOOST_PP_STRINGIZE(elem) );
00058
00059 #define BOOST_REFLECT_IMPL( TYPE, INHERITS, MEMBERS ) \
00060 template<typename Visitor>\
00061 static inline void visit( const Visitor& v ) { \
00062 BOOST_PP_SEQ_FOR_EACH( BOOST_REFLECT_VISIT_BASE, v, INHERITS ) \
00063 BOOST_PP_SEQ_FOR_EACH( BOOST_REFLECT_VISIT_MEMBER, v, MEMBERS ) \
00064 }
00065
00066 #endif // DOXYGEN
00067
00068
00069
00070
00071
00072
00073
00074
00075 #define BOOST_REFLECT_DERIVED( TYPE, INHERITS, MEMBERS ) \
00076 BOOST_REFLECT_TYPEINFO(TYPE) \
00077 namespace boost { namespace reflect { \
00078 template<> struct reflector<TYPE> {\
00079 typedef TYPE type; \
00080 typedef boost::true_type is_defined; \
00081 BOOST_REFLECT_IMPL( TYPE, INHERITS, MEMBERS ) \
00082 }; } }
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092 #define BOOST_REFLECT( TYPE, MEMBERS ) \
00093 BOOST_REFLECT_DERIVED( TYPE, BOOST_PP_SEQ_NIL, MEMBERS )
00094
00095
00096
00097
00098
00099 #endif