Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r62230 - in sandbox/metagraph: boost/metagraph/mpl_graph boost/metagraph/mpl_graph/detail libs/metagraph/example
From: gordon_at_[hidden]
Date: 2010-05-26 03:20:03


Author: gordon.woodhull
Date: 2010-05-26 03:20:01 EDT (Wed, 26 May 2010)
New Revision: 62230
URL: http://svn.boost.org/trac/boost/changeset/62230

Log:
license and as_mpl_map
Added:
   sandbox/metagraph/boost/metagraph/mpl_graph/detail/as_mpl_map.hpp (contents, props changed)
Text files modified:
   sandbox/metagraph/boost/metagraph/mpl_graph/adjacency_list_graph.hpp | 4 ++++
   sandbox/metagraph/boost/metagraph/mpl_graph/breadth_first_search.hpp | 4 ++++
   sandbox/metagraph/boost/metagraph/mpl_graph/depth_first_search.hpp | 4 ++++
   sandbox/metagraph/boost/metagraph/mpl_graph/detail/adjacency_list_graph.ipp | 4 ++++
   sandbox/metagraph/boost/metagraph/mpl_graph/detail/graph_implementation_interface.ipp | 4 ++++
   sandbox/metagraph/boost/metagraph/mpl_graph/detail/incidence_list_graph.ipp | 20 ++++++++++++++++++++
   sandbox/metagraph/boost/metagraph/mpl_graph/incidence_list_graph.hpp | 4 ++++
   sandbox/metagraph/boost/metagraph/mpl_graph/mpl_graph.hpp | 4 ++++
   sandbox/metagraph/boost/metagraph/mpl_graph/mpl_utils.hpp | 4 ++++
   sandbox/metagraph/boost/metagraph/mpl_graph/search_colors.hpp | 4 ++++
   sandbox/metagraph/libs/metagraph/example/adjacency_list_graph.cpp | 4 ++++
   sandbox/metagraph/libs/metagraph/example/breadth_first_search.cpp | 4 ++++
   sandbox/metagraph/libs/metagraph/example/depth_first_search.cpp | 4 ++++
   sandbox/metagraph/libs/metagraph/example/fusion_graph.cpp | 4 ++++
   sandbox/metagraph/libs/metagraph/example/incidence_list_graph.cpp | 4 ++++
   sandbox/metagraph/libs/metagraph/example/msm_adaptor.cpp | 31 +++----------------------------
   16 files changed, 79 insertions(+), 28 deletions(-)

Modified: sandbox/metagraph/boost/metagraph/mpl_graph/adjacency_list_graph.hpp
==============================================================================
--- sandbox/metagraph/boost/metagraph/mpl_graph/adjacency_list_graph.hpp (original)
+++ sandbox/metagraph/boost/metagraph/mpl_graph/adjacency_list_graph.hpp 2010-05-26 03:20:01 EDT (Wed, 26 May 2010)
@@ -1,3 +1,7 @@
+// Copyright 2008-2010 Gordon Woodhull
+// 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_METAGRAPH_MPL_GRAPH_ADJACENCY_LIST_GRAPH_HPP_INCLUDED
 #define BOOST_METAGRAPH_MPL_GRAPH_ADJACENCY_LIST_GRAPH_HPP_INCLUDED
 

Modified: sandbox/metagraph/boost/metagraph/mpl_graph/breadth_first_search.hpp
==============================================================================
--- sandbox/metagraph/boost/metagraph/mpl_graph/breadth_first_search.hpp (original)
+++ sandbox/metagraph/boost/metagraph/mpl_graph/breadth_first_search.hpp 2010-05-26 03:20:01 EDT (Wed, 26 May 2010)
@@ -1,3 +1,7 @@
+// Copyright 2008-2010 Gordon Woodhull
+// 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_METAGRAPH_MPL_GRAPH_BREADTH_FIRST_SEARCH_HPP_INCLUDED
 #define BOOST_METAGRAPH_MPL_GRAPH_BREADTH_FIRST_SEARCH_HPP_INCLUDED
 

Modified: sandbox/metagraph/boost/metagraph/mpl_graph/depth_first_search.hpp
==============================================================================
--- sandbox/metagraph/boost/metagraph/mpl_graph/depth_first_search.hpp (original)
+++ sandbox/metagraph/boost/metagraph/mpl_graph/depth_first_search.hpp 2010-05-26 03:20:01 EDT (Wed, 26 May 2010)
@@ -1,3 +1,7 @@
+// Copyright 2008-2010 Gordon Woodhull
+// 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_METAGRAPH_MPL_GRAPH_DEPTH_FIRST_SEARCH_HPP_INCLUDED
 #define BOOST_METAGRAPH_MPL_GRAPH_DEPTH_FIRST_SEARCH_HPP_INCLUDED
 

