1 // Copyright (C) 2009 Andrew Sutton
3 // Use, modification and distribution is subject to the Boost Software
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
7 #ifndef BOOST_GRAPH_MUTABILITY_TRAITS_HPP
8 #define BOOST_GRAPH_MUTABILITY_TRAITS_HPP
10 #include <boost/config.hpp>
11 #include <boost/mpl/if.hpp>
12 #include <boost/mpl/and.hpp>
13 #include <boost/mpl/bool.hpp>
14 #include <boost/type_traits/is_same.hpp>
18 // The mutabiltiy categories classify graphs by their mutating operations
19 // on the edge and vertex sets. This is a substantially more refined
20 // categorization than the MutableGraph and MutablePropertyGraph denote.
21 // Currently, this framework is only used in the graph tests to help
22 // dispatch test to the correct places. However, there are probably some
23 // constructive or destructive algorithms (i.e., graph generators) that
24 // may use these to describe requirements on graph inputs.
26 struct add_vertex_tag { };
27 struct add_vertex_property_tag : virtual add_vertex_tag { };
28 struct add_edge_tag { };
29 struct add_edge_property_tag : virtual add_edge_tag { };
30 struct remove_vertex_tag { };
31 struct remove_edge_tag { };
33 struct mutable_vertex_graph_tag
34 : virtual add_vertex_tag, virtual remove_vertex_tag
36 struct mutable_vertex_property_graph_tag
37 : virtual add_vertex_property_tag, virtual remove_vertex_tag
40 struct mutable_edge_graph_tag
41 : virtual add_edge_tag, virtual remove_edge_tag
43 struct mutable_edge_property_graph_tag
44 : virtual add_edge_property_tag, virtual remove_edge_tag
47 struct mutable_graph_tag
48 : virtual mutable_vertex_graph_tag
49 , virtual mutable_edge_graph_tag
51 struct mutable_property_graph_tag
52 : virtual mutable_vertex_property_graph_tag
53 , virtual mutable_edge_property_graph_tag
56 // Some graphs just don't like to be torn down. Note this only restricts
57 // teardown to the set of vertices, not the vertex set.
58 // TODO: Find a better name for this tag.
59 struct add_only_property_graph_tag
60 : virtual add_vertex_property_tag
61 , virtual mutable_edge_property_graph_tag
65 * The graph_mutability_traits provide methods for determining the
66 * interfaces supported by graph classes for adding and removing vertices
69 template <typename Graph>
70 struct graph_mutability_traits {
71 typedef typename Graph::mutability_category category;
74 template <typename Graph>
75 struct graph_has_add_vertex
78 typename graph_mutability_traits<Graph>::category,
84 template <typename Graph>
85 struct graph_has_add_vertex_with_property
88 typename graph_mutability_traits<Graph>::category,
89 add_vertex_property_tag
95 template <typename Graph>
96 struct graph_has_remove_vertex
99 typename graph_mutability_traits<Graph>::category,
105 template <typename Graph>
106 struct graph_has_add_edge
109 typename graph_mutability_traits<Graph>::category,
115 template <typename Graph>
116 struct graph_has_add_edge_with_property
119 typename graph_mutability_traits<Graph>::category,
120 add_edge_property_tag
126 template <typename Graph>
127 struct graph_has_remove_edge
130 typename graph_mutability_traits<Graph>::category,
137 template <typename Graph>
138 struct is_mutable_vertex_graph
140 graph_has_add_vertex<Graph>,
141 graph_has_remove_vertex<Graph>
145 template <typename Graph>
146 struct is_mutable_vertex_property_graph
148 graph_has_add_vertex_with_property<Graph>,
149 graph_has_remove_vertex<Graph>
154 template <typename Graph>
155 struct is_mutable_edge_graph
157 graph_has_add_edge<Graph>,
158 graph_has_remove_edge<Graph>
162 template <typename Graph>
163 struct is_mutable_edge_property_graph
165 graph_has_add_edge_with_property<Graph>,
166 graph_has_remove_edge<Graph>
171 template <typename Graph>
172 struct is_mutable_graph
174 is_mutable_vertex_graph<Graph>,
175 is_mutable_edge_graph<Graph>
179 template <typename Graph>
180 struct is_mutable_property_graph
182 is_mutable_vertex_property_graph<Graph>,
183 is_mutable_edge_property_graph<Graph>
187 template <typename Graph>
188 struct is_add_only_property_graph
191 typename graph_mutability_traits<Graph>::category,
192 add_only_property_graph_tag
197 /** @name Mutability Traits Specializations */