Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r51813 - in sandbox/mirror: boost/mirror boost/mirror/detail boost/mirror/visitors libs/mirror/example libs/mirror/example/traversal
From: chochlik_at_[hidden]
Date: 2009-03-17 04:38:58


Author: matus.chochlik
Date: 2009-03-17 04:38:57 EDT (Tue, 17 Mar 2009)
New Revision: 51813
URL: http://svn.boost.org/trac/boost/changeset/51813

Log:
[mirror 0.3.x]
- added support for traversals on namespaces

Added:
   sandbox/mirror/libs/mirror/example/traversal/meta_path_full.cpp (contents, props changed)
Text files modified:
   sandbox/mirror/boost/mirror/detail/traversal.hpp | 641 ++++++++++++++++++++++-----------------
   sandbox/mirror/boost/mirror/traversal.hpp | 114 ++++++
   sandbox/mirror/boost/mirror/visitors/meta_path_sample.hpp | 33 ++
   sandbox/mirror/boost/mirror/visitors/sample.hpp | 44 ++
   sandbox/mirror/libs/mirror/example/Jamfile.v2 | 1
   5 files changed, 541 insertions(+), 292 deletions(-)

Modified: sandbox/mirror/boost/mirror/detail/traversal.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/detail/traversal.hpp (original)
+++ sandbox/mirror/boost/mirror/detail/traversal.hpp 2009-03-17 04:38:57 EDT (Tue, 17 Mar 2009)
@@ -15,7 +15,7 @@
 #include <boost/mirror/meta_path/node_context.hpp>
 //
 #include <boost/ref.hpp>
-#include <boost/type_traits/remove_reference.hpp>
+#include <boost/type_traits/remove_reference.hpp>
 //
 #include <assert.h>
 