Modified: sandbox/metagraph/boost/metagraph/mpl_graph/detail/adjacency_list_graph.ipp
==============================================================================
--- sandbox/metagraph/boost/metagraph/mpl_graph/detail/adjacency_list_graph.ipp (original)
+++ sandbox/metagraph/boost/metagraph/mpl_graph/detail/adjacency_list_graph.ipp 2010-05-26 03:20:01 EDT (Wed, 26 May 2010)
@@ -1,3 +1,7 @@
+// Copyright 2008-2010 Gordon Woodhull
+// 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_METAGRAPH_MPL_GRAPH_DETAIL_ADJACENCY_LIST_GRAPH_IPP_INCLUDED
 #define BOOST_METAGRAPH_MPL_GRAPH_DETAIL_ADJACENCY_LIST_GRAPH_IPP_INCLUDED
 

Added: sandbox/metagraph/boost/metagraph/mpl_graph/detail/as_mpl_map.hpp
==============================================================================
--- (empty file)
+++ sandbox/metagraph/boost/metagraph/mpl_graph/detail/as_mpl_map.hpp 2010-05-26 03:20:01 EDT (Wed, 26 May 2010)
@@ -0,0 +1,100 @@
+// Copyright 2008-2010 Gordon Woodhull
+// 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)
+
+// this is an experiment at implementing a metafunction that's
+// present in fusion but not in mpl
+// based on fusion/container/map/detail/as_map.hpp
+/*=============================================================================
+ Copyright (c) 2001-2006 Joel de Guzman
+
+ 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_PP_IS_ITERATING
+#if !defined(AS_MPL_MAP_HPP)
+#define AS_MPL_MAP_HPP
+
+#define AS_MPL_MAP_SIZE 20
+
+#include <boost/preprocessor/iterate.hpp>
+#include <boost/preprocessor/repetition/enum_params.hpp>
+#include <boost/preprocessor/repetition/enum_binary_params.hpp>
+#include <boost/preprocessor/repetition/repeat.hpp>
+#include <boost/preprocessor/cat.hpp>
+#include <boost/preprocessor/inc.hpp>
+#include <boost/preprocessor/dec.hpp>
+#include <boost/mpl/map.hpp>
+#include <boost/mpl/deref.hpp>
+#include <boost/mpl/next.hpp>
+
+namespace boost { namespace mpl {
+
+ namespace detail {
+ template <int size>
+ struct as_map;
+
+ }
+ template<typename Seq>
+ struct as_map : detail::as_map<mpl::size<Seq>::value>::template
+ apply<typename mpl::begin<Seq>::type> {};
+
+ namespace detail
+{
+ template <int size>
+ struct as_map;
+
+ template <>
+ struct as_map<0>
+ {
+ template <typename Iterator>
+ struct apply
+ {
+ typedef map<> type;
+ };
+
+ };
+
+#define BOOST_AS_MPL_MAP_NEXT_ITERATOR(z, n, data) \
+ typedef typename mpl::next<BOOST_PP_CAT(I, n)>::type \
+ BOOST_PP_CAT(I, BOOST_PP_INC(n));
+
+#define BOOST_AS_MPL_MAP_DEREF_ITERATOR(z, n, data) \
+ typedef typename mpl::deref<BOOST_PP_CAT(I, n)>::type \
+ BOOST_PP_CAT(T, n);
+
+#define BOOST_PP_FILENAME_1 <boost/metagraph/mpl_graph/detail/as_mpl_map.hpp>
+#define BOOST_PP_ITERATION_LIMITS (1, AS_MPL_MAP_SIZE)
+#include BOOST_PP_ITERATE()
+
+#undef BOOST_AS_MPL_MAP_NEXT_ITERATOR
+#undef BOOST_AS_MPL_MAP_DEREF_ITERATOR
+
+}}}
+
+#endif
+#else // defined(BOOST_PP_IS_ITERATING)
+///////////////////////////////////////////////////////////////////////////////
+//
+// Preprocessor vertical repetition code
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#define N BOOST_PP_ITERATION()
+
+ template <>
+ struct as_map<N>
+ {
+ template <typename I0>
+ struct apply
+ {
+ BOOST_PP_REPEAT(N, BOOST_AS_MPL_MAP_NEXT_ITERATOR, _)
+ BOOST_PP_REPEAT(N, BOOST_AS_MPL_MAP_DEREF_ITERATOR, _)
+ typedef map<BOOST_PP_ENUM_PARAMS(N, T)> type;
+ };
+
+ };
+
+#undef N
+#endif // defined(BOOST_PP_IS_ITERATING)
+

Modified: sandbox/metagraph/boost/metagraph/mpl_graph/detail/graph_implementation_interface.ipp
==============================================================================
--- sandbox/metagraph/boost/metagraph/mpl_graph/detail/graph_implementation_interface.ipp (original)
+++ sandbox/metagraph/boost/metagraph/mpl_graph/detail/graph_implementation_interface.ipp 2010-05-26 03:20:01 EDT (Wed, 26 May 2010)
@@ -1,3 +1,7 @@
+// Copyright 2008-2010 Gordon Woodhull
+// 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_METAGRAPH_MPL_GRAPH_DETAIL_GRAPH_IMPLEMENTATION_INTERFACE_IPP_INCLUDED
 #define BOOST_METAGRAPH_MPL_GRAPH_DETAIL_GRAPH_IMPLEMENTATION_INTERFACE_IPP_INCLUDED
 

Modified: sandbox/metagraph/boost/metagraph/mpl_graph/detail/incidence_list_graph.ipp
==============================================================================
--- sandbox/metagraph/boost/metagraph/mpl_graph/detail/incidence_list_graph.ipp (original)
+++ sandbox/metagraph/boost/metagraph/mpl_graph/detail/incidence_list_graph.ipp 2010-05-26 03:20:01 EDT (Wed, 26 May 2010)
@@ -1,4 +1,9 @@
+// Copyright 2008-2010 Gordon Woodhull
+// 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_METAGRAPH_MPL_GRAPH_DETAIL_INCIDENCE_LIST_GRAPH_IPP_INCLUDED
+
 #define BOOST_METAGRAPH_MPL_GRAPH_DETAIL_INCIDENCE_LIST_GRAPH_IPP_INCLUDED
 
 // these metafunctions provide the metadata structures needed by the public interface
@@ -29,9 +34,14 @@
 #include <boost/mpl/at.hpp>
 #include <boost/mpl/push_back.hpp>
 #include <boost/mpl/filter_view.hpp>
+#include <boost/mpl/transform_view.hpp>
 #include <boost/mpl/equal.hpp>
 #include <boost/type_traits.hpp>
 
+#ifdef USE_AS_MPL_MAP
+#include <boost/metagraph/mpl_graph/detail/as_mpl_map.hpp>
+#endif
+
 namespace boost {
 namespace metagraph {
 namespace mpl_graph {
@@ -73,12 +83,22 @@
 // Edge->Target map for an Source for out_*, adjacent_vertices
 template<typename Source, typename ESTSequence>
 struct produce_out_map<incidence_list_tag, Source, ESTSequence> :
+#ifdef USE_AS_MPL_MAP
+ mpl::as_map<
+ typename mpl::fold<typename mpl::filter_view<ESTSequence, boost::is_same<fetch_source<mpl::_1>,Source> >::type,
+ mpl::vector<>,
+ mpl::push_back<mpl::_1,mpl::pair<fetch_edge<mpl::_2>,fetch_target<mpl::_2> > > >::type>
+#else
     mpl::fold<typename mpl::filter_view<ESTSequence, boost::is_same<fetch_source<mpl::_1>,Source> >::type,
          mpl::map<>,
          mpl::insert<mpl::_1,mpl::pair<fetch_edge<mpl::_2>,fetch_target<mpl::_2> > > >
+#endif
 {};
+
 #endif
 
+/*
+*/
 // Edge->Source map for a Target for in_*, degree
 template<typename Target, typename ESTSequence>
 struct produce_in_map<incidence_list_tag, Target, ESTSequence> :

Modified: sandbox/metagraph/boost/metagraph/mpl_graph/incidence_list_graph.hpp
==============================================================================
--- sandbox/metagraph/boost/metagraph/mpl_graph/incidence_list_graph.hpp (original)
+++ sandbox/metagraph/boost/metagraph/mpl_graph/incidence_list_graph.hpp 2010-05-26 03:20:01 EDT (Wed, 26 May 2010)
@@ -1,3 +1,7 @@
+// Copyright 2008-2010 Gordon Woodhull
+// 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_METAGRAPH_MPL_GRAPH_INCIDENCE_LIST_GRAPH_HPP_INCLUDED
 #define BOOST_METAGRAPH_MPL_GRAPH_INCIDENCE_LIST_GRAPH_HPP_INCLUDED
 

Modified: sandbox/metagraph/boost/metagraph/mpl_graph/mpl_graph.hpp
==============================================================================
--- sandbox/metagraph/boost/metagraph/mpl_graph/mpl_graph.hpp (original)
+++ sandbox/metagraph/boost/metagraph/mpl_graph/mpl_graph.hpp 2010-05-26 03:20:01 EDT (Wed, 26 May 2010)
@@ -1,3 +1,7 @@
+// Copyright 2008-2010 Gordon Woodhull
+// 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)
+
 // mpl_graph - defines a metadata implementation of the BGL immutable graph concepts
 
 // (c) 2008 Gordon Woodhull

