]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/msm/include/boost/msm/mpl_graph/mpl_graph.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / msm / include / boost / msm / mpl_graph / mpl_graph.hpp
CommitLineData
7c673cae
FG
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)
4
5// mpl_graph - defines a metadata implementation of the BGL immutable graph concepts
6
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)
11
12#ifndef BOOST_MSM_MPL_GRAPH_MPL_GRAPH_HPP_INCLUDED
13#define BOOST_MSM_MPL_GRAPH_MPL_GRAPH_HPP_INCLUDED
14
15#include <boost/msm/mpl_graph/detail/graph_implementation_interface.ipp>
16
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>
26
27namespace boost {
28namespace msm {
29namespace mpl_graph {
30
31// Boost Graph concepts, MPL style
32
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
38// used.
39
40// Each of these dispatch to the correct producer metafunctions based
41// on the representation inner type tag
42
43
44
45// IncidenceGraph
46template<typename Edge, typename Graph>
47struct source :
48 mpl::first<typename mpl::at<typename detail::produce_edge_st_map<typename Graph::representation, typename Graph::data>::type,Edge>::type>
49{};
50template<typename Edge, typename Graph>
51struct target :
52 mpl::second<typename mpl::at<typename detail::produce_edge_st_map<typename Graph::representation, typename Graph::data>::type,Edge>::type>
53{};
54template<typename Vertex, typename Graph>
55struct out_edges :
56 mpl::fold<typename detail::produce_out_map<typename Graph::representation, Vertex, typename Graph::data>::type,
57 mpl::vector<>,
58 mpl::push_back<mpl::_1, mpl::first<mpl::_2> > >
59{};
60template<typename Vertex, typename Graph>
61struct out_degree :
62 mpl::size<typename out_edges<Vertex, Graph>::type>
63{};
64
65// BidirectionalGraph
66template<typename Vertex, typename Graph>
67struct in_edges :
68 mpl::fold<typename detail::produce_in_map<typename Graph::representation, Vertex, typename Graph::data>::type,
69 mpl::vector<>,
70 mpl::push_back<mpl::_1, mpl::first<mpl::_2> > >
71{};
72template<typename Vertex, typename Graph>
73struct in_degree :
74 mpl::size<typename in_edges<Vertex, Graph>::type>
75{};
76template<typename Vertex, typename Graph>
77struct degree :
78 mpl::plus<typename out_degree<Vertex, Graph>::type,typename in_degree<Vertex, Graph>::type>
79{};
80
81// AdjacencyGraph
82template<typename Vertex, typename Graph>
83struct adjacent_vertices :
84 mpl::transform<typename detail::produce_out_map<typename Graph::representation, Vertex, typename Graph::data>::type,
85 mpl::second<mpl::_1>,
86 mpl::back_inserter<mpl::vector<> > >
87{};
88
89// VertexListGraph
90template<typename Graph>
91struct vertices :
92 detail::produce_vertex_set<typename Graph::representation, typename Graph::data>
93{};
94template<typename Graph>
95struct num_vertices :
96 mpl::size<typename vertices<Graph>::type>
97{};
98
99// EdgeListGraph
100template<typename Graph>
101struct edges :
102 detail::produce_edge_set<typename Graph::representation, typename Graph::data>
103{};
104template<typename Graph>
105struct num_edges :
106 mpl::size<typename edges<Graph>::type>
107{};
108// source and target are defined in IncidenceGraph
109
110} // mpl_graph
111} // msm
112} // boost
113
114#endif // BOOST_MSM_MPL_GRAPH_MPL_GRAPH_HPP_INCLUDED