Boost logo

Boost-Commit :

From: chochlik_at_[hidden]
Date: 2008-06-26 14:02:40


Author: matus.chochlik
Date: 2008-06-26 14:02:39 EDT (Thu, 26 Jun 2008)
New Revision: 46734
URL: http://svn.boost.org/trac/boost/changeset/46734

Log:
Added accumulate algorithm working on meta-object-sequences
Added a new meta-path axes (ancestors_and_self, siblings, siblings_and_self)
Updated the meta_path_sample.hpp to show the new things
Tested with MSVC++ 2008 EE On Vista
Added:
   sandbox/mirror/boost/mirror/algorithm/accumulate.hpp (contents, props changed)
   sandbox/mirror/boost/mirror/algorithm/detail/accumulate.hpp (contents, props changed)
   sandbox/mirror/boost/mirror/meta_path/ancestors_and_self.hpp (contents, props changed)
   sandbox/mirror/boost/mirror/meta_path/siblings.hpp (contents, props changed)
   sandbox/mirror/boost/mirror/meta_path/siblings_and_self.hpp (contents, props changed)
Text files modified:
   sandbox/mirror/boost/mirror/algorithm/for_each.hpp | 1 -
   sandbox/mirror/boost/mirror/meta_path/ancestors.hpp | 15 +++++++++++++--
   sandbox/mirror/boost/mirror/visitors/meta_path_sample.hpp | 14 +++++++++++++-
   sandbox/mirror/libs/mirror/doc/xml/mirror/_library.xml | 10 ++++++++++
   4 files changed, 36 insertions(+), 4 deletions(-)

Added: sandbox/mirror/boost/mirror/algorithm/accumulate.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/algorithm/accumulate.hpp 2008-06-26 14:02:39 EDT (Thu, 26 Jun 2008)
@@ -0,0 +1,54 @@
+/**
+ * \file boost/mirror/algorithm/accumulate.hpp
+ *
+ *
+ * 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)
+ */
+
+#ifndef BOOST_MIRROR_ALGORITHM_ACCUMULATE_HPP
+#define BOOST_MIRROR_ALGORITHM_ACCUMULATE_HPP
+
+#include <boost/mirror/algorithm/detail/accumulate.hpp>
+#include <boost/mirror/algorithm/begin.hpp>
+#include <boost/mirror/algorithm/end.hpp>
+
+namespace boost {
+namespace mirror {
+
+template <
+ class MetaObjectSequence,
+ class InitialState,
+ class ForwardOp
+>
+struct accumulate
+: detail::accumulate<
+ typename begin<MetaObjectSequence>::type,
+ typename end<MetaObjectSequence>::type,
+ InitialState,
+ ForwardOp
+>
+{ };
+
+template <
+ class IteratorBegin,
+ class IteratorEnd,
+ class InitialState,
+ class ForwardOp
+>
+struct accumulate_on_range
+: detail::accumulate<
+ IteratorBegin,
+ IteratorEnd,
+ InitialState,
+ ForwardOp
+>
+{ };
+
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+

Added: sandbox/mirror/boost/mirror/algorithm/detail/accumulate.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/algorithm/detail/accumulate.hpp 2008-06-26 14:02:39 EDT (Thu, 26 Jun 2008)
@@ -0,0 +1,61 @@
+/**
+ * \file boost/mirror/algorithm/detail/accumulate.hpp
+ * Implementation of the accumulate algorithm
+ *
+ * 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)
+ */
+
+#ifndef BOOST_MIRROR_ALGORITHM_DETAIL_ACCUMULATE_HPP
+#define BOOST_MIRROR_ALGORITHM_DETAIL_ACCUMULATE_HPP
+
+#include <boost/mirror/algorithm/detail/iterative.hpp>
+#include <boost/mirror/algorithm/next.hpp>
+
+namespace boost {
+namespace mirror {
+namespace detail {
+
+template <
+ class Current,
+ class End,
+ class State,
+ class ForwardOp
+>
+struct accumulate
+{
+ typedef typename accumulate<
+ typename next<Current>::type,
+ End,
+ typename ForwardOp::template apply<
+ State,
+ typename deref<Current>::type
+ >::type,
+ ForwardOp
+ >::type type;
+};
+
+template <
+ class End,
+ class State,
+ class ForwardOp
+>
+struct accumulate<
+ End,
+ End,
+ State,
+ ForwardOp
+>
+{
+ typedef State type;
+};
+
+
+
+} // namespace detail
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+

Modified: sandbox/mirror/boost/mirror/algorithm/for_each.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/algorithm/for_each.hpp (original)
+++ sandbox/mirror/boost/mirror/algorithm/for_each.hpp 2008-06-26 14:02:39 EDT (Thu, 26 Jun 2008)
@@ -89,7 +89,6 @@
                 typename mirror::end<MetaObjectSequence>::type
> ::perform(ref(fn), ref(transf));
 }
-
 template <
         class IteratorBegin,
         class IteratorEnd,

Modified: sandbox/mirror/boost/mirror/meta_path/ancestors.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/meta_path/ancestors.hpp (original)
+++ sandbox/mirror/boost/mirror/meta_path/ancestors.hpp 2008-06-26 14:02:39 EDT (Thu, 26 Jun 2008)
@@ -26,7 +26,7 @@
 
 namespace detail {
 
- template <class NodeContext>
+ template <class NodeContext, class IncludeSelf>
         struct ancestors_base
         {
         private:
@@ -95,6 +95,15 @@
>,
                                         if_empty,
                                         if_not_empty
+ >::type ancestor_paths_and_nodes;
+
+ typedef typename mpl::if_<
+ IncludeSelf,
+ typename mpl::push_back<
+ ancestor_paths_and_nodes,
+ Pair
+ >::type,
+ ancestor_paths_and_nodes
>::type type;
                         };
                 };
@@ -113,7 +122,9 @@
  * given node context
  */
 template <class NodeContext>
-struct ancestors : node_set<detail::ancestors_base<NodeContext> >
+struct ancestors : node_set<
+ detail::ancestors_base<NodeContext, mpl::false_>
+>
 {
         typedef ancestors<NodeContext> type;
 };

Added: sandbox/mirror/boost/mirror/meta_path/ancestors_and_self.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/meta_path/ancestors_and_self.hpp 2008-06-26 14:02:39 EDT (Thu, 26 Jun 2008)
@@ -0,0 +1,35 @@
+/**
+ * \file boost/mirror/meta_path/ancestors_and_self.hpp
+ *
+ * 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)
+ */
+
+#ifndef BOOST_MIRROR_META_PATH_ANCESTORS_AND_SELF_HPP
+#define BOOST_MIRROR_META_PATH_ANCESTORS_AND_SELF_HPP
+
+#include <boost/mirror/meta_path/ancestors.hpp>
+
+namespace boost {
+namespace mirror {
+namespace meta_path {
+
+
+/** A nodeset containing ancestor and self nodes of the
+ * given node context
+ */
+template <class NodeContext>
+struct ancestors_and_self : node_set<
+ detail::ancestors_base<NodeContext, mpl::true_>
+>
+{
+ typedef ancestors_and_self<NodeContext> type;
+};
+
+} // namespace meta_path
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+

Added: sandbox/mirror/boost/mirror/meta_path/siblings.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/meta_path/siblings.hpp 2008-06-26 14:02:39 EDT (Thu, 26 Jun 2008)
@@ -0,0 +1,202 @@
+/**
+ * \file boost/mirror/meta_path/siblings.hpp
+ *
+ * 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)
+ */
+
+#ifndef BOOST_MIRROR_META_PATH_SIBLINGS_HPP
+#define BOOST_MIRROR_META_PATH_SIBLINGS_HPP
+
+#include <boost/mirror/meta_path/node_context.hpp>
+#include <boost/mirror/algorithm/accumulate.hpp>
+#include <boost/mpl/vector.hpp>
+#include <boost/mpl/pair.hpp>
+#include <boost/mpl/front.hpp>
+#include <boost/mpl/pop_front.hpp>
+#include <boost/mpl/back.hpp>
+#include <boost/mpl/push_back.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/mpl/eval_if.hpp>
+#include <boost/mpl/and.hpp>
+#include <boost/mpl/not.hpp>
+#include <boost/mpl/empty.hpp>
+#include <boost/type_traits/is_same.hpp>
+
+namespace boost {
+namespace mirror {
+namespace meta_path {
+
+namespace detail {
+
+ template <
+ class PathsAndNodes,
+ class Pair,
+ class Node,
+ class IncludeSelf
+ >
+ struct siblings_base_process_single_path_and_node_apply
+ {
+ typedef typename mpl::if_<
+ IncludeSelf,
+ typename mpl::push_back<
+ PathsAndNodes,
+ Pair
+ >::type,
+ PathsAndNodes
+ >::type type;
+ };
+
+ template <
+ class PathsAndNodes,
+ class Pair,
+ class IncludeSelf
+ >
+ struct siblings_base_process_single_path_and_seq_elem_apply
+ {
+ typedef typename mpl::first<Pair>::type
+ path;
+
+ typedef typename mpl::back<
+ path
+ >::type meta_attribs;
+
+ struct append_sibling
+ {
+ template <
+ class PathsAndNodes,
+ class SiblingOrSelf
+ >
+ struct apply
+ {
+ typedef typename mpl::second<Pair>::type
+ Self;
+
+ typedef typename mpl::if_<
+ typename mpl::and_<
+ typename boost::is_same<
+ SiblingOrSelf,
+ Self
+ >::type,
+ typename mpl::not_<IncludeSelf>::type
+ >::type,
+ PathsAndNodes,
+ typename mpl::push_back<
+ PathsAndNodes,
+ mpl::pair<
+ path,
+ SiblingOrSelf
+ >
+ >::type
+ >::type type;
+
+ };
+ };
+
+
+ typedef typename mirror::accumulate<
+ meta_attribs,
+ PathsAndNodes,
+ append_sibling
+ >::type type;
+ };
+
+
+ template <
+ class PathsAndNodes,
+ class Pair,
+ class ReflectedType,
+ class VariantTag,
+ class MetaAttributes,
+ class AttribPos,
+ class IncludeSelf
+ >
+ struct siblings_base_process_single_path_and_node_apply<
+ PathsAndNodes,
+ Pair,
+ meta_class_attribute<
+ ReflectedType,
+ VariantTag,
+ MetaAttributes,
+ AttribPos
+ >,
+ IncludeSelf
+ > : siblings_base_process_single_path_and_seq_elem_apply<
+ PathsAndNodes,
+ Pair,
+ IncludeSelf
+ >{ };
+
+ template <
+ class PathsAndNodes,
+ class Pair,
+ class Position,
+ class BaseClass,
+ typename AccessSpec,
+ typename InheritanceSpec,
+ class IncludeSelf
+ >
+ struct siblings_base_process_single_path_and_node_apply<
+ PathsAndNodes,
+ Pair,
+ meta_inheritance<
+ Position,
+ BaseClass,
+ AccessSpec,
+ InheritanceSpec
+ >,
+ IncludeSelf
+ > : siblings_base_process_single_path_and_seq_elem_apply<
+ PathsAndNodes,
+ Pair,
+ IncludeSelf
+ >{ };
+
+
+ template <class NodeContext, class IncludeSelf>
+ struct siblings_base
+ {
+ private:
+ typedef typename NodeContext::paths_and_nodes
+ passed_paths_and_nodes;
+
+ struct process_single_path_and_node
+ {
+ template <class PathsAndNodes, class Pair>
+ struct apply
+ : siblings_base_process_single_path_and_node_apply<
+ PathsAndNodes,
+ Pair,
+ typename mpl::second<Pair>::type,
+ IncludeSelf
+ >{ };
+ };
+
+ public:
+ typedef typename mpl::accumulate<
+ passed_paths_and_nodes,
+ mpl::vector0<>,
+ process_single_path_and_node
+ >::type paths_and_nodes;
+ };
+
+} // namespace detail
+
+/** A nodeset containing sibling nodes of the
+ * given node context
+ */
+template <class NodeContext>
+struct siblings : node_set<
+ detail::siblings_base<NodeContext, mpl::false_>
+>
+{
+ typedef siblings<NodeContext> type;
+};
+
+} // namespace meta_path
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+

Added: sandbox/mirror/boost/mirror/meta_path/siblings_and_self.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/meta_path/siblings_and_self.hpp 2008-06-26 14:02:39 EDT (Thu, 26 Jun 2008)
@@ -0,0 +1,35 @@
+/**
+ * \file boost/mirror/meta_path/siblings_and_self.hpp
+ *
+ * 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)
+ */
+
+#ifndef BOOST_MIRROR_META_PATH_SIBLINGS_AND_SELF_HPP
+#define BOOST_MIRROR_META_PATH_SIBLINGS_AND_SELF_HPP
+
+#include <boost/mirror/meta_path/siblings.hpp>
+
+namespace boost {
+namespace mirror {
+namespace meta_path {
+
+
+/** A nodeset containing sibling nodes and self of the
+ * given node context
+ */
+template <class NodeContext>
+struct siblings_and_self : node_set<
+ detail::siblings_base<NodeContext, mpl::true_>
+>
+{
+ typedef siblings_and_self<NodeContext> type;
+};
+
+} // namespace meta_path
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+

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 2008-06-26 14:02:39 EDT (Thu, 26 Jun 2008)
@@ -27,6 +27,9 @@
 #include <boost/mirror/meta_path/self.hpp>
 #include <boost/mirror/meta_path/parent.hpp>
 #include <boost/mirror/meta_path/ancestors.hpp>
+#include <boost/mirror/meta_path/ancestors_and_self.hpp>
+#include <boost/mirror/meta_path/siblings.hpp>
+#include <boost/mirror/meta_path/siblings_and_self.hpp>
 #include <boost/mirror/meta_path/size.hpp>
 
 //
@@ -118,7 +121,13 @@
                         InheritanceSpec
> mi) const
                 {
- bcout << "|base_class|";
+ typedef typename meta_inheritance<
+ Position,
+ BaseClass,
+ AccessSpec,
+ InheritanceSpec
+ >::meta_base_class mbc;
+ bcout << "|base_class '" << mbc::base_name() << "'|";
                         print_indent();
                 }
         
@@ -223,6 +232,9 @@
                 print_node_set<meta_path::self>("self", mo, ctx);
                 print_node_set<meta_path::parent>("parent", mo, ctx);
                 print_node_set<meta_path::ancestors>("ancestors", mo, ctx);
+ print_node_set<meta_path::ancestors_and_self>("ancestors_and_self", mo, ctx);
+ print_node_set<meta_path::siblings>("siblings", mo, ctx);
+ print_node_set<meta_path::siblings_and_self>("siblings_and_self", mo, ctx);
         }
 
 };

Modified: sandbox/mirror/libs/mirror/doc/xml/mirror/_library.xml
==============================================================================
--- sandbox/mirror/libs/mirror/doc/xml/mirror/_library.xml (original)
+++ sandbox/mirror/libs/mirror/doc/xml/mirror/_library.xml 2008-06-26 14:02:39 EDT (Thu, 26 Jun 2008)
@@ -208,5 +208,15 @@
                         - Tested with gcc 4.3.0 on SuSE
                         - Tested with intel 10.1 on SuSE
                 </revision>
+ <revision id="20080626" major="0" minor="1" micro="31" author="m_ch">
+ - Added accumulate algorithm working on meta-object-sequences
+ - Added a new meta-path axes (ancestors_and_self, siblings, siblings_and_self)
+ - Updated the meta_path_sample.hpp to show the new things
+ - Tested with MSVC++ 2008 EE On Vista
+ - Tested with gcc 4.2.1 on FreeBSD
+ - Tested with gcc 4.2.1 on SuSE
+ - Tested with gcc 4.3.0 on SuSE
+ - Tested with intel 10.1 on SuSE
+ </revision>
         </revisions>
 </library>


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