Boost logo

Boost-Commit :

From: chochlik_at_[hidden]
Date: 2008-06-27 07:42:44


Author: matus.chochlik
Date: 2008-06-27 07:42:42 EDT (Fri, 27 Jun 2008)
New Revision: 46768
URL: http://svn.boost.org/trac/boost/changeset/46768

Log:
Added point_to meta-function
Added is_valid iterator meta-function
Added a new meta-path axes (prior and next)
Updated the meta_path_sample.hpp to show the new functionality

Added:
   sandbox/mirror/boost/mirror/algorithm/detail/point_to.hpp (contents, props changed)
   sandbox/mirror/boost/mirror/algorithm/is_valid.hpp (contents, props changed)
   sandbox/mirror/boost/mirror/algorithm/point_to.hpp (contents, props changed)
   sandbox/mirror/boost/mirror/meta_path/next.hpp (contents, props changed)
   sandbox/mirror/boost/mirror/meta_path/prior.hpp (contents, props changed)
Text files modified:
   sandbox/mirror/boost/mirror/algorithm/detail/common_iterator.hpp | 32 ++++++++++++++++++++------------
   sandbox/mirror/boost/mirror/algorithm/detail/positional.hpp | 12 ++++++++++++
   sandbox/mirror/boost/mirror/meta_path/siblings.hpp | 5 ++---
   sandbox/mirror/boost/mirror/visitors/meta_path_sample.hpp | 4 ++++
   sandbox/mirror/libs/mirror/doc/xml/mirror/_library.xml | 11 +++++++++++
   5 files changed, 49 insertions(+), 15 deletions(-)

Modified: sandbox/mirror/boost/mirror/algorithm/detail/common_iterator.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/algorithm/detail/common_iterator.hpp (original)
+++ sandbox/mirror/boost/mirror/algorithm/detail/common_iterator.hpp 2008-06-27 07:42:42 EDT (Fri, 27 Jun 2008)
@@ -16,8 +16,9 @@
 #include <boost/mpl/int.hpp>
 #include <boost/mpl/arithmetic.hpp>
 #include <boost/mpl/if.hpp>
+#include <boost/mpl/and.hpp>
 #include <boost/mpl/apply.hpp>
-#include <boost/mpl/equal_to.hpp>
+#include <boost/mpl/comparison.hpp>
 
 
 
@@ -29,7 +30,7 @@
 template <class Iterator>
 struct deref
 {
- typedef typename Iterator::pointed_to
+ typedef typename Iterator::template get_pointed_to<void>::type
                 type;
 };
 
@@ -154,19 +155,26 @@
>
         struct meta_object_iterator_base_templ
         {
+
                 typedef Position position;
- typedef Direction direction;
+ typedef BeginPos begin_position;
+ typedef EndPos end_position;
 
- // the type meta_class_attribute
- // that this iterator points to
- typedef typename Selector::template apply<
- ReflectedType,
- VariantTag,
- MetaObjectSequence,
- Position,
- UnaryPredicate
- >::type pointed_to;
+ typedef Direction direction;
 
+ template <typename Dummy>
+ struct get_pointed_to
+ {
+ // the type meta_class_attribute
+ // that this iterator points to
+ typedef typename Selector::template apply<
+ ReflectedType,
+ VariantTag,
+ MetaObjectSequence,
+ Position,
+ UnaryPredicate
+ >::type type;
+ };
 
                 // the current iterator getter
                 struct get_this_iterator

Added: sandbox/mirror/boost/mirror/algorithm/detail/point_to.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/algorithm/detail/point_to.hpp 2008-06-27 07:42:42 EDT (Fri, 27 Jun 2008)
@@ -0,0 +1,44 @@
+/**
+ * \file boost/mirror/algorithm/detail/point_to.hpp
+ *
+ * Template returning the iterator poining to
+ * the element at the given position
+ *
+ * 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_POINT_TO_HPP
+#define BOOST_MIRROR_ALGORITHM_DETAIL_POINT_TO_HPP
+
+#include <boost/mirror/algorithm/detail/iterator.hpp>
+#include <boost/mpl/always.hpp>
+
+namespace boost {
+namespace mirror {
+namespace detail {
+
+ template <
+ class ReflectedType,
+ class VariantTag,
+ class MetaObjectSequence,
+ class Position
+ >
+ struct meta_object_sequence_point_to
+ {
+ typedef typename get_meta_object_iterator<
+ ReflectedType,
+ VariantTag,
+ MetaObjectSequence,
+ Position,
+ mpl::always<mpl::true_>
+ >::type type;
+ };
+
+} // namespace detail
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+

Modified: sandbox/mirror/boost/mirror/algorithm/detail/positional.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/algorithm/detail/positional.hpp (original)
+++ sandbox/mirror/boost/mirror/algorithm/detail/positional.hpp 2008-06-27 07:42:42 EDT (Fri, 27 Jun 2008)
@@ -100,6 +100,18 @@
         : position_getter_impl_1<MetaObjectSequence, void, Implementation>
         { };
 
+ /** Declaration of the default explicit_position_getter_impl
+ * helper template.
+ */
+ template <
+ class MetaObjectSequence,
+ class Position,
+ template <class, class, class, class> class Implementation
+ >
+ struct explicit_position_getter_impl
+ : position_getter_impl_1<MetaObjectSequence, Position, Implementation>
+ { };
+
 
 
 } // namespace detail

Added: sandbox/mirror/boost/mirror/algorithm/is_valid.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/algorithm/is_valid.hpp 2008-06-27 07:42:42 EDT (Fri, 27 Jun 2008)
@@ -0,0 +1,56 @@
+/**
+ * \file boost/mirror/algorithm/is_valid.hpp
+ *
+ * returns mpl::true_ if the passed iterator is valid
+ * returns mpl::false_ otherwise
+ *
+ * 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_IS_VALID_HPP
+#define BOOST_MIRROR_ALGORITHM_ID_VALID_HPP
+
+#include <boost/mpl/times.hpp>
+#include <boost/mpl/and.hpp>
+#include <boost/mpl/less_equal.hpp>
+#include <boost/mpl/less.hpp>
+
+namespace boost {
+namespace mirror {
+
+template <
+ class Iterator
+>
+struct is_valid
+{
+ typedef typename mpl::and_<
+ typename mpl::less_equal<
+ typename mpl::times<
+ typename Iterator::begin_position,
+ typename Iterator::direction
+ >::type,
+ typename mpl::times<
+ typename Iterator::position,
+ typename Iterator::direction
+ >::type
+ >::type,
+ typename mpl::less<
+ typename mpl::times<
+ typename Iterator::position,
+ typename Iterator::direction
+ >::type,
+ typename mpl::times<
+ typename Iterator::end_position,
+ typename Iterator::direction
+ >::type
+ >::type
+ >::type type;
+};
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+

Added: sandbox/mirror/boost/mirror/algorithm/point_to.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/algorithm/point_to.hpp 2008-06-27 07:42:42 EDT (Fri, 27 Jun 2008)
@@ -0,0 +1,40 @@
+/**
+ * \file boost/mirror/algorithm/point_to.hpp
+ * Returns the iterator pointing to the meta-object
+ * on the specified position in a meta-object sequence.
+ *
+ * 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_POINT_TO_HPP
+#define BOOST_MIRROR_ALGORITHM_POINT_TO_HPP
+
+#include <boost/mirror/algorithm/detail/point_to.hpp>
+#include <boost/mirror/algorithm/detail/positional.hpp>
+
+namespace boost {
+namespace mirror {
+namespace detail {
+
+ template <class MetaObjectSequence, class Position>
+ struct point_to_impl
+ : explicit_position_getter_impl<
+ MetaObjectSequence,
+ Position,
+ meta_object_sequence_point_to
+ >
+ { };
+
+} // namespace detail
+
+template <class MetaObjectSequence, class Position>
+struct point_to : detail::point_to_impl<MetaObjectSequence, Position>
+{ };
+
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+

Added: sandbox/mirror/boost/mirror/meta_path/next.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/meta_path/next.hpp 2008-06-27 07:42:42 EDT (Fri, 27 Jun 2008)
@@ -0,0 +1,37 @@
+/**
+ * \file boost/mirror/meta_path/next.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_NEXT_HPP
+#define BOOST_MIRROR_META_PATH_NEXT_HPP
+
+#include <boost/mirror/meta_path/node_context.hpp>
+#include <boost/mirror/meta_path/prior.hpp>
+#include <boost/mirror/algorithm/next.hpp>
+
+namespace boost {
+namespace mirror {
+namespace meta_path {
+
+
+/** A nodeset containing the next node of the
+ * given node context
+ */
+template <class NodeContext>
+struct next : node_set<
+ detail::neighbour_base<NodeContext, mirror::next>
+>
+{
+ typedef next<NodeContext> type;
+};
+
+} // namespace meta_path
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+

Added: sandbox/mirror/boost/mirror/meta_path/prior.hpp
==============================================================================
--- (empty file)
+++ sandbox/mirror/boost/mirror/meta_path/prior.hpp 2008-06-27 07:42:42 EDT (Fri, 27 Jun 2008)
@@ -0,0 +1,214 @@
+/**
+ * \file boost/mirror/meta_path/prior.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_PRIOR_HPP
+#define BOOST_MIRROR_META_PATH_PRIOR_HPP
+
+#include <boost/mirror/meta_path/node_context.hpp>
+#include <boost/mirror/algorithm/prior.hpp>
+#include <boost/mirror/algorithm/point_to.hpp>
+#include <boost/mirror/algorithm/is_valid.hpp>
+#include <boost/mpl/vector.hpp>
+#include <boost/mpl/pair.hpp>
+#include <boost/mpl/back.hpp>
+
+namespace boost {
+namespace mirror {
+namespace meta_path {
+
+namespace detail {
+
+ template <
+ class PathsAndNodes,
+ class Pair,
+ class Node,
+ template <class> class PriorOrNext
+ >
+ struct neighbour_base_process_single_path_and_node_apply
+ {
+ typedef PathsAndNodes type;
+ };
+
+ template <
+ class PathsAndNodes,
+ class Path,
+ class Iterator,
+ class IsValid
+ >
+ struct neighbour_base_append_if_valid;
+
+ template <
+ class PathsAndNodes,
+ class Path,
+ class Iterator
+ >
+ struct neighbour_base_append_if_valid<
+ PathsAndNodes,
+ Path,
+ Iterator,
+ mpl::false_
+ >
+ {
+ typedef PathsAndNodes type;
+ };
+
+ template <
+ class PathsAndNodes,
+ class Path,
+ class Iterator
+ >
+ struct neighbour_base_append_if_valid<
+ PathsAndNodes,
+ Path,
+ Iterator,
+ mpl::true_
+ >
+ {
+ typedef typename mpl::push_back<
+ PathsAndNodes,
+ typename mpl::pair<
+ Path,
+ typename mirror::deref<
+ Iterator
+ >::type
+ >::type
+ >::type type;
+ };
+
+
+ template <
+ class PathsAndNodes,
+ class Pair,
+ template <class> class PriorOrNext
+ >
+ struct neighbour_base_process_single_path_and_seq_elem_apply
+ {
+ typedef typename mpl::first<Pair>::type
+ path;
+
+ typedef typename mpl::back<
+ path
+ >::type meta_object_sequence;
+
+ typedef typename mpl::second<Pair>::type
+ meta_object;
+
+ typedef typename PriorOrNext<
+ typename mirror::point_to<
+ meta_object_sequence,
+ typename meta_object::position
+ >::type
+ >::type
+ new_iterator;
+
+ typedef typename neighbour_base_append_if_valid<
+ PathsAndNodes,
+ path,
+ new_iterator,
+ typename mirror::is_valid<new_iterator>::type
+ >::type type;
+ };
+
+
+ template <
+ class PathsAndNodes,
+ class Pair,
+ class ReflectedType,
+ class VariantTag,
+ class MetaAttributes,
+ class AttribPos,
+ template <class> class PriorOrNext
+ >
+ struct neighbour_base_process_single_path_and_node_apply<
+ PathsAndNodes,
+ Pair,
+ meta_class_attribute<
+ ReflectedType,
+ VariantTag,
+ MetaAttributes,
+ AttribPos
+ >,
+ PriorOrNext
+ > : neighbour_base_process_single_path_and_seq_elem_apply<
+ PathsAndNodes,
+ Pair,
+ PriorOrNext
+ >{ };
+
+ template <
+ class PathsAndNodes,
+ class Pair,
+ class Position,
+ class BaseClass,
+ typename AccessSpec,
+ typename InheritanceSpec,
+ template <class> class PriorOrNext
+ >
+ struct neighbour_base_process_single_path_and_node_apply<
+ PathsAndNodes,
+ Pair,
+ meta_inheritance<
+ Position,
+ BaseClass,
+ AccessSpec,
+ InheritanceSpec
+ >,
+ PriorOrNext
+ > : neighbour_base_process_single_path_and_seq_elem_apply<
+ PathsAndNodes,
+ Pair,
+ PriorOrNext
+ >{ };
+
+
+ template <class NodeContext, template <class> class PriorOrNext >
+ struct neighbour_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
+ : neighbour_base_process_single_path_and_node_apply<
+ PathsAndNodes,
+ Pair,
+ typename mpl::second<Pair>::type,
+ PriorOrNext
+ >{ };
+ };
+
+ 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 the prior node of the
+ * given node context
+ */
+template <class NodeContext>
+struct prior : node_set<
+ detail::neighbour_base<NodeContext, mirror::prior>
+>
+{
+ typedef prior<NodeContext> type;
+};
+
+} // namespace meta_path
+} // namespace mirror
+} // namespace boost
+
+#endif //include guard
+

Modified: sandbox/mirror/boost/mirror/meta_path/siblings.hpp
==============================================================================
--- sandbox/mirror/boost/mirror/meta_path/siblings.hpp (original)
+++ sandbox/mirror/boost/mirror/meta_path/siblings.hpp 2008-06-27 07:42:42 EDT (Fri, 27 Jun 2008)
@@ -18,7 +18,6 @@
 #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>
@@ -60,7 +59,7 @@
 
                 typedef typename mpl::back<
                         path
- >::type meta_attribs;
+ >::type meta_object_sequence;
 
                 struct append_sibling
                 {
@@ -96,7 +95,7 @@
 
 
                 typedef typename mirror::accumulate<
- meta_attribs,
+ meta_object_sequence,
                         PathsAndNodes,
                         append_sibling
>::type type;

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-27 07:42:42 EDT (Fri, 27 Jun 2008)
@@ -30,6 +30,8 @@
 #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/prior.hpp>
+#include <boost/mirror/meta_path/next.hpp>
 #include <boost/mirror/meta_path/size.hpp>
 
 //
@@ -235,6 +237,8 @@
                 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);
+ print_node_set<meta_path::prior>("prior", mo, ctx);
+ print_node_set<meta_path::next>("next", 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-27 07:42:42 EDT (Fri, 27 Jun 2008)
@@ -218,5 +218,16 @@
                         - Tested with gcc 4.3.0 on SuSE
                         - Tested with intel 10.1 on SuSE
                 </revision>
+ <revision id="20080627" major="0" minor="1" micro="32" author="m_ch">
+ - Added point_to meta-function
+ - Added is_valid iterator meta-function
+ - Added a new meta-path axes (prior and next)
+ - 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