@@ -23,318 +23,389 @@
 namespace mirror {
 
 
-template <class MetaClass, class NodePath> class deep_traversal_of;
-template <class MetaClass, class NodePath> class flat_traversal_of;
+template <
+ class MetaStructure,
+ class NodePath = mpl::vector0<>
+> class deep_traversal_of;
+
+template <
+ class MetaStructure,
+ class NodePath = mpl::vector0<>
+> class flat_traversal_of;
 
 namespace detail {
 
- template <
- class MetaClass,
- class NodePath,
- class MetaAttributes,
- template <class, class> class TraversalType
- >
- struct traversal_utils
+template <
+ class MetaClass,
+ class NodePath,
+ class MetaAttributes,
+ template <class, class> class TraversalType
+>
+struct class_traversal_utils
+{
+protected:
+ typedef typename mpl::push_back<NodePath, MetaClass>::type
+ ClassNodePath;
+
+ typedef typename remove_reference<
+ typename MetaClass::reflected_type
+ >::type* InstancePtr;
+
+
+ template <class VisitorType>
+ class attribute_traversal
         {
- protected:
- typedef typename mpl::push_back<NodePath, MetaClass>::type
- ClassNodePath;
-
- typedef typename remove_reference<
- typename MetaClass::reflected_type
- >::type* InstancePtr;
-
-
-
- template <class VisitorType>
- class attribute_traversal
- {
- public:
- inline attribute_traversal(
- reference_wrapper<VisitorType> _visitor,
- InstancePtr _ptr_to_inst
- )
- : visitor(_visitor)
- , ptr_to_inst(_ptr_to_inst)
- {
- visitor.enter_attributes(
- MetaClass(),
- MetaAttributes(),
- meta_path::make_node_context(
- ClassNodePath(),
- MetaAttributes()
- )
- );
- }
-
- inline ~attribute_traversal(void)
- {
- visitor.leave_attributes(
- MetaClass(),
- MetaAttributes(),
- meta_path::make_node_context(
- ClassNodePath(),
- MetaAttributes()
- )
- );
- }
-
- template <class MetaAttribute>
- inline void operator ()(MetaAttribute ma) const
- {
- // update the traversal context
- typename mpl::push_back<
- ClassNodePath,
- MetaAttributes
- >::type path;
- //
- // process a single attribute
- process_single(
- ma,
- path,
- typename VisitorType::works_on_instances()
- );
- }
- private:
- VisitorType& visitor;
- InstancePtr ptr_to_inst;
-
- // process single attribute WITH an instance
- template <class MetaAttribute, class AttribsNodePath>
- void inline process_single(
- MetaAttribute ma,
- AttribsNodePath path,
- mpl::bool_<true>
- ) const
- {
- // enter the attribute
- visitor.enter_attribute(
- ma,
- meta_path::make_node_context(
- path,
- ma
- )
- );
- //
- // the poiner has to be valid
- assert(ptr_to_inst != 0);
- //
- // get an attribute instance
- typedef BOOST_TYPEOF(ma.get(*ptr_to_inst)) instance_type;
- instance_type instance(ma.get(*ptr_to_inst));
- //
- // traverse the attribute
- TraversalType<
- typename MetaAttribute::type,
- typename mpl::push_back<
- AttribsNodePath,
- MetaAttribute
- >::type
- >::accept(visitor, &instance);
- //
- // leave the attribute
- visitor.leave_attribute(
- ma,
- meta_path::make_node_context(
- path,
- ma
- )
- );
- }
-
- // process single attribute W/O an instance
- template <class MetaAttribute, class AttribsNodePath>
- void inline process_single(
- MetaAttribute ma,
- AttribsNodePath path,
- mpl::bool_<false>
- ) const
- {
- // enter the attribute
- visitor.enter_attribute(
- ma,
- meta_path::make_node_context(
- path,
- ma
- )
- );
- //
- // traverse the attributes
- TraversalType<
- typename MetaAttribute::type,
- typename mpl::push_back<
- AttribsNodePath,
- MetaAttribute
- >::type
- >::accept(visitor, 0);
- //
- // leave the attributes
- visitor.leave_attribute(
- ma,
- meta_path::make_node_context(
- path,
- ma
- )
- );
- }
- };
-
- // attribute_traversal factory function
- template <class VisitorType>
- static inline attribute_traversal<VisitorType>
- show_attribs_to(
- reference_wrapper<VisitorType> visitor,
- InstancePtr ptr_to_inst
+ public:
+ inline attribute_traversal(
+ reference_wrapper<VisitorType> _visitor,
+ InstancePtr _ptr_to_inst
                 )
+ : visitor(_visitor)
+ , ptr_to_inst(_ptr_to_inst)
                 {
- return attribute_traversal<VisitorType>(visitor, ptr_to_inst);
+ visitor.enter_attributes(
+ MetaClass(),
+ MetaAttributes(),
+ meta_path::make_node_context(
+ ClassNodePath(),
+ MetaAttributes()
+ )
+ );
                 }
-
 
- template <class VisitorType>
- class base_class_traversal
+ inline ~attribute_traversal(void)
                 {
- public:
- inline base_class_traversal(
- reference_wrapper<VisitorType> _visitor,
- InstancePtr _ptr_to_inst
- )
- : visitor(_visitor)
- , ptr_to_inst(_ptr_to_inst)
- {
- visitor.enter_base_classes(
- MetaClass(),
- typename MetaClass::base_classes(),
- meta_path::make_node_context(
- ClassNodePath(),
- typename MetaClass::base_classes()
- )
- );
- }
-
- inline ~base_class_traversal(void)
- {
- visitor.leave_base_classes(
- MetaClass(),
- typename MetaClass::base_classes(),
- meta_path::make_node_context(
- ClassNodePath(),
- typename MetaClass::base_classes()
- )
- );
- }
-
- template <class MetaInheritance>
- inline void operator ()(MetaInheritance mbc) const
- {
- typedef typename mpl::push_back<
- ClassNodePath,
- typename MetaClass::base_classes
- >::type BaseClassesNodePath;
- BaseClassesNodePath path;
- //
- // enter the base cass
- visitor.enter_base_class(
- mbc,
- meta_path::make_node_context(
- path,
- mbc
- )
- );
- //
- // get the meta-class of the base class
- typedef typename MetaInheritance::base_class
- meta_base_class;
- // traverse the base class
- TraversalType<
- meta_base_class,
- typename mpl::push_back<
- BaseClassesNodePath,
- MetaInheritance
- >::type
- >::accept(visitor, ptr_to_inst);
- // leave the base class
- visitor.leave_base_class(
- mbc,
- meta_path::make_node_context(
- path,
- mbc
- )
- );
- }
- private:
- VisitorType& visitor;
- InstancePtr ptr_to_inst;
- };
-
- // base class traversal factory function
- template <class VisitorType>
- static inline base_class_traversal<VisitorType>
- show_bases_to(
- reference_wrapper<VisitorType> visitor,
- InstancePtr ptr_to_inst
- )
- {
- return base_class_traversal<VisitorType>(visitor, ptr_to_inst);
+ visitor.leave_attributes(
+ MetaClass(),
+ MetaAttributes(),
+ meta_path::make_node_context(
+ ClassNodePath(),
+ MetaAttributes()
+ )
+ );
                 }
 
- template <
- class VisitorType,
- class InstanceType
- >
- inline static void lead_to_instance(
- reference_wrapper<VisitorType> visitor,
- MetaClass mc,
- NodePath path,
- InstanceType* ptr_to_inst
- )
+ template <class MetaAttribute>
+ inline void operator ()(MetaAttribute ma) const
                 {
- do_lead_to_instance(
- visitor,
- mc,
+ // update the traversal context
+ typename mpl::push_back<
+ ClassNodePath,
+ MetaAttributes
+ >::type path;
+ //
+ // process a single attribute
+ process_single(
+ ma,
                                 path,
- ptr_to_inst,
                                 typename VisitorType::works_on_instances()
                         );
                 }
-
         private:
- template <
- class VisitorType,
- class InstanceType
- >
- inline static void do_lead_to_instance(
- reference_wrapper<VisitorType> visitor,
- MetaClass,
- NodePath,
- InstanceType* ptr_to_inst,
- mpl::bool_<false>
- ){ }
+ VisitorType& visitor;
+ InstancePtr ptr_to_inst;
 
- template <
- class VisitorType,
- class InstanceType
- >
- inline static void do_lead_to_instance(
- reference_wrapper<VisitorType> visitor,
- MetaClass mc,
- NodePath path,
- InstanceType* ptr_to_inst,
+ // process single attribute WITH an instance
+ template <class MetaAttribute, class AttribsNodePath>
+ void inline process_single(
+ MetaAttribute ma,
+ AttribsNodePath path,
                         mpl::bool_<true>
+ ) const
+ {
+ // enter the attribute
+ visitor.enter_attribute(
+ ma,
+ meta_path::make_node_context(
+ path,
+ ma
+ )
+ );
+ //
+ // the poiner has to be valid
+ assert(ptr_to_inst != 0);
+ //
+ // get an attribute instance
+ typedef BOOST_TYPEOF(ma.get(*ptr_to_inst)) instance_type;
+ instance_type instance(ma.get(*ptr_to_inst));
+ //
+ // traverse the attribute
+ TraversalType<
+ typename MetaAttribute::type,
+ typename mpl::push_back<
+ AttribsNodePath,
+ MetaAttribute
+ >::type
+ >::accept(visitor, &instance);
+ //
+ // leave the attribute
+ visitor.leave_attribute(
+ ma,
+ meta_path::make_node_context(
+ path,
+ ma
+ )
+ );
+ }
+
+ // process single attribute W/O an instance
+ template <class MetaAttribute, class AttribsNodePath>
+ void inline process_single(
+ MetaAttribute ma,
+ AttribsNodePath path,
+ mpl::bool_<false>
+ ) const
+ {
+ // enter the attribute
+ visitor.enter_attribute(
+ ma,
+ meta_path::make_node_context(
+ path,
+ ma
+ )
+ );
+ //
+ // traverse the attributes
+ TraversalType<
+ typename MetaAttribute::type,
+ typename mpl::push_back<
+ AttribsNodePath,
+ MetaAttribute
+ >::type
+ >::accept(visitor, 0);
+ //
+ // leave the attributes
+ visitor.leave_attribute(
+ ma,
+ meta_path::make_node_context(
+ path,
+ ma
+ )
+ );
+ }
+ };
+
+ // attribute_traversal factory function
+ template <class VisitorType>
+ static inline attribute_traversal<VisitorType>
+ show_attribs_to(
+ reference_wrapper<VisitorType> visitor,
+ InstancePtr ptr_to_inst
+ )
+ {
+ return attribute_traversal<VisitorType>(visitor, ptr_to_inst);
+ }
+
+
+ template <class VisitorType>
+ class base_class_traversal
+ {
+ public:
+ inline base_class_traversal(
+ reference_wrapper<VisitorType> _visitor,
+ InstancePtr _ptr_to_inst
                 )
+ : visitor(_visitor)
+ , ptr_to_inst(_ptr_to_inst)
+ {
+ visitor.enter_base_classes(
+ MetaClass(),
+ typename MetaClass::base_classes(),
+ meta_path::make_node_context(
+ ClassNodePath(),
+ typename MetaClass::base_classes()
+ )
+ );
+ }
+
+ inline ~base_class_traversal(void)
                 {
- visitor.get().visit_instance(
- mc,
+ visitor.leave_base_classes(
+ MetaClass(),
+ typename MetaClass::base_classes(),
+ meta_path::make_node_context(
+ ClassNodePath(),
+ typename MetaClass::base_classes()
+ )
+ );
+ }
+
+ template <class MetaInheritance>
+ inline void operator ()(MetaInheritance mbc) const
+ {
+ typedef typename mpl::push_back<
+ ClassNodePath,
+ typename MetaClass::base_classes
+ >::type BaseClassesNodePath;
+ BaseClassesNodePath path;
+ //
+ // enter the base cass
+ visitor.enter_base_class(
+ mbc,
                                 meta_path::make_node_context(
                                         path,
- mc
- ),
- ptr_to_inst
+ mbc
+ )
+ );
+ //
+ // get the meta-class of the base class
+ typedef typename MetaInheritance::base_class
+ meta_base_class;
+ // traverse the base class
+ TraversalType<
+ meta_base_class,
+ typename mpl::push_back<
+ BaseClassesNodePath,
+ MetaInheritance
+ >::type
+ >::accept(visitor, ptr_to_inst);
+ // leave the base class
+ visitor.leave_base_class(
+ mbc,
+ meta_path::make_node_context(
+ path,
+ mbc
+ )
+ );
+ }
+ private:
+ VisitorType& visitor;
+ InstancePtr ptr_to_inst;
+ };
+
+ // base class traversal factory function
+ template <class VisitorType>
+ static inline base_class_traversal<VisitorType>
+ show_bases_to(
+ reference_wrapper<VisitorType> visitor,
+ InstancePtr ptr_to_inst
+ )
+ {
+ return base_class_traversal<VisitorType>(visitor, ptr_to_inst);
+ }
+
+ template <
+ class VisitorType,
+ class InstanceType
+ >
+ inline static void lead_to_instance(
+ reference_wrapper<VisitorType> visitor,
+ MetaClass mc,
+ NodePath path,
+ InstanceType* ptr_to_inst
+ )
+ {
+ do_lead_to_instance(
+ visitor,
+ mc,
+ path,
+ ptr_to_inst,
+ typename VisitorType::works_on_instances()
+ );
+ }
+
+private:
+ template <
+ class VisitorType,
+ class InstanceType
+ >
+ inline static void do_lead_to_instance(
+ reference_wrapper<VisitorType> visitor,
+ MetaClass,
+ NodePath,
+ InstanceType* ptr_to_inst,
+ mpl::bool_<false>
+ ){ }
+
+ template <
+ class VisitorType,
+ class InstanceType
+ >
+ inline static void do_lead_to_instance(
+ reference_wrapper<VisitorType> visitor,
+ MetaClass mc,
+ NodePath path,
+ InstanceType* ptr_to_inst,
+ mpl::bool_<true>
+ )
+ {
+ visitor.get().visit_instance(
+ mc,
+ meta_path::make_node_context(
+ path,
+ mc
+ ),
+ ptr_to_inst
+ );
+ }
+
+};
+
+/** Base implementation of namespace traversal
+ */
+template <
+ class MetaNamespace,
+ class NodePath,
+ template <class, class> class TraversalType
+> class namespace_traversal_utils
+{
+private:
+ typedef typename mpl::push_back<
+ NodePath,
+ MetaNamespace
+ >::type NamespaceNodePath;
+protected:
+ template <class VisitorType, class Members>
+ struct namespace_member_traversal
+ {
+ reference_wrapper<VisitorType> visitor;
+
+ typedef typename mpl::push_back<
+ NamespaceNodePath,
+ Members
+ >::type MembersNodePath;
+
+ inline namespace_member_traversal(
+ reference_wrapper<VisitorType> _visitor
+ ): visitor(_visitor)
+ {
+ visitor.get().enter_namespace_members(
+ Members(),
+ meta_path::make_node_context(
+ NamespaceNodePath(),
+ Members()
+ )
                         );
                 }
 
+ template <class MetaObject>
+ inline void operator ()(MetaObject mo) const
+ {
+ TraversalType<
+ MetaObject,
+ MembersNodePath
+ >::accept(visitor);
+ }
+
+ inline ~namespace_member_traversal(void)
+ {
+ visitor.get().leave_namespace_members(
+ Members(),
+ meta_path::make_node_context(
+ NamespaceNodePath(),
+ Members()
+ )
+ );
+ }
         };
 
+ template <class Members, class VisitorType>
+ static inline namespace_member_traversal<VisitorType, Members>
+ show_namespace_members_to(reference_wrapper<VisitorType> _visitor, Members)
+ {
+ return namespace_member_traversal<VisitorType, Members>(_visitor);
+ }
+};
 
 } // namespace detail
 } // namespace mirror

Modified: sandbox/mirror/boost/mirror/traversal.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/traversal.hpp (original)
+++ sandbox/mirror/boost/mirror/traversal.hpp 2009-03-17 04:38:57 EDT (Tue, 17 Mar 2009)
@@ -16,9 +16,12 @@
 namespace mirror {
 
 
-template <class MetaClass, class NodePath = mpl::vector0<> >
-class deep_traversal_of
-: detail::traversal_utils<
+template <
+ class MetaClass,
+ class NodePath
+>
+class deep_traversal_of_class
+: detail::class_traversal_utils<
         MetaClass,
         NodePath,
         typename MetaClass::attributes,
@@ -85,10 +88,13 @@
         }
 };
 
-template <class MetaClass, class NodePath = mpl::vector0<> >
-class flat_traversal_of
-: detail::traversal_utils<
- MetaClass,
+template <
+ class MetaClass,
+ class NodePath
+>
+class flat_traversal_of_class
+: detail::class_traversal_utils<
+ MetaClass,
         NodePath,
         typename MetaClass::all_attributes,
         flat_traversal_of
@@ -107,6 +113,7 @@
         {
                 do_accept(ref<VisitorType>(visitor), ptr_to_inst);
         }
+
         template <class VisitorType>
         static inline void accept(
                 reference_wrapper<VisitorType> visitor,
@@ -149,6 +156,99 @@
         }
 };
 
+template < class Class, class VariantTag, class NodePath >
+class deep_traversal_of<meta_class<Class, VariantTag>, NodePath>
+: public deep_traversal_of_class<meta_class<Class, VariantTag>, NodePath>
+{ };
+
+template < class Type, class NodePath >
+class deep_traversal_of<meta_type<Type>, NodePath>
+: public deep_traversal_of_class<meta_class<Type>, NodePath>
+{ };
+
+template < class Class, class VariantTag, class NodePath >
+class flat_traversal_of<meta_class<Class, VariantTag>, NodePath>
+: public flat_traversal_of_class<meta_class<Class, VariantTag>, NodePath>
+{ };
+
+template < class Type, class NodePath >
+class flat_traversal_of<meta_type<Type>, NodePath>
+: public flat_traversal_of_class<meta_class<Type>, NodePath>
+{ };
+
+/** Traversal of namespace
+ */
+template <
+ class MetaNamespace,
+ class NodePath,
+ template <class, class> class TraversalType
+> class traversal_of_namespace
+: detail::namespace_traversal_utils<MetaNamespace, NodePath, TraversalType>
+{
+public:
+ template <class VisitorType>
+ static inline void accept(VisitorType visitor)
+ {
+ do_accept(ref<VisitorType>(visitor));
+ }
+
+ template <class VisitorType>
+ static void accept(reference_wrapper<VisitorType> visitor)
+ {
+ do_accept(visitor);
+ }
+private:
+
+ template <class VisitorType>
+ static void do_accept(reference_wrapper<VisitorType> visitor)
+ {
+ MetaNamespace mn;
+ NodePath path;
+ // let the visitor enter the namespace
+ visitor.get().enter_namespace(
+ mn,
+ meta_path::make_node_context(
+ path,
+ mn
+ )
+ );
+ typedef typename MetaNamespace::template members<>::type
+ members;
+ // show the visitor through all the members of
+ // the namespace
+ for_each<members>(
+ cref(show_namespace_members_to(
+ visitor,
+ members()
+ ))
+ );
+ // the visitor leaves the namespace
+ visitor.get().leave_namespace(
+ mn,
+ meta_path::make_node_context(
+ path,
+ mn
+ )
+ );
+ }
+};
+
+template <class Placeholder, class NodePath>
+class deep_traversal_of<meta_namespace<Placeholder>, NodePath>
+ : public traversal_of_namespace<
+ meta_namespace<Placeholder>,
+ NodePath,
+ deep_traversal_of
+>{ };
+
+template <class Placeholder, class NodePath>
+class flat_traversal_of<meta_namespace<Placeholder>, NodePath>
+ : public traversal_of_namespace<
+ meta_namespace<Placeholder>,
+ NodePath,
+ flat_traversal_of
+>{ };
+
 } // namespace mirror
 } // namespace boost
 

