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