Modified: sandbox/metagraph/boost/metagraph/mpl_graph/mpl_utils.hpp
==============================================================================
--- sandbox/metagraph/boost/metagraph/mpl_graph/mpl_utils.hpp (original)
+++ sandbox/metagraph/boost/metagraph/mpl_graph/mpl_utils.hpp 2010-05-26 03:20:01 EDT (Wed, 26 May 2010)
@@ -1,3 +1,7 @@
+// Copyright 2008-2010 Gordon Woodhull
+// 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_METAGRAPH_MPL_GRAPH_MPL_UTILS_HPP_INCLUDED
 #define BOOST_METAGRAPH_MPL_GRAPH_MPL_UTILS_HPP_INCLUDED
 

Modified: sandbox/metagraph/boost/metagraph/mpl_graph/search_colors.hpp
==============================================================================
--- sandbox/metagraph/boost/metagraph/mpl_graph/search_colors.hpp (original)
+++ sandbox/metagraph/boost/metagraph/mpl_graph/search_colors.hpp 2010-05-26 03:20:01 EDT (Wed, 26 May 2010)
@@ -1,3 +1,7 @@
+// Copyright 2008-2010 Gordon Woodhull
+// 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_METAGRAPH_MPL_GRAPH_SEARCH_COLORS_HPP_INCLUDED
 #define BOOST_METAGRAPH_MPL_GRAPH_SEARCH_COLORS_HPP_INCLUDED
 

Modified: sandbox/metagraph/libs/metagraph/example/adjacency_list_graph.cpp
==============================================================================
--- sandbox/metagraph/libs/metagraph/example/adjacency_list_graph.cpp (original)
+++ sandbox/metagraph/libs/metagraph/example/adjacency_list_graph.cpp 2010-05-26 03:20:01 EDT (Wed, 26 May 2010)
@@ -1,3 +1,7 @@
+// Copyright 2008-2010 Gordon Woodhull
+// 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)
+
 // mplgraph.cpp : Defines the entry point for the console application.
 //
 

Modified: sandbox/metagraph/libs/metagraph/example/breadth_first_search.cpp
==============================================================================
--- sandbox/metagraph/libs/metagraph/example/breadth_first_search.cpp (original)
+++ sandbox/metagraph/libs/metagraph/example/breadth_first_search.cpp 2010-05-26 03:20:01 EDT (Wed, 26 May 2010)
@@ -1,3 +1,7 @@
+// Copyright 2008-2010 Gordon Woodhull
+// 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/metagraph/mpl_graph/breadth_first_search.hpp>
 #include <boost/metagraph/mpl_graph/adjacency_list_graph.hpp>
 #include <boost/metagraph/mpl_graph/incidence_list_graph.hpp>

Modified: sandbox/metagraph/libs/metagraph/example/depth_first_search.cpp
==============================================================================
--- sandbox/metagraph/libs/metagraph/example/depth_first_search.cpp (original)
+++ sandbox/metagraph/libs/metagraph/example/depth_first_search.cpp 2010-05-26 03:20:01 EDT (Wed, 26 May 2010)
@@ -1,3 +1,7 @@
+// Copyright 2008-2010 Gordon Woodhull
+// 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/metagraph/mpl_graph/depth_first_search.hpp>
 #include <boost/metagraph/mpl_graph/adjacency_list_graph.hpp>
 #include <boost/metagraph/mpl_graph/incidence_list_graph.hpp>

Modified: sandbox/metagraph/libs/metagraph/example/fusion_graph.cpp
==============================================================================
--- sandbox/metagraph/libs/metagraph/example/fusion_graph.cpp (original)
+++ sandbox/metagraph/libs/metagraph/example/fusion_graph.cpp 2010-05-26 03:20:01 EDT (Wed, 26 May 2010)
@@ -1,3 +1,7 @@
+// Copyright 2008-2010 Gordon Woodhull
+// 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/metagraph/fusion_graph/fusion_graph.hpp>
 #include <boost/metagraph/mpl_graph/incidence_list_graph.hpp>
 

Modified: sandbox/metagraph/libs/metagraph/example/incidence_list_graph.cpp
==============================================================================
--- sandbox/metagraph/libs/metagraph/example/incidence_list_graph.cpp (original)
+++ sandbox/metagraph/libs/metagraph/example/incidence_list_graph.cpp 2010-05-26 03:20:01 EDT (Wed, 26 May 2010)
@@ -1,3 +1,7 @@
+// Copyright 2008-2010 Gordon Woodhull
+// 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)
+
 // mplgraph.cpp : Defines the entry point for the console application.
 //
 

Modified: sandbox/metagraph/libs/metagraph/example/msm_adaptor.cpp
==============================================================================
--- sandbox/metagraph/libs/metagraph/example/msm_adaptor.cpp (original)
+++ sandbox/metagraph/libs/metagraph/example/msm_adaptor.cpp 2010-05-26 03:20:01 EDT (Wed, 26 May 2010)
@@ -1,7 +1,7 @@
 // Copyright 2010 Gordon Woodhull
-// simplified from MSMv2.10/libs/msm/doc/HTML/examples/SimpleTutorial.cpp
+// modified from MSMv2.10/libs/msm/doc/HTML/examples/SimpleTutorial.cpp
 // for the purpose of showing how to run mpl_graph algorithms on MSMs
-// and distributed same as below
+// and distributed same license as source
 // Copyright 2008 Christophe Henry
 // henry UNDERSCORE christophe AT hotmail DOT com
 // This is an extended version of the state machine available in the boost::mpl library
@@ -18,29 +18,15 @@
 //front-end
 #include <boost/msm/front/state_machine_def.hpp>
 
-#ifdef SKIP_DFS
-#define DO_DFS 0
-#else
-#ifndef DO_DFS
-#define DO_DFS 5
-#endif
-#endif
-
-#if DO_DFS>1
 // mpl_graph graph implementation and depth first search
 #include <boost/metagraph/mpl_graph/incidence_list_graph.hpp>
 #include <boost/metagraph/mpl_graph/depth_first_search.hpp>
-#if DO_BFS>0
 #include <boost/metagraph/mpl_graph/breadth_first_search.hpp>
-#endif
-#endif
 
 namespace msm = boost::msm;
 namespace mpl = boost::mpl;
 
-#if DO_DFS>1
 namespace mpl_graph = boost::metagraph::mpl_graph;
-#endif
 
 namespace
 {
@@ -180,8 +166,6 @@
         }
 
 
-#if DO_DFS>2
-
         // transition table is already an incidence list;
         // select Edge, Source, Target = pair<Start,Event>, Start, Next
         // making Start part of Edge is necessary because Edge tags have to be unique
@@ -205,20 +189,16 @@
             {};
         };
 
-#if DO_DFS>3
         typedef mpl::first<mpl_graph::
             depth_first_search<transition_graph,
                                preordering_dfs_visitor,
                                mpl::vector<>,
                                player_::initial_state>::type>::type
                     dfs_from_initial_state;
-#if DO_DFS>4
+
         BOOST_MPL_ASSERT(( mpl::equal<dfs_from_initial_state,
                                       mpl::vector<Empty,Open,Stopped,Playing,Paused> > ));
-#endif
-#endif
 
-#if DO_BFS>0
         struct preordering_bfs_visitor : mpl_graph::bfs_default_visitor_operations {
             template<typename Node, typename Graph, typename State>
             struct discover_vertex :
@@ -235,11 +215,6 @@
         // yawn, BFS happens to produce the same result as DFS for this example
         BOOST_MPL_ASSERT(( mpl::equal<bfs_from_initial_state,
                                       mpl::vector<Empty,Open,Stopped,Playing,Paused> > ));
-#endif
-
-
-#endif
-
 
     };
     // Pick a back-end


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