1 // Copyright 2008-2010 Gordon Woodhull
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5 // mpl_graph - defines a metadata implementation of the BGL immutable graph concepts
7 // (c) 2008 Gordon Woodhull
8 // Distributed under the Boost Software License, Version 1.0.
9 // (See accompanying file LICENSEmpl::_1_0.txt or copy at
10 // http://www.boost.org/LICENSEmpl::_1_0.txt)
12 #ifndef BOOST_MSM_MPL_GRAPH_MPL_GRAPH_HPP_INCLUDED
13 #define BOOST_MSM_MPL_GRAPH_MPL_GRAPH_HPP_INCLUDED
15 #include <boost/msm/mpl_graph/detail/graph_implementation_interface.ipp>
17 #include <boost/mpl/vector.hpp>
18 #include <boost/mpl/pair.hpp>
19 #include <boost/mpl/fold.hpp>
20 #include <boost/mpl/push_back.hpp>
21 #include <boost/mpl/at.hpp>
22 #include <boost/mpl/size.hpp>
23 #include <boost/mpl/plus.hpp>
24 #include <boost/mpl/transform.hpp>
25 #include <boost/mpl/back_inserter.hpp>
31 // Boost Graph concepts, MPL style
33 // The metafunctions of the public interface rely
34 // metafunctions in the graph implementation to transform the input
35 // into the maps which are required to deliver results. Since the
36 // maps are produced lazily and are memoized, all of the graph
37 // concepts can be supported with no cost until they are actually
40 // Each of these dispatch to the correct producer metafunctions based
41 // on the representation inner type tag
46 template<typename Edge, typename Graph>
48 mpl::first<typename mpl::at<typename detail::produce_edge_st_map<typename Graph::representation, typename Graph::data>::type,Edge>::type>
50 template<typename Edge, typename Graph>
52 mpl::second<typename mpl::at<typename detail::produce_edge_st_map<typename Graph::representation, typename Graph::data>::type,Edge>::type>
54 template<typename Vertex, typename Graph>
56 mpl::fold<typename detail::produce_out_map<typename Graph::representation, Vertex, typename Graph::data>::type,
58 mpl::push_back<mpl::_1, mpl::first<mpl::_2> > >
60 template<typename Vertex, typename Graph>
62 mpl::size<typename out_edges<Vertex, Graph>::type>
66 template<typename Vertex, typename Graph>
68 mpl::fold<typename detail::produce_in_map<typename Graph::representation, Vertex, typename Graph::data>::type,
70 mpl::push_back<mpl::_1, mpl::first<mpl::_2> > >
72 template<typename Vertex, typename Graph>
74 mpl::size<typename in_edges<Vertex, Graph>::type>
76 template<typename Vertex, typename Graph>
78 mpl::plus<typename out_degree<Vertex, Graph>::type,typename in_degree<Vertex, Graph>::type>
82 template<typename Vertex, typename Graph>
83 struct adjacent_vertices :
84 mpl::transform<typename detail::produce_out_map<typename Graph::representation, Vertex, typename Graph::data>::type,
86 mpl::back_inserter<mpl::vector<> > >
90 template<typename Graph>
92 detail::produce_vertex_set<typename Graph::representation, typename Graph::data>
94 template<typename Graph>
96 mpl::size<typename vertices<Graph>::type>
100 template<typename Graph>
102 detail::produce_edge_set<typename Graph::representation, typename Graph::data>
104 template<typename Graph>
106 mpl::size<typename edges<Graph>::type>
108 // source and target are defined in IncidenceGraph
114 #endif // BOOST_MSM_MPL_GRAPH_MPL_GRAPH_HPP_INCLUDED