Chris@16
|
1 // Copyright (C) 2009 Andrew Sutton
|
Chris@16
|
2 //
|
Chris@16
|
3 // Use, modification and distribution is subject to the Boost Software
|
Chris@16
|
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
5 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
6
|
Chris@16
|
7 #ifndef BOOST_GRAPH_MUTABILITY_TRAITS_HPP
|
Chris@16
|
8 #define BOOST_GRAPH_MUTABILITY_TRAITS_HPP
|
Chris@16
|
9
|
Chris@16
|
10 #include <boost/config.hpp>
|
Chris@16
|
11 #include <boost/mpl/if.hpp>
|
Chris@16
|
12 #include <boost/mpl/and.hpp>
|
Chris@16
|
13 #include <boost/mpl/bool.hpp>
|
Chris@16
|
14 #include <boost/type_traits/is_same.hpp>
|
Chris@16
|
15
|
Chris@16
|
16 namespace boost {
|
Chris@16
|
17
|
Chris@16
|
18 // The mutabiltiy categories classify graphs by their mutating operations
|
Chris@16
|
19 // on the edge and vertex sets. This is a substantially more refined
|
Chris@16
|
20 // categorization than the MutableGraph and MutablePropertyGraph denote.
|
Chris@16
|
21 // Currently, this framework is only used in the graph tests to help
|
Chris@16
|
22 // dispatch test to the correct places. However, there are probably some
|
Chris@16
|
23 // constructive or destructive algorithms (i.e., graph generators) that
|
Chris@16
|
24 // may use these to describe requirements on graph inputs.
|
Chris@16
|
25
|
Chris@16
|
26 struct add_vertex_tag { };
|
Chris@16
|
27 struct add_vertex_property_tag : virtual add_vertex_tag { };
|
Chris@16
|
28 struct add_edge_tag { };
|
Chris@16
|
29 struct add_edge_property_tag : virtual add_edge_tag { };
|
Chris@16
|
30 struct remove_vertex_tag { };
|
Chris@16
|
31 struct remove_edge_tag { };
|
Chris@16
|
32
|
Chris@16
|
33 struct mutable_vertex_graph_tag
|
Chris@16
|
34 : virtual add_vertex_tag, virtual remove_vertex_tag
|
Chris@16
|
35 { };
|
Chris@16
|
36 struct mutable_vertex_property_graph_tag
|
Chris@16
|
37 : virtual add_vertex_property_tag, virtual remove_vertex_tag
|
Chris@16
|
38 { };
|
Chris@16
|
39
|
Chris@16
|
40 struct mutable_edge_graph_tag
|
Chris@16
|
41 : virtual add_edge_tag, virtual remove_edge_tag
|
Chris@16
|
42 { };
|
Chris@16
|
43 struct mutable_edge_property_graph_tag
|
Chris@16
|
44 : virtual add_edge_property_tag, virtual remove_edge_tag
|
Chris@16
|
45 { };
|
Chris@16
|
46
|
Chris@16
|
47 struct mutable_graph_tag
|
Chris@16
|
48 : virtual mutable_vertex_graph_tag
|
Chris@16
|
49 , virtual mutable_edge_graph_tag
|
Chris@16
|
50 { };
|
Chris@16
|
51 struct mutable_property_graph_tag
|
Chris@16
|
52 : virtual mutable_vertex_property_graph_tag
|
Chris@16
|
53 , virtual mutable_edge_property_graph_tag
|
Chris@16
|
54 { };
|
Chris@16
|
55
|
Chris@16
|
56 // Some graphs just don't like to be torn down. Note this only restricts
|
Chris@16
|
57 // teardown to the set of vertices, not the vertex set.
|
Chris@16
|
58 // TODO: Find a better name for this tag.
|
Chris@16
|
59 struct add_only_property_graph_tag
|
Chris@16
|
60 : virtual add_vertex_property_tag
|
Chris@16
|
61 , virtual mutable_edge_property_graph_tag
|
Chris@16
|
62 { };
|
Chris@16
|
63
|
Chris@16
|
64 /**
|
Chris@16
|
65 * The graph_mutability_traits provide methods for determining the
|
Chris@16
|
66 * interfaces supported by graph classes for adding and removing vertices
|
Chris@16
|
67 * and edges.
|
Chris@16
|
68 */
|
Chris@16
|
69 template <typename Graph>
|
Chris@16
|
70 struct graph_mutability_traits {
|
Chris@16
|
71 typedef typename Graph::mutability_category category;
|
Chris@16
|
72 };
|
Chris@16
|
73
|
Chris@16
|
74 template <typename Graph>
|
Chris@16
|
75 struct graph_has_add_vertex
|
Chris@16
|
76 : mpl::bool_<
|
Chris@16
|
77 is_convertible<
|
Chris@16
|
78 typename graph_mutability_traits<Graph>::category,
|
Chris@16
|
79 add_vertex_tag
|
Chris@16
|
80 >::value
|
Chris@16
|
81 >
|
Chris@16
|
82 { };
|
Chris@16
|
83
|
Chris@16
|
84 template <typename Graph>
|
Chris@16
|
85 struct graph_has_add_vertex_with_property
|
Chris@16
|
86 : mpl::bool_<
|
Chris@16
|
87 is_convertible<
|
Chris@16
|
88 typename graph_mutability_traits<Graph>::category,
|
Chris@16
|
89 add_vertex_property_tag
|
Chris@16
|
90 >::value
|
Chris@16
|
91 >
|
Chris@16
|
92 { };
|
Chris@16
|
93
|
Chris@16
|
94
|
Chris@16
|
95 template <typename Graph>
|
Chris@16
|
96 struct graph_has_remove_vertex
|
Chris@16
|
97 : mpl::bool_<
|
Chris@16
|
98 is_convertible<
|
Chris@16
|
99 typename graph_mutability_traits<Graph>::category,
|
Chris@16
|
100 remove_vertex_tag
|
Chris@16
|
101 >::value
|
Chris@16
|
102 >
|
Chris@16
|
103 { };
|
Chris@16
|
104
|
Chris@16
|
105 template <typename Graph>
|
Chris@16
|
106 struct graph_has_add_edge
|
Chris@16
|
107 : mpl::bool_<
|
Chris@16
|
108 is_convertible<
|
Chris@16
|
109 typename graph_mutability_traits<Graph>::category,
|
Chris@16
|
110 add_edge_tag
|
Chris@16
|
111 >::value
|
Chris@16
|
112 >
|
Chris@16
|
113 { };
|
Chris@16
|
114
|
Chris@16
|
115 template <typename Graph>
|
Chris@16
|
116 struct graph_has_add_edge_with_property
|
Chris@16
|
117 : mpl::bool_<
|
Chris@16
|
118 is_convertible<
|
Chris@16
|
119 typename graph_mutability_traits<Graph>::category,
|
Chris@16
|
120 add_edge_property_tag
|
Chris@16
|
121 >::value
|
Chris@16
|
122 >
|
Chris@16
|
123 { };
|
Chris@16
|
124
|
Chris@16
|
125
|
Chris@16
|
126 template <typename Graph>
|
Chris@16
|
127 struct graph_has_remove_edge
|
Chris@16
|
128 : mpl::bool_<
|
Chris@16
|
129 is_convertible<
|
Chris@16
|
130 typename graph_mutability_traits<Graph>::category,
|
Chris@16
|
131 remove_edge_tag
|
Chris@16
|
132 >::value
|
Chris@16
|
133 >
|
Chris@16
|
134 { };
|
Chris@16
|
135
|
Chris@16
|
136
|
Chris@16
|
137 template <typename Graph>
|
Chris@16
|
138 struct is_mutable_vertex_graph
|
Chris@16
|
139 : mpl::and_<
|
Chris@16
|
140 graph_has_add_vertex<Graph>,
|
Chris@16
|
141 graph_has_remove_vertex<Graph>
|
Chris@16
|
142 >
|
Chris@16
|
143 { };
|
Chris@16
|
144
|
Chris@16
|
145 template <typename Graph>
|
Chris@16
|
146 struct is_mutable_vertex_property_graph
|
Chris@16
|
147 : mpl::and_<
|
Chris@16
|
148 graph_has_add_vertex_with_property<Graph>,
|
Chris@16
|
149 graph_has_remove_vertex<Graph>
|
Chris@16
|
150 >
|
Chris@16
|
151 { };
|
Chris@16
|
152
|
Chris@16
|
153
|
Chris@16
|
154 template <typename Graph>
|
Chris@16
|
155 struct is_mutable_edge_graph
|
Chris@16
|
156 : mpl::and_<
|
Chris@16
|
157 graph_has_add_edge<Graph>,
|
Chris@16
|
158 graph_has_remove_edge<Graph>
|
Chris@16
|
159 >
|
Chris@16
|
160 { };
|
Chris@16
|
161
|
Chris@16
|
162 template <typename Graph>
|
Chris@16
|
163 struct is_mutable_edge_property_graph
|
Chris@16
|
164 : mpl::and_<
|
Chris@16
|
165 graph_has_add_edge_with_property<Graph>,
|
Chris@16
|
166 graph_has_remove_edge<Graph>
|
Chris@16
|
167 >
|
Chris@16
|
168 { };
|
Chris@16
|
169
|
Chris@16
|
170
|
Chris@16
|
171 template <typename Graph>
|
Chris@16
|
172 struct is_mutable_graph
|
Chris@16
|
173 : mpl::and_<
|
Chris@16
|
174 is_mutable_vertex_graph<Graph>,
|
Chris@16
|
175 is_mutable_edge_graph<Graph>
|
Chris@16
|
176 >
|
Chris@16
|
177 { };
|
Chris@16
|
178
|
Chris@16
|
179 template <typename Graph>
|
Chris@16
|
180 struct is_mutable_property_graph
|
Chris@16
|
181 : mpl::and_<
|
Chris@16
|
182 is_mutable_vertex_property_graph<Graph>,
|
Chris@16
|
183 is_mutable_edge_property_graph<Graph>
|
Chris@16
|
184 >
|
Chris@16
|
185 { };
|
Chris@16
|
186
|
Chris@16
|
187 template <typename Graph>
|
Chris@16
|
188 struct is_add_only_property_graph
|
Chris@16
|
189 : mpl::bool_<
|
Chris@16
|
190 is_convertible<
|
Chris@16
|
191 typename graph_mutability_traits<Graph>::category,
|
Chris@16
|
192 add_only_property_graph_tag
|
Chris@16
|
193 >::value
|
Chris@16
|
194 >
|
Chris@16
|
195 { };
|
Chris@16
|
196
|
Chris@16
|
197 /** @name Mutability Traits Specializations */
|
Chris@16
|
198 //@{
|
Chris@16
|
199
|
Chris@16
|
200 //@}
|
Chris@16
|
201
|
Chris@16
|
202 } // namespace boost
|
Chris@16
|
203
|
Chris@16
|
204 #endif
|