1// Copyright (C) 2009 Andrew Sutton
2//
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)
6
7#ifndef BOOST_GRAPH_MUTABILITY_TRAITS_HPP
8#define BOOST_GRAPH_MUTABILITY_TRAITS_HPP
9
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>
15
16namespace boost {
17
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.
25
26struct add_vertex_tag { };
27struct add_vertex_property_tag : virtual add_vertex_tag { };
28struct add_edge_tag { };
29struct add_edge_property_tag : virtual add_edge_tag { };
30struct remove_vertex_tag { };
31struct remove_edge_tag { };
32
33struct mutable_vertex_graph_tag
34 : virtual add_vertex_tag, virtual remove_vertex_tag
35{ };
36struct mutable_vertex_property_graph_tag
37 : virtual add_vertex_property_tag, virtual remove_vertex_tag
38{ };
39
40struct mutable_edge_graph_tag
41 : virtual add_edge_tag, virtual remove_edge_tag
42{ };
43struct mutable_edge_property_graph_tag
44 : virtual add_edge_property_tag, virtual remove_edge_tag
45{ };
46
47struct mutable_graph_tag
48 : virtual mutable_vertex_graph_tag
49 , virtual mutable_edge_graph_tag
50{ };
51struct mutable_property_graph_tag
52 : virtual mutable_vertex_property_graph_tag
53 , virtual mutable_edge_property_graph_tag
54{ };
55
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.
59struct add_only_property_graph_tag
60 : virtual add_vertex_property_tag
61 , virtual mutable_edge_property_graph_tag
62{ };
63
64/**
65 * The graph_mutability_traits provide methods for determining the
66 * interfaces supported by graph classes for adding and removing vertices
67 * and edges.
68 */
69template <typename Graph>
70struct graph_mutability_traits {
71 typedef typename Graph::mutability_category category;
72};
73
74template <typename Graph>
75struct graph_has_add_vertex
76 : mpl::bool_<
77 is_convertible<
78 typename graph_mutability_traits<Graph>::category,
79 add_vertex_tag
80 >::value
81 >
82{ };
83
84template <typename Graph>
85struct graph_has_add_vertex_with_property
86 : mpl::bool_<
87 is_convertible<
88 typename graph_mutability_traits<Graph>::category,
89 add_vertex_property_tag
90 >::value
91 >
92{ };
93
94
95template <typename Graph>
96struct graph_has_remove_vertex
97 : mpl::bool_<
98 is_convertible<
99 typename graph_mutability_traits<Graph>::category,
100 remove_vertex_tag
101 >::value
102 >
103{ };
104
105template <typename Graph>
106struct graph_has_add_edge
107 : mpl::bool_<
108 is_convertible<
109 typename graph_mutability_traits<Graph>::category,
110 add_edge_tag
111 >::value
112 >
113{ };
114
115template <typename Graph>
116struct graph_has_add_edge_with_property
117 : mpl::bool_<
118 is_convertible<
119 typename graph_mutability_traits<Graph>::category,
120 add_edge_property_tag
121 >::value
122 >
123{ };
124
125
126template <typename Graph>
127struct graph_has_remove_edge
128 : mpl::bool_<
129 is_convertible<
130 typename graph_mutability_traits<Graph>::category,
131 remove_edge_tag
132 >::value
133 >
134{ };
135
136
137template <typename Graph>
138struct is_mutable_vertex_graph
139 : mpl::and_<
140 graph_has_add_vertex<Graph>,
141 graph_has_remove_vertex<Graph>
142 >
143{ };
144
145template <typename Graph>
146struct is_mutable_vertex_property_graph
147 : mpl::and_<
148 graph_has_add_vertex_with_property<Graph>,
149 graph_has_remove_vertex<Graph>
150 >
151{ };
152
153
154template <typename Graph>
155struct is_mutable_edge_graph
156 : mpl::and_<
157 graph_has_add_edge<Graph>,
158 graph_has_remove_edge<Graph>
159 >
160{ };
161
162template <typename Graph>
163struct is_mutable_edge_property_graph
164 : mpl::and_<
165 graph_has_add_edge_with_property<Graph>,
166 graph_has_remove_edge<Graph>
167 >
168{ };
169
170
171template <typename Graph>
172struct is_mutable_graph
173 : mpl::and_<
174 is_mutable_vertex_graph<Graph>,
175 is_mutable_edge_graph<Graph>
176 >
177{ };
178
179template <typename Graph>
180struct is_mutable_property_graph
181 : mpl::and_<
182 is_mutable_vertex_property_graph<Graph>,
183 is_mutable_edge_property_graph<Graph>
184 >
185{ };
186
187template <typename Graph>
188struct is_add_only_property_graph
189 : mpl::bool_<
190 is_convertible<
191 typename graph_mutability_traits<Graph>::category,
192 add_only_property_graph_tag
193 >::value
194 >
195{ };
196
197/** @name Mutability Traits Specializations */
198//@{
199
200//@}
201
202} // namespace boost
203
204#endif
205

source code of boost/boost/graph/graph_mutability_traits.hpp