Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:42:58

0001 // Copyright (C) 2009 Andrew Sutton
0002 //
0003 // Use, modification and distribution is subject to the Boost Software
0004 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0005 // http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 #ifndef BOOST_GRAPH_MUTABILITY_TRAITS_HPP
0008 #define BOOST_GRAPH_MUTABILITY_TRAITS_HPP
0009 
0010 #include <boost/config.hpp>
0011 #include <boost/mpl/if.hpp>
0012 #include <boost/mpl/and.hpp>
0013 #include <boost/mpl/bool.hpp>
0014 #include <boost/type_traits/is_same.hpp>
0015 
0016 namespace boost
0017 {
0018 
0019 // The mutabiltiy categories classify graphs by their mutating operations
0020 // on the edge and vertex sets. This is a substantially more refined
0021 // categorization than the MutableGraph and MutablePropertyGraph denote.
0022 // Currently, this framework is only used in the graph tests to help
0023 // dispatch test to the correct places. However, there are probably some
0024 // constructive or destructive algorithms (i.e., graph generators) that
0025 // may use these to describe requirements on graph inputs.
0026 
0027 struct add_vertex_tag
0028 {
0029 };
0030 struct add_vertex_property_tag : virtual add_vertex_tag
0031 {
0032 };
0033 struct add_edge_tag
0034 {
0035 };
0036 struct add_edge_property_tag : virtual add_edge_tag
0037 {
0038 };
0039 struct remove_vertex_tag
0040 {
0041 };
0042 struct remove_edge_tag
0043 {
0044 };
0045 
0046 struct mutable_vertex_graph_tag : virtual add_vertex_tag,
0047                                   virtual remove_vertex_tag
0048 {
0049 };
0050 struct mutable_vertex_property_graph_tag : virtual add_vertex_property_tag,
0051                                            virtual remove_vertex_tag
0052 {
0053 };
0054 
0055 struct mutable_edge_graph_tag : virtual add_edge_tag, virtual remove_edge_tag
0056 {
0057 };
0058 struct mutable_edge_property_graph_tag : virtual add_edge_property_tag,
0059                                          virtual remove_edge_tag
0060 {
0061 };
0062 
0063 struct mutable_graph_tag : virtual mutable_vertex_graph_tag,
0064                            virtual mutable_edge_graph_tag
0065 {
0066 };
0067 struct mutable_property_graph_tag : virtual mutable_vertex_property_graph_tag,
0068                                     virtual mutable_edge_property_graph_tag
0069 {
0070 };
0071 
0072 // Some graphs just don't like to be torn down. Note this only restricts
0073 // teardown to the set of vertices, not the vertex set.
0074 // TODO: Find a better name for this tag.
0075 struct add_only_property_graph_tag : virtual add_vertex_property_tag,
0076                                      virtual mutable_edge_property_graph_tag
0077 {
0078 };
0079 
0080 /**
0081  * The graph_mutability_traits provide methods for determining the
0082  * interfaces supported by graph classes for adding and removing vertices
0083  * and edges.
0084  */
0085 template < typename Graph > struct graph_mutability_traits
0086 {
0087     typedef typename Graph::mutability_category category;
0088 };
0089 
0090 template < typename Graph >
0091 struct graph_has_add_vertex
0092 : mpl::bool_<
0093       is_convertible< typename graph_mutability_traits< Graph >::category,
0094           add_vertex_tag >::value >
0095 {
0096 };
0097 
0098 template < typename Graph >
0099 struct graph_has_add_vertex_with_property
0100 : mpl::bool_<
0101       is_convertible< typename graph_mutability_traits< Graph >::category,
0102           add_vertex_property_tag >::value >
0103 {
0104 };
0105 
0106 template < typename Graph >
0107 struct graph_has_remove_vertex
0108 : mpl::bool_<
0109       is_convertible< typename graph_mutability_traits< Graph >::category,
0110           remove_vertex_tag >::value >
0111 {
0112 };
0113 
0114 template < typename Graph >
0115 struct graph_has_add_edge
0116 : mpl::bool_<
0117       is_convertible< typename graph_mutability_traits< Graph >::category,
0118           add_edge_tag >::value >
0119 {
0120 };
0121 
0122 template < typename Graph >
0123 struct graph_has_add_edge_with_property
0124 : mpl::bool_<
0125       is_convertible< typename graph_mutability_traits< Graph >::category,
0126           add_edge_property_tag >::value >
0127 {
0128 };
0129 
0130 template < typename Graph >
0131 struct graph_has_remove_edge
0132 : mpl::bool_<
0133       is_convertible< typename graph_mutability_traits< Graph >::category,
0134           remove_edge_tag >::value >
0135 {
0136 };
0137 
0138 template < typename Graph >
0139 struct is_mutable_vertex_graph
0140 : mpl::and_< graph_has_add_vertex< Graph >, graph_has_remove_vertex< Graph > >
0141 {
0142 };
0143 
0144 template < typename Graph >
0145 struct is_mutable_vertex_property_graph
0146 : mpl::and_< graph_has_add_vertex_with_property< Graph >,
0147       graph_has_remove_vertex< Graph > >
0148 {
0149 };
0150 
0151 template < typename Graph >
0152 struct is_mutable_edge_graph
0153 : mpl::and_< graph_has_add_edge< Graph >, graph_has_remove_edge< Graph > >
0154 {
0155 };
0156 
0157 template < typename Graph >
0158 struct is_mutable_edge_property_graph
0159 : mpl::and_< graph_has_add_edge_with_property< Graph >,
0160       graph_has_remove_edge< Graph > >
0161 {
0162 };
0163 
0164 template < typename Graph >
0165 struct is_mutable_graph
0166 : mpl::and_< is_mutable_vertex_graph< Graph >, is_mutable_edge_graph< Graph > >
0167 {
0168 };
0169 
0170 template < typename Graph >
0171 struct is_mutable_property_graph
0172 : mpl::and_< is_mutable_vertex_property_graph< Graph >,
0173       is_mutable_edge_property_graph< Graph > >
0174 {
0175 };
0176 
0177 template < typename Graph >
0178 struct is_add_only_property_graph
0179 : mpl::bool_<
0180       is_convertible< typename graph_mutability_traits< Graph >::category,
0181           add_only_property_graph_tag >::value >
0182 {
0183 };
0184 
0185 /** @name Mutability Traits Specializations */
0186 //@{
0187 
0188 //@}
0189 
0190 } // namespace boost
0191 
0192 #endif