Modified: sandbox/mirror/boost/mirror/visitors/meta_path_sample.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/visitors/meta_path_sample.hpp (original)
+++ sandbox/mirror/boost/mirror/visitors/meta_path_sample.hpp 2009-03-17 04:38:57 EDT (Tue, 17 Mar 2009)
@@ -127,6 +127,20 @@
                         cts::bcout() << "|type '" << mc.base_name() << "'|";
                         print_indent();
                 }
+
+ template <class Placeholder>
+ void operator()(meta_namespace<Placeholder> mn) const
+ {
+ cts::bcout() << "|namespace '" << mn.base_name() << "'|";
+ print_indent();
+ }
+
+ template <class Unknown>
+ void operator()(Unknown) const
+ {
+ cts::bcout() << "|unknown |";
+ print_indent();
+ }
         };
         
 } // namespace detail
@@ -136,6 +150,25 @@
 public:
         typedef mpl::bool_<false> works_on_instances;
 
+ // enter a namespace
+ template <class MetaNamespace, class Context>
+ void enter_namespace(MetaNamespace, Context)
+ {
+ print_node(MetaNamespace(), Context());
+ }
+
+ // leave the namespace
+ template <class MetaNamespace, class Context>
+ void leave_namespace(MetaNamespace, Context) { }
+
+ template <class MetaObjectSequence, class Context>
+ void enter_namespace_members(MetaObjectSequence, Context) { }
+
+ template <class MetaObjectSequence, class Context>
+ void leave_namespace_members(MetaObjectSequence, Context) { }
+
+
+
         // enter a class/type
         template <class MetaClass, class Context>
         void enter_type(MetaClass, Context)

Modified: sandbox/mirror/boost/mirror/visitors/sample.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/visitors/sample.hpp (original)
+++ sandbox/mirror/boost/mirror/visitors/sample.hpp 2009-03-17 04:38:57 EDT (Tue, 17 Mar 2009)
@@ -35,6 +35,50 @@
 
         sample_visitor(void):indent(0){ }
 
+ // enter a namespace
+ template <class MetaNamespace, class Context>
+ void enter_namespace(MetaNamespace, Context)
+ {
+ using namespace ::std;
+ using namespace ::boost;
+ print_indentation();
+ ++indent;
+ cts::bcout() <<
+ "<namespace name='" <<
+ MetaNamespace::base_name();
+ if(!reflects_global_scope<typename MetaNamespace::scope>::value)
+ {
+ cts::bcout() <<
+ "' scope='" <<
+ MetaNamespace::scope::full_name();
+ }
+ cts::bcout() <<
+ "'>" <<
+ endl;
+ }
+
+ // leave the namespace
+ template <class MetaNamespace, class Context>
+ void leave_namespace(MetaNamespace, Context)
+ {
+ using namespace ::std;
+ using namespace ::boost;
+ --indent;
+ print_indentation();
+ cts::bcout() << "</namespace>" << endl;
+ }
+
+ template <class MetaObjectSequence, class Context>
+ void enter_namespace_members(MetaObjectSequence, Context)
+ {
+ }
+
+ template <class MetaObjectSequence, class Context>
+ void leave_namespace_members(MetaObjectSequence, Context)
+ {
+ }
+
+
         // enter a class/type
         template <class MetaClass, class Context>
         void enter_type(MetaClass, Context)

Modified: sandbox/mirror/libs/mirror/example/Jamfile.v2
==============================================================================
--- sandbox/mirror/libs/mirror/example/Jamfile.v2 (original)
+++ sandbox/mirror/libs/mirror/example/Jamfile.v2 2009-03-17 04:38:57 EDT (Tue, 17 Mar 2009)
@@ -32,6 +32,7 @@
 #
 # traversal by visitors
 #
+exe tvrsl_meta_path_full : traversal/meta_path_full.cpp ;
 exe tvrsl_sample_visitor : traversal/sample_visitor.cpp ;
 exe tvrsl_meta_path_visitor : traversal/sample_meta_path.cpp ;
 #

Added: sandbox/mirror/libs/mirror/example/traversal/meta_path_full.cpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/libs/mirror/example/traversal/meta_path_full.cpp 2009-03-17 04:38:57 EDT (Tue, 17 Mar 2009)
@@ -0,0 +1,203 @@
+/**
+ * \file examples/traversal/meta_path_full.cpp
+ *
+ * Example of full deep and flat traversal namespace
+ *
+ * NOTE: if You are not familiar with registration
+ * and reflection, You should probably
+ * see examples in examples/registering/ first.
+ *
+ * Copyright 2008 Matus Chochlik. Distributed under the Boost
+ * Software License, Version 1.0. (See accompanying file
+ * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+ */
+
+#include <boost/char_type_switch/iostream.hpp>
+
+#include <boost/mirror/meta_namespace.hpp>
+#include <boost/mirror/meta_type.hpp>
+#include <boost/mirror/meta_class.hpp>
+
+#include <boost/mirror/meta_types/std/pair.hpp>
+#include <boost/mirror/meta_types/boost/tuples/tuple.hpp>
+#include <boost/mirror/meta_classes/boost/tuples/tuple.hpp>
+
+#include <boost/mirror/meta_path/ancestors.hpp>
+#include <boost/mirror/meta_path/size.hpp>
+
+#include <boost/mirror/visitors/meta_path_sample.hpp>
+#include <boost/mirror/traversal.hpp>
+
+/** First declare some namespaces and classes
+ */
+
+namespace test {
+namespace ns_1 {
+
+namespace ns_1_1 {
+
+struct A
+{
+ int a;
+};
+
+} // namespace ns_1_1
+
+namespace ns_1_2 {
+
+struct B
+{
+ int b;
+};
+
+} // namespace ns_1_2
+
+namespace ns_1_3 {
+
+struct C
+{
+ int c;
+};
+
+} // namespace ns_1_2
+
+} // namespace ns_1
+
+namespace ns_2 {
+
+namespace ns_2_1 {
+
+struct D
+{
+ int d;
+};
+
+} // namespace ns_2_1
+
+namespace ns_2_2 {
+
+struct E
+{
+ int e;
+};
+
+} // namespace ns_2_2
+
+namespace ns_2_3 {
+
+struct F
+{
+ int f;
+};
+
+} // namespace ns_2_3
+
+struct G
+: ns_1::ns_1_1::A
+, ns_1::ns_1_2::B
+, ns_1::ns_1_3::C
+, ns_2::ns_2_1::D
+, ns_2::ns_2_2::E
+, ns_2::ns_2_3::F
+{
+ int g;
+};
+
+} // namespace ns_2
+
+
+} // namespace test
+
+namespace boost {
+namespace mirror {
+
+/** Register the test namespace
+ */
+BOOST_MIRROR_REG_NAMESPACE((test))
+BOOST_MIRROR_REG_NAMESPACE((test)(ns_1))
+BOOST_MIRROR_REG_NAMESPACE((test)(ns_1)(ns_1_1))
+BOOST_MIRROR_REG_NAMESPACE((test)(ns_1)(ns_1_2))
+BOOST_MIRROR_REG_NAMESPACE((test)(ns_1)(ns_1_3))
+BOOST_MIRROR_REG_NAMESPACE((test)(ns_2))
+BOOST_MIRROR_REG_NAMESPACE((test)(ns_2)(ns_2_1))
+BOOST_MIRROR_REG_NAMESPACE((test)(ns_2)(ns_2_2))
+BOOST_MIRROR_REG_NAMESPACE((test)(ns_2)(ns_2_3))
+
+/** Register the types and classes
+ */
+BOOST_MIRROR_REG_TYPE(::test::ns_1::ns_1_1, A)
+BOOST_MIRROR_REG_TYPE(::test::ns_1::ns_1_2, B)
+BOOST_MIRROR_REG_TYPE(::test::ns_1::ns_1_3, C)
+BOOST_MIRROR_REG_TYPE(::test::ns_2::ns_2_1, D)
+BOOST_MIRROR_REG_TYPE(::test::ns_2::ns_2_2, E)
+BOOST_MIRROR_REG_TYPE(::test::ns_2::ns_2_3, F)
+BOOST_MIRROR_REG_TYPE(::test::ns_2, G)
+
+
+BOOST_MIRROR_REG_BASE_CLASSES_BEGIN(::test::ns_2::G)
+BOOST_MIRROR_REG_SIMPLE_BASE_CLASS(0, ::test::ns_1::ns_1_1::A)
+BOOST_MIRROR_REG_SIMPLE_BASE_CLASS(1, ::test::ns_1::ns_1_2::B)
+BOOST_MIRROR_REG_SIMPLE_BASE_CLASS(2, ::test::ns_1::ns_1_3::C)
+BOOST_MIRROR_REG_SIMPLE_BASE_CLASS(3, ::test::ns_2::ns_2_1::D)
+BOOST_MIRROR_REG_SIMPLE_BASE_CLASS(4, ::test::ns_2::ns_2_2::E)
+BOOST_MIRROR_REG_SIMPLE_BASE_CLASS(5, ::test::ns_2::ns_2_3::F)
+BOOST_MIRROR_REG_BASE_CLASSES_END
+
+
+/** Class attributes
+ */
+BOOST_MIRROR_REG_CLASS_ATTRIBS_BEGIN(::test::ns_1::ns_1_1::A)
+ BOOST_MIRROR_REG_AUTO_CLASS_ATTRIB(_, a)
+BOOST_MIRROR_REG_CLASS_ATTRIBS_END
+
+BOOST_MIRROR_REG_CLASS_ATTRIBS_BEGIN(::test::ns_1::ns_1_2::B)
+ BOOST_MIRROR_REG_AUTO_CLASS_ATTRIB(_, b)
+BOOST_MIRROR_REG_CLASS_ATTRIBS_END
+
+BOOST_MIRROR_REG_CLASS_ATTRIBS_BEGIN(::test::ns_1::ns_1_3::C)
+ BOOST_MIRROR_REG_AUTO_CLASS_ATTRIB(_, c)
+BOOST_MIRROR_REG_CLASS_ATTRIBS_END
+
+BOOST_MIRROR_REG_CLASS_ATTRIBS_BEGIN(::test::ns_2::ns_2_1::D)
+ BOOST_MIRROR_REG_AUTO_CLASS_ATTRIB(_, d)
+BOOST_MIRROR_REG_CLASS_ATTRIBS_END
+
+BOOST_MIRROR_REG_CLASS_ATTRIBS_BEGIN(::test::ns_2::ns_2_2::E)
+ BOOST_MIRROR_REG_AUTO_CLASS_ATTRIB(_, e)
+BOOST_MIRROR_REG_CLASS_ATTRIBS_END
+
+BOOST_MIRROR_REG_CLASS_ATTRIBS_BEGIN(::test::ns_2::ns_2_3::F)
+ BOOST_MIRROR_REG_AUTO_CLASS_ATTRIB(_, f)
+BOOST_MIRROR_REG_CLASS_ATTRIBS_END
+
+BOOST_MIRROR_REG_CLASS_ATTRIBS_BEGIN(::test::ns_2::G)
+ BOOST_MIRROR_REG_AUTO_CLASS_ATTRIB(_, g)
+BOOST_MIRROR_REG_CLASS_ATTRIBS_END
+
+} // namespace mirror
+} // namespace boost
+
+
+int main(void)
+{
+ using namespace ::std;
+ using namespace ::boost;
+ using namespace ::boost::mirror;
+ //
+ cts::bostream& bcout = cts::bcout();
+ //
+ typedef BOOST_MIRRORED_NAMESPACE(::test) meta_test;
+ //
+ /** NOTE: this will only visit the test namespace with compilers
+ * for which the BOOST_MIRROR_NO_GLOBAL_LISTS macro is defined
+ */
+ //
+ bcout << "--------------------------------------------" << endl;
+ deep_traversal_of<meta_test>::accept(meta_path_sample_visitor());
+ bcout << "--------------------------------------------" << endl;
+ flat_traversal_of<meta_test>::accept(meta_path_sample_visitor());
+ bcout << "--------------------------------------------" << endl;
+ //
+ //
+ return 0;
+}


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk