mirror of
https://github.com/boostorg/graph.git
synced 2026-02-01 08:32:11 +00:00
Changed property lookup code to simplify graph implementations (remove most special-casing of bundled properties), made CSR graph work with non-bundled properties (probably), split named parameter algorithms to not use property map code
[SVN r77549]
This commit is contained in:
@@ -51,11 +51,6 @@ namespace boost {
|
||||
// adjacency_list, and the container_gen traits class which is used
|
||||
// to map the selectors to the container type used to implement the
|
||||
// graph.
|
||||
//
|
||||
// The main container_gen traits class uses partial specialization,
|
||||
// so we also include a workaround.
|
||||
|
||||
#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
#if !defined BOOST_NO_SLIST
|
||||
struct slistS {};
|
||||
@@ -130,93 +125,6 @@ namespace boost {
|
||||
typedef boost::unordered_multiset<ValueType> type;
|
||||
};
|
||||
|
||||
#else // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
#if !defined BOOST_NO_SLIST
|
||||
struct slistS {
|
||||
template <class T>
|
||||
struct bind_ { typedef BOOST_STD_EXTENSION_NAMESPACE::slist<T> type; };
|
||||
};
|
||||
#endif
|
||||
|
||||
struct vecS {
|
||||
template <class T>
|
||||
struct bind_ { typedef std::vector<T> type; };
|
||||
};
|
||||
|
||||
struct listS {
|
||||
template <class T>
|
||||
struct bind_ { typedef std::list<T> type; };
|
||||
};
|
||||
|
||||
struct setS {
|
||||
template <class T>
|
||||
struct bind_ { typedef std::set<T, std::less<T> > type; };
|
||||
};
|
||||
|
||||
|
||||
struct mapS {
|
||||
template <class T>
|
||||
struct bind_ { typedef std::set<T, std::less<T> > type; };
|
||||
};
|
||||
|
||||
struct multisetS {
|
||||
template <class T>
|
||||
struct bind_ { typedef std::multiset<T, std::less<T> > type; };
|
||||
};
|
||||
|
||||
struct multimapS {
|
||||
template <class T>
|
||||
struct bind_ { typedef std::multiset<T, std::less<T> > type; };
|
||||
};
|
||||
|
||||
struct hash_setS {
|
||||
template <class T>
|
||||
struct bind_ { typedef boost::unordered_set<T> type; };
|
||||
};
|
||||
|
||||
struct hash_mapS {
|
||||
template <class T>
|
||||
struct bind_ { typedef boost::unordered_set<T> type; };
|
||||
};
|
||||
|
||||
struct hash_multisetS {
|
||||
template <class T>
|
||||
struct bind_ { typedef boost::unordered_multiset<T> type; };
|
||||
};
|
||||
|
||||
struct hash_multimapS {
|
||||
template <class T>
|
||||
struct bind_ { typedef boost::unordered_multiset<T> type; };
|
||||
};
|
||||
|
||||
template <class Selector> struct container_selector {
|
||||
typedef vecS type;
|
||||
};
|
||||
|
||||
#define BOOST_CONTAINER_SELECTOR(NAME) \
|
||||
template <> struct container_selector<NAME> { \
|
||||
typedef NAME type; \
|
||||
}
|
||||
|
||||
BOOST_CONTAINER_SELECTOR(vecS);
|
||||
BOOST_CONTAINER_SELECTOR(listS);
|
||||
BOOST_CONTAINER_SELECTOR(mapS);
|
||||
BOOST_CONTAINER_SELECTOR(setS);
|
||||
BOOST_CONTAINER_SELECTOR(multisetS);
|
||||
BOOST_CONTAINER_SELECTOR(hash_mapS);
|
||||
#if !defined BOOST_NO_SLIST
|
||||
BOOST_CONTAINER_SELECTOR(slistS);
|
||||
#endif
|
||||
|
||||
template <class Selector, class ValueType>
|
||||
struct container_gen {
|
||||
typedef typename container_selector<Selector>::type Select;
|
||||
typedef typename Select:: template bind_<ValueType>::type type;
|
||||
};
|
||||
|
||||
#endif // !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
template <class StorageSelector>
|
||||
struct parallel_edge_traits { };
|
||||
|
||||
@@ -354,13 +262,7 @@ namespace boost {
|
||||
adjacency_list<OutEdgeListS,VertexListS,DirectedS,
|
||||
VertexProperty,EdgeProperty,GraphProperty,EdgeListS>,
|
||||
VertexListS, OutEdgeListS, DirectedS,
|
||||
#if !defined(BOOST_GRAPH_NO_BUNDLED_PROPERTIES)
|
||||
typename detail::retag_property_list<vertex_bundle_t,
|
||||
VertexProperty>::type,
|
||||
typename detail::retag_property_list<edge_bundle_t, EdgeProperty>::type,
|
||||
#else
|
||||
VertexProperty, EdgeProperty,
|
||||
#endif
|
||||
GraphProperty, EdgeListS>::type,
|
||||
// Support for named vertices
|
||||
public graph::maybe_named_graph<
|
||||
@@ -371,25 +273,14 @@ namespace boost {
|
||||
VertexProperty>
|
||||
{
|
||||
public:
|
||||
#if !defined(BOOST_GRAPH_NO_BUNDLED_PROPERTIES)
|
||||
typedef typename graph_detail::graph_prop<GraphProperty>::property graph_property_type;
|
||||
typedef typename graph_detail::graph_prop<GraphProperty>::bundle graph_bundled;
|
||||
|
||||
typedef typename graph_detail::vertex_prop<VertexProperty>::property vertex_property_type;
|
||||
typedef typename graph_detail::vertex_prop<VertexProperty>::bundle vertex_bundled;
|
||||
|
||||
typedef typename graph_detail::edge_prop<EdgeProperty>::property edge_property_type;
|
||||
typedef typename graph_detail::edge_prop<EdgeProperty>::bundle edge_bundled;
|
||||
#else
|
||||
typedef GraphProperty graph_property_type;
|
||||
typedef no_graph_bundle graph_bundled;
|
||||
typedef typename lookup_one_property<GraphProperty, graph_bundle_t>::type graph_bundled;
|
||||
|
||||
typedef VertexProperty vertex_property_type;
|
||||
typedef no_vertex_bundle vertex_bundled;
|
||||
typedef typename lookup_one_property<VertexProperty, vertex_bundle_t>::type vertex_bundled;
|
||||
|
||||
typedef EdgeProperty edge_property_type;
|
||||
typedef no_edge_bundle edge_bundled;
|
||||
#endif
|
||||
typedef typename lookup_one_property<EdgeProperty, edge_bundle_t>::type edge_bundled;
|
||||
|
||||
private:
|
||||
typedef adjacency_list self;
|
||||
@@ -545,58 +436,6 @@ namespace boost {
|
||||
return e.m_target;
|
||||
}
|
||||
|
||||
// Support for bundled properties
|
||||
#ifndef BOOST_GRAPH_NO_BUNDLED_PROPERTIES
|
||||
template<typename OutEdgeListS, typename VertexListS, typename DirectedS, typename VertexProperty,
|
||||
typename EdgeProperty, typename GraphProperty, typename EdgeListS, typename T, typename Bundle>
|
||||
inline
|
||||
typename property_map<adjacency_list<OutEdgeListS, VertexListS, DirectedS, VertexProperty, EdgeProperty,
|
||||
GraphProperty, EdgeListS>, T Bundle::*>::type
|
||||
get(T Bundle::* p, adjacency_list<OutEdgeListS, VertexListS, DirectedS, VertexProperty, EdgeProperty,
|
||||
GraphProperty, EdgeListS>& g)
|
||||
{
|
||||
typedef typename property_map<adjacency_list<OutEdgeListS, VertexListS, DirectedS, VertexProperty,
|
||||
EdgeProperty, GraphProperty, EdgeListS>, T Bundle::*>::type
|
||||
result_type;
|
||||
return result_type(&g, p);
|
||||
}
|
||||
|
||||
template<typename OutEdgeListS, typename VertexListS, typename DirectedS, typename VertexProperty,
|
||||
typename EdgeProperty, typename GraphProperty, typename EdgeListS, typename T, typename Bundle>
|
||||
inline
|
||||
typename property_map<adjacency_list<OutEdgeListS, VertexListS, DirectedS, VertexProperty, EdgeProperty,
|
||||
GraphProperty, EdgeListS>, T Bundle::*>::const_type
|
||||
get(T Bundle::* p, adjacency_list<OutEdgeListS, VertexListS, DirectedS, VertexProperty, EdgeProperty,
|
||||
GraphProperty, EdgeListS> const & g)
|
||||
{
|
||||
typedef typename property_map<adjacency_list<OutEdgeListS, VertexListS, DirectedS, VertexProperty,
|
||||
EdgeProperty, GraphProperty, EdgeListS>, T Bundle::*>::const_type
|
||||
result_type;
|
||||
return result_type(&g, p);
|
||||
}
|
||||
|
||||
template<typename OutEdgeListS, typename VertexListS, typename DirectedS, typename VertexProperty,
|
||||
typename EdgeProperty, typename GraphProperty, typename EdgeListS, typename T, typename Bundle,
|
||||
typename Key>
|
||||
inline T
|
||||
get(T Bundle::* p, adjacency_list<OutEdgeListS, VertexListS, DirectedS, VertexProperty, EdgeProperty,
|
||||
GraphProperty, EdgeListS> const & g, const Key& key)
|
||||
{
|
||||
return get(get(p, g), key);
|
||||
}
|
||||
|
||||
template<typename OutEdgeListS, typename VertexListS, typename DirectedS, typename VertexProperty,
|
||||
typename EdgeProperty, typename GraphProperty, typename EdgeListS, typename T, typename Bundle,
|
||||
typename Key>
|
||||
inline void
|
||||
put(T Bundle::* p, adjacency_list<OutEdgeListS, VertexListS, DirectedS, VertexProperty, EdgeProperty,
|
||||
GraphProperty, EdgeListS>& g, const Key& key, const T& value)
|
||||
{
|
||||
put(get(p, g), key, value);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// Mutability Traits
|
||||
template <ADJLIST_PARAMS>
|
||||
struct graph_mutability_traits<ADJLIST> {
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace boost {
|
||||
template<class Tag, class Value, class Next>
|
||||
std::istream& operator >> ( std::istream& in, property<Tag,Value,Next>& p )
|
||||
{
|
||||
in >> p.m_value >> *(static_cast<Next*>(&p)); // houpla !!
|
||||
in >> p.m_value >> p.m_base; // houpla !!
|
||||
return in;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ template<class Tag, class Value, class Next, class V, class Stag>
|
||||
void get
|
||||
( property<Tag,Value,Next>& p, const V& v, Stag s )
|
||||
{
|
||||
get( *(static_cast<Next*>(&p)),v,s );
|
||||
get( p.m_base,v,s );
|
||||
}
|
||||
|
||||
template<class Value, class Next, class V, class Stag>
|
||||
@@ -82,7 +82,7 @@ void getSubset
|
||||
( property<Tag,Value,Next>& p, const property<Stag,Svalue,Snext>& s )
|
||||
{
|
||||
get( p, s.m_value, Stag() );
|
||||
getSubset( p, Snext(s) );
|
||||
getSubset( p, s.m_base );
|
||||
}
|
||||
|
||||
template<class Tag, class Value, class Next,
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <boost/graph/graph_mutability_traits.hpp>
|
||||
#include <boost/graph/graph_selectors.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/graph/adjacency_iterator.hpp>
|
||||
#include <boost/graph/detail/edge.hpp>
|
||||
#include <boost/iterator/iterator_adaptor.hpp>
|
||||
@@ -29,7 +30,10 @@
|
||||
#include <boost/graph/properties.hpp>
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/type_traits/ice.hpp>
|
||||
#include <boost/type_traits.hpp>
|
||||
#include <boost/property_map/property_map.hpp>
|
||||
#include <boost/property_map/transform_value_property_map.hpp>
|
||||
#include <boost/property_map/function_property_map.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
@@ -484,25 +488,14 @@ namespace boost {
|
||||
BOOST_STATIC_ASSERT(!(is_same<Directed, bidirectionalS>::value));
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_GRAPH_NO_BUNDLED_PROPERTIES)
|
||||
typedef typename graph_detail::graph_prop<GraphProperty>::property graph_property_type;
|
||||
typedef typename graph_detail::graph_prop<GraphProperty>::bundle graph_bundled;
|
||||
|
||||
typedef typename graph_detail::vertex_prop<VertexProperty>::property vertex_property_type;
|
||||
typedef typename graph_detail::vertex_prop<VertexProperty>::bundle vertex_bundled;
|
||||
|
||||
typedef typename graph_detail::edge_prop<EdgeProperty>::property edge_property_type;
|
||||
typedef typename graph_detail::edge_prop<EdgeProperty>::bundle edge_bundled;
|
||||
#else
|
||||
typedef GraphProperty graph_property_type;
|
||||
typedef no_graph_bundle graph_bundled;
|
||||
typedef typename lookup_one_property<GraphProperty, graph_bundle_t>::type graph_bundled;
|
||||
|
||||
typedef VertexProperty vertex_property_type;
|
||||
typedef no_vertex_bundle vertex_bundled;
|
||||
typedef typename lookup_one_property<VertexProperty, vertex_bundle_t>::type vertex_bundled;
|
||||
|
||||
typedef EdgeProperty edge_property_type;
|
||||
typedef no_edge_bundle edge_bundled;
|
||||
#endif
|
||||
typedef typename lookup_one_property<EdgeProperty, edge_bundle_t>::type edge_bundled;
|
||||
|
||||
public: // should be private
|
||||
typedef typename mpl::if_<typename has_property<edge_property_type>::type,
|
||||
@@ -640,16 +633,16 @@ namespace boost {
|
||||
#ifndef BOOST_GRAPH_NO_BUNDLED_PROPERTIES
|
||||
// Directly access a vertex or edge bundle
|
||||
vertex_bundled& operator[](vertex_descriptor v)
|
||||
{ return get(vertex_bundle, *this)[v]; }
|
||||
{ return get(vertex_bundle, *this, v); }
|
||||
|
||||
const vertex_bundled& operator[](vertex_descriptor v) const
|
||||
{ return get(vertex_bundle, *this)[v]; }
|
||||
{ return get(vertex_bundle, *this, v); }
|
||||
|
||||
edge_bundled& operator[](edge_descriptor e)
|
||||
{ return get(edge_bundle, *this)[e]; }
|
||||
{ return get(edge_bundle, *this, e); }
|
||||
|
||||
const edge_bundled& operator[](edge_descriptor e) const
|
||||
{ return get(edge_bundle, *this)[e]; }
|
||||
{ return get(edge_bundle, *this, e); }
|
||||
|
||||
graph_bundled& operator[](graph_bundle_t)
|
||||
{ return get_property(*this); }
|
||||
@@ -1035,256 +1028,194 @@ namespace boost {
|
||||
//=========================================================================
|
||||
// Functions required by the PropertyGraph concept
|
||||
|
||||
template <typename D, typename VP, typename EP, typename GP, typename A,
|
||||
typename Prop, typename Kind>
|
||||
struct adj_mat_pm_helper;
|
||||
|
||||
template <typename D, typename VP, typename EP, typename GP, typename A,
|
||||
typename Prop>
|
||||
struct adj_mat_pm_helper<D, VP, EP, GP, A, Prop, vertex_property_tag> {
|
||||
typedef typename graph_traits<adjacency_matrix<D, VP, EP, GP, A> >::vertex_descriptor arg_type;
|
||||
typedef typed_identity_property_map<arg_type> vi_map_type;
|
||||
typedef iterator_property_map<typename std::vector<VP>::iterator, vi_map_type> all_map_type;
|
||||
typedef iterator_property_map<typename std::vector<VP>::const_iterator, vi_map_type> all_map_const_type;
|
||||
typedef transform_value_property_map<
|
||||
detail::lookup_one_property_f<VP, Prop>,
|
||||
all_map_type>
|
||||
type;
|
||||
typedef transform_value_property_map<
|
||||
detail::lookup_one_property_f<const VP, Prop>,
|
||||
all_map_const_type>
|
||||
const_type;
|
||||
typedef typename property_traits<type>::reference single_nonconst_type;
|
||||
typedef typename property_traits<const_type>::reference single_const_type;
|
||||
|
||||
static type get_nonconst(adjacency_matrix<D, VP, EP, GP, A>& g, Prop prop) {
|
||||
return type(prop, all_map_type(g.m_vertex_properties.begin(), vi_map_type()));
|
||||
}
|
||||
|
||||
static const_type get_const(const adjacency_matrix<D, VP, EP, GP, A>& g, Prop prop) {
|
||||
return const_type(prop, all_map_const_type(g.m_vertex_properties.begin(), vi_map_type()));
|
||||
}
|
||||
|
||||
static single_nonconst_type get_nonconst_one(adjacency_matrix<D, VP, EP, GP, A>& g, Prop prop, arg_type v) {
|
||||
return lookup_one_property<VP, Prop>::lookup(g.m_vertex_properties[v], prop);
|
||||
}
|
||||
|
||||
static single_const_type get_const_one(const adjacency_matrix<D, VP, EP, GP, A>& g, Prop prop, arg_type v) {
|
||||
return lookup_one_property<const VP, Prop>::lookup(g.m_vertex_properties[v], prop);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename D, typename VP, typename EP, typename GP, typename A,
|
||||
typename Tag>
|
||||
struct adj_mat_pm_helper<D, VP, EP, GP, A, Tag, edge_property_tag> {
|
||||
typedef typename graph_traits<adjacency_matrix<D, VP, EP, GP, A> >::edge_descriptor edge_descriptor;
|
||||
|
||||
template <typename IsConst>
|
||||
struct lookup_property_from_edge {
|
||||
Tag tag;
|
||||
lookup_property_from_edge(Tag tag): tag(tag) {}
|
||||
typedef typename boost::mpl::if_<IsConst, const EP, EP>::type ep_type_nonref;
|
||||
typedef ep_type_nonref& ep_type;
|
||||
typedef typename lookup_one_property<ep_type_nonref, Tag>::type& result_type;
|
||||
result_type operator()(edge_descriptor e) const {
|
||||
return lookup_one_property<ep_type_nonref, Tag>::lookup(*static_cast<ep_type_nonref*>(e.get_property()), tag);
|
||||
}
|
||||
};
|
||||
|
||||
typedef function_property_map<
|
||||
lookup_property_from_edge<boost::mpl::false_>,
|
||||
typename graph_traits<adjacency_matrix<D, VP, EP, GP, A> >::edge_descriptor> type;
|
||||
typedef function_property_map<
|
||||
lookup_property_from_edge<boost::mpl::true_>,
|
||||
typename graph_traits<adjacency_matrix<D, VP, EP, GP, A> >::edge_descriptor> const_type;
|
||||
typedef edge_descriptor arg_type;
|
||||
typedef typename lookup_property_from_edge<boost::mpl::false_>::result_type single_nonconst_type;
|
||||
typedef typename lookup_property_from_edge<boost::mpl::true_>::result_type single_const_type;
|
||||
|
||||
static type get_nonconst(adjacency_matrix<D, VP, EP, GP, A>& g, Tag tag) {
|
||||
return type(tag);
|
||||
}
|
||||
|
||||
static const_type get_const(const adjacency_matrix<D, VP, EP, GP, A>& g, Tag tag) {
|
||||
return const_type(tag);
|
||||
}
|
||||
|
||||
static single_nonconst_type get_nonconst_one(adjacency_matrix<D, VP, EP, GP, A>& g, Tag tag, edge_descriptor e) {
|
||||
return lookup_one_property<EP, Tag>::lookup(*static_cast<EP*>(e.get_property()), tag);
|
||||
}
|
||||
|
||||
static single_const_type get_const_one(const adjacency_matrix<D, VP, EP, GP, A>& g, Tag tag, edge_descriptor e) {
|
||||
return lookup_one_property<const EP, Tag>::lookup(*static_cast<const EP*>(e.get_property()), tag);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename D, typename VP, typename EP, typename GP, typename A,
|
||||
typename Tag>
|
||||
struct property_map<adjacency_matrix<D,VP,EP,GP,A>, Tag>
|
||||
: adj_mat_pm_helper<D, VP, EP, GP, A, Tag,
|
||||
typename detail::property_kind_from_graph<adjacency_matrix<D, VP, EP, GP, A>, Tag>::type> {};
|
||||
|
||||
template <typename D, typename VP, typename EP, typename GP, typename A,
|
||||
typename Tag>
|
||||
typename property_map<adjacency_matrix<D, VP, EP, GP, A>, Tag>::type
|
||||
get(Tag tag, adjacency_matrix<D, VP, EP, GP, A>& g) {
|
||||
return property_map<adjacency_matrix<D, VP, EP, GP, A>, Tag>::get_nonconst(g, tag);
|
||||
}
|
||||
|
||||
template <typename D, typename VP, typename EP, typename GP, typename A,
|
||||
typename Tag>
|
||||
typename property_map<adjacency_matrix<D, VP, EP, GP, A>, Tag>::const_type
|
||||
get(Tag tag, const adjacency_matrix<D, VP, EP, GP, A>& g) {
|
||||
return property_map<adjacency_matrix<D, VP, EP, GP, A>, Tag>::get_const(g, tag);
|
||||
}
|
||||
|
||||
template <typename D, typename VP, typename EP, typename GP, typename A,
|
||||
typename Tag>
|
||||
typename property_map<adjacency_matrix<D, VP, EP, GP, A>, Tag>::single_nonconst_type
|
||||
get(Tag tag, adjacency_matrix<D, VP, EP, GP, A>& g, typename property_map<adjacency_matrix<D, VP, EP, GP, A>, Tag>::arg_type a) {
|
||||
return property_map<adjacency_matrix<D, VP, EP, GP, A>, Tag>::get_nonconst_one(g, tag, a);
|
||||
}
|
||||
|
||||
template <typename D, typename VP, typename EP, typename GP, typename A,
|
||||
typename Tag>
|
||||
typename property_map<adjacency_matrix<D, VP, EP, GP, A>, Tag>::single_const_type
|
||||
get(Tag tag, const adjacency_matrix<D, VP, EP, GP, A>& g, typename property_map<adjacency_matrix<D, VP, EP, GP, A>, Tag>::arg_type a) {
|
||||
return property_map<adjacency_matrix<D, VP, EP, GP, A>, Tag>::get_const_one(g, tag, a);
|
||||
}
|
||||
|
||||
template <typename D, typename VP, typename EP, typename GP, typename A,
|
||||
typename Tag>
|
||||
void
|
||||
put(Tag tag,
|
||||
adjacency_matrix<D, VP, EP, GP, A>& g,
|
||||
typename property_map<adjacency_matrix<D, VP, EP, GP, A>, Tag>::arg_type a,
|
||||
typename property_map<adjacency_matrix<D, VP, EP, GP, A>, Tag>::single_const_type val) {
|
||||
property_map<adjacency_matrix<D, VP, EP, GP, A>, Tag>::get_nonconst_one(g, tag, a) = val;
|
||||
}
|
||||
|
||||
// O(1)
|
||||
template <typename D, typename VP, typename EP, typename GP, typename A,
|
||||
typename Tag, typename Value>
|
||||
inline void
|
||||
set_property(adjacency_matrix<D,VP,EP,GP,A>& g, Tag, const Value& value)
|
||||
set_property(adjacency_matrix<D,VP,EP,GP,A>& g, Tag tag, const Value& value)
|
||||
{
|
||||
get_property_value(g.m_property, Tag()) = value;
|
||||
get_property_value(g.m_property, tag) = value;
|
||||
}
|
||||
|
||||
template <typename D, typename VP, typename EP, typename GP, typename A,
|
||||
typename Tag>
|
||||
inline typename graph_property<adjacency_matrix<D,VP,EP,GP,A>, Tag>::type&
|
||||
get_property(adjacency_matrix<D,VP,EP,GP,A>& g, Tag)
|
||||
get_property(adjacency_matrix<D,VP,EP,GP,A>& g, Tag tag)
|
||||
{
|
||||
return get_property_value(g.m_property, Tag());
|
||||
return get_property_value(g.m_property, tag);
|
||||
}
|
||||
|
||||
template <typename D, typename VP, typename EP, typename GP, typename A,
|
||||
typename Tag>
|
||||
inline const typename graph_property<adjacency_matrix<D,VP,EP,GP,A>, Tag>::type&
|
||||
get_property(const adjacency_matrix<D,VP,EP,GP,A>& g, Tag)
|
||||
get_property(const adjacency_matrix<D,VP,EP,GP,A>& g, Tag tag)
|
||||
{
|
||||
return get_property_value(g.m_property, Tag());
|
||||
return get_property_value(g.m_property, tag);
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
// Vertex Property Map
|
||||
|
||||
template <typename GraphPtr, typename Vertex, typename T, typename R,
|
||||
typename Tag>
|
||||
class adj_matrix_vertex_property_map
|
||||
: public put_get_helper<R,
|
||||
adj_matrix_vertex_property_map<GraphPtr, Vertex, T, R, Tag> >
|
||||
{
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef R reference;
|
||||
typedef Vertex key_type;
|
||||
typedef boost::lvalue_property_map_tag category;
|
||||
adj_matrix_vertex_property_map() { }
|
||||
adj_matrix_vertex_property_map(GraphPtr g) : m_g(g) { }
|
||||
inline reference operator[](key_type v) const {
|
||||
return get_property_value(m_g->m_vertex_properties[v], Tag());
|
||||
}
|
||||
GraphPtr m_g;
|
||||
template <typename D, typename VP, typename EP, typename GP, typename A>
|
||||
struct property_map<adjacency_matrix<D, VP, EP, GP, A>, vertex_index_t> {
|
||||
typedef typename adjacency_matrix<D, VP, EP, GP, A>::vertex_descriptor Vertex;
|
||||
typedef typed_identity_property_map<Vertex> type;
|
||||
typedef type const_type;
|
||||
};
|
||||
|
||||
template <class Property, class Vertex>
|
||||
struct adj_matrix_vertex_id_map
|
||||
: public boost::put_get_helper<Vertex,
|
||||
adj_matrix_vertex_id_map<Property, Vertex> >
|
||||
{
|
||||
typedef Vertex value_type;
|
||||
typedef Vertex reference;
|
||||
typedef Vertex key_type;
|
||||
typedef boost::readable_property_map_tag category;
|
||||
adj_matrix_vertex_id_map() { }
|
||||
template <class Graph>
|
||||
inline adj_matrix_vertex_id_map(const Graph&) { }
|
||||
inline value_type operator[](key_type v) const { return v; }
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
struct adj_matrix_any_vertex_pa {
|
||||
template <class Tag, class Graph, class Property>
|
||||
struct bind_ {
|
||||
typedef typename property_value<Property,Tag>::type Value;
|
||||
typedef typename boost::graph_traits<Graph>::vertex_descriptor Vertex;
|
||||
|
||||
typedef adj_matrix_vertex_property_map<Graph*, Vertex, Value, Value&,
|
||||
Tag> type;
|
||||
typedef adj_matrix_vertex_property_map<const Graph*, Vertex, Value,
|
||||
const Value&, Tag> const_type;
|
||||
};
|
||||
};
|
||||
struct adj_matrix_id_vertex_pa {
|
||||
template <class Tag, class Graph, class Property>
|
||||
struct bind_ {
|
||||
typedef typename Graph::vertex_descriptor Vertex;
|
||||
typedef adj_matrix_vertex_id_map<Property, Vertex> type;
|
||||
typedef adj_matrix_vertex_id_map<Property, Vertex> const_type;
|
||||
};
|
||||
};
|
||||
|
||||
template <class Tag>
|
||||
struct adj_matrix_choose_vertex_pa_helper {
|
||||
typedef adj_matrix_any_vertex_pa type;
|
||||
};
|
||||
template <>
|
||||
struct adj_matrix_choose_vertex_pa_helper<vertex_index_t> {
|
||||
typedef adj_matrix_id_vertex_pa type;
|
||||
};
|
||||
|
||||
template <class Tag, class Graph, class Property>
|
||||
struct adj_matrix_choose_vertex_pa {
|
||||
typedef typename adj_matrix_choose_vertex_pa_helper<Tag>::type Helper;
|
||||
typedef typename Helper::template bind_<Tag,Graph,Property> Bind;
|
||||
typedef typename Bind::type type;
|
||||
typedef typename Bind::const_type const_type;
|
||||
};
|
||||
|
||||
struct adj_matrix_vertex_property_selector {
|
||||
template <class Graph, class Property, class Tag>
|
||||
struct bind_ {
|
||||
typedef adj_matrix_choose_vertex_pa<Tag,Graph,Property> Choice;
|
||||
typedef typename Choice::type type;
|
||||
typedef typename Choice::const_type const_type;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <>
|
||||
struct vertex_property_selector<adjacency_matrix_class_tag> {
|
||||
typedef detail::adj_matrix_vertex_property_selector type;
|
||||
};
|
||||
|
||||
//=========================================================================
|
||||
// Edge Property Map
|
||||
|
||||
|
||||
template <typename Directed, typename Property, typename Vertex,
|
||||
typename T, typename R, typename Tag>
|
||||
class adj_matrix_edge_property_map
|
||||
: public put_get_helper<R,
|
||||
adj_matrix_edge_property_map<Directed, Property, Vertex, T, R, Tag> >
|
||||
{
|
||||
public:
|
||||
typedef T value_type;
|
||||
typedef R reference;
|
||||
typedef detail::matrix_edge_desc_impl<Directed, Vertex> key_type;
|
||||
typedef boost::lvalue_property_map_tag category;
|
||||
inline reference operator[](key_type e) const {
|
||||
Property& p = *(Property*)e.get_property();
|
||||
return get_property_value(p, Tag());
|
||||
}
|
||||
};
|
||||
struct adj_matrix_edge_property_selector {
|
||||
template <class Graph, class Property, class Tag>
|
||||
struct bind_ {
|
||||
typedef typename property_value<Property,Tag>::type T;
|
||||
typedef typename Graph::vertex_descriptor Vertex;
|
||||
typedef adj_matrix_edge_property_map<typename Graph::directed_category,
|
||||
Property, Vertex, T, T&, Tag> type;
|
||||
typedef adj_matrix_edge_property_map<typename Graph::directed_category,
|
||||
Property, Vertex, T, const T&, Tag> const_type;
|
||||
};
|
||||
};
|
||||
template <>
|
||||
struct edge_property_selector<adjacency_matrix_class_tag> {
|
||||
typedef adj_matrix_edge_property_selector type;
|
||||
};
|
||||
|
||||
//=========================================================================
|
||||
// Functions required by PropertyGraph
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename Property, typename D, typename VP, typename EP,
|
||||
typename GP, typename A>
|
||||
typename boost::property_map<adjacency_matrix<D,VP,EP,GP,A>,
|
||||
Property>::type
|
||||
get_dispatch(adjacency_matrix<D,VP,EP,GP,A>& g, Property,
|
||||
vertex_property_tag)
|
||||
{
|
||||
typedef adjacency_matrix<D,VP,EP,GP,A> Graph;
|
||||
typedef typename boost::property_map<adjacency_matrix<D,VP,EP,GP,A>,
|
||||
Property>::type PA;
|
||||
return PA(&g);
|
||||
}
|
||||
template <typename Property, typename D, typename VP, typename EP,
|
||||
typename GP, typename A>
|
||||
typename boost::property_map<adjacency_matrix<D,VP,EP,GP,A>,
|
||||
Property>::type
|
||||
get_dispatch(adjacency_matrix<D,VP,EP,GP,A>&, Property,
|
||||
edge_property_tag)
|
||||
{
|
||||
typedef typename boost::property_map<adjacency_matrix<D,VP,EP,GP,A>,
|
||||
Property>::type PA;
|
||||
return PA();
|
||||
}
|
||||
template <typename Property, typename D, typename VP, typename EP,
|
||||
typename GP, typename A>
|
||||
typename boost::property_map<adjacency_matrix<D,VP,EP,GP,A>,
|
||||
Property>::const_type
|
||||
get_dispatch(const adjacency_matrix<D,VP,EP,GP,A>& g, Property,
|
||||
vertex_property_tag)
|
||||
{
|
||||
typedef adjacency_matrix<D,VP,EP,GP,A> Graph;
|
||||
typedef typename boost::property_map<adjacency_matrix<D,VP,EP,GP,A>,
|
||||
Property>::const_type PA;
|
||||
return PA(&g);
|
||||
}
|
||||
template <typename Property, typename D, typename VP, typename EP,
|
||||
typename GP, typename A>
|
||||
typename boost::property_map<adjacency_matrix<D,VP,EP,GP,A>,
|
||||
Property>::const_type
|
||||
get_dispatch(const adjacency_matrix<D,VP,EP,GP,A>&, Property,
|
||||
edge_property_tag)
|
||||
{
|
||||
typedef typename boost::property_map<adjacency_matrix<D,VP,EP,GP,A>,
|
||||
Property>::const_type PA;
|
||||
return PA();
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <typename Property, typename D, typename VP, typename EP,
|
||||
typename GP, typename A>
|
||||
inline
|
||||
typename property_map<adjacency_matrix<D,VP,EP,GP,A>, Property>::type
|
||||
get(Property p, adjacency_matrix<D,VP,EP,GP,A>& g)
|
||||
{
|
||||
typedef typename property_kind<Property>::type Kind;
|
||||
return detail::get_dispatch(g, p, Kind());
|
||||
template <typename D, typename VP, typename EP, typename GP, typename A>
|
||||
typename property_map<adjacency_matrix<D, VP, EP, GP, A>, vertex_index_t>::const_type
|
||||
get(vertex_index_t, adjacency_matrix<D, VP, EP, GP, A>&) {
|
||||
return typename property_map<adjacency_matrix<D, VP, EP, GP, A>, vertex_index_t>::const_type();
|
||||
}
|
||||
|
||||
template <typename Property, typename D, typename VP, typename EP,
|
||||
typename GP, typename A>
|
||||
inline
|
||||
typename property_map<adjacency_matrix<D,VP,EP,GP,A>, Property>::const_type
|
||||
get(Property p, const adjacency_matrix<D,VP,EP,GP,A>& g)
|
||||
{
|
||||
typedef typename property_kind<Property>::type Kind;
|
||||
return detail::get_dispatch(g, p, Kind());
|
||||
template <typename D, typename VP, typename EP, typename GP, typename A>
|
||||
typename adjacency_matrix<D, VP, EP, GP, A>::vertex_descriptor
|
||||
get(vertex_index_t,
|
||||
adjacency_matrix<D, VP, EP, GP, A>&,
|
||||
typename adjacency_matrix<D, VP, EP, GP, A>::vertex_descriptor v) {
|
||||
return v;
|
||||
}
|
||||
|
||||
template <typename Property, typename D, typename VP, typename EP,
|
||||
typename GP, typename A, typename Key>
|
||||
inline
|
||||
typename property_traits<
|
||||
typename property_map<adjacency_matrix<D,VP,EP,GP,A>, Property>::const_type
|
||||
>::value_type
|
||||
get(Property p, const adjacency_matrix<D,VP,EP,GP,A>& g,
|
||||
const Key& key)
|
||||
{
|
||||
return get(get(p, g), key);
|
||||
template <typename D, typename VP, typename EP, typename GP, typename A>
|
||||
typename property_map<adjacency_matrix<D, VP, EP, GP, A>, vertex_index_t>::const_type
|
||||
get(vertex_index_t, const adjacency_matrix<D, VP, EP, GP, A>&) {
|
||||
return typename property_map<adjacency_matrix<D, VP, EP, GP, A>, vertex_index_t>::const_type();
|
||||
}
|
||||
|
||||
template <typename Property, typename D, typename VP, typename EP,
|
||||
typename GP, typename A, typename Key, typename Value>
|
||||
inline void
|
||||
put(Property p, adjacency_matrix<D,VP,EP,GP,A>& g,
|
||||
const Key& key, const Value& value)
|
||||
{
|
||||
typedef adjacency_matrix<D,VP,EP,GP,A> Graph;
|
||||
typedef typename boost::property_map<Graph, Property>::type Map;
|
||||
Map pmap = get(p, g);
|
||||
put(pmap, key, value);
|
||||
template <typename D, typename VP, typename EP, typename GP, typename A>
|
||||
typename adjacency_matrix<D, VP, EP, GP, A>::vertex_descriptor
|
||||
get(vertex_index_t,
|
||||
const adjacency_matrix<D, VP, EP, GP, A>&,
|
||||
typename adjacency_matrix<D, VP, EP, GP, A>::vertex_descriptor v) {
|
||||
return v;
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
@@ -1298,63 +1229,10 @@ namespace boost {
|
||||
return n;
|
||||
}
|
||||
|
||||
// Support for bundled properties
|
||||
#ifndef BOOST_GRAPH_NO_BUNDLED_PROPERTIES
|
||||
template <typename Directed, typename VertexProperty, typename EdgeProperty, typename GraphProperty,
|
||||
typename Allocator, typename T, typename Bundle>
|
||||
inline
|
||||
typename property_map<adjacency_matrix<Directed, VertexProperty, EdgeProperty, GraphProperty, Allocator>,
|
||||
T Bundle::*>::type
|
||||
get(T Bundle::* p, adjacency_matrix<Directed, VertexProperty, EdgeProperty, GraphProperty, Allocator>& g)
|
||||
{
|
||||
typedef typename property_map<adjacency_matrix<Directed, VertexProperty, EdgeProperty, GraphProperty, Allocator>,
|
||||
T Bundle::*>::type
|
||||
result_type;
|
||||
return result_type(&g, p);
|
||||
}
|
||||
|
||||
template <typename Directed, typename VertexProperty, typename EdgeProperty, typename GraphProperty,
|
||||
typename Allocator, typename T, typename Bundle>
|
||||
inline
|
||||
typename property_map<adjacency_matrix<Directed, VertexProperty, EdgeProperty, GraphProperty, Allocator>,
|
||||
T Bundle::*>::const_type
|
||||
get(T Bundle::* p, adjacency_matrix<Directed, VertexProperty, EdgeProperty, GraphProperty, Allocator> const & g)
|
||||
{
|
||||
typedef typename property_map<adjacency_matrix<Directed, VertexProperty, EdgeProperty, GraphProperty, Allocator>,
|
||||
T Bundle::*>::const_type
|
||||
result_type;
|
||||
return result_type(&g, p);
|
||||
}
|
||||
|
||||
template <typename Directed, typename VertexProperty, typename EdgeProperty, typename GraphProperty,
|
||||
typename Allocator, typename T, typename Bundle, typename Key>
|
||||
inline T
|
||||
get(T Bundle::* p, adjacency_matrix<Directed, VertexProperty, EdgeProperty, GraphProperty, Allocator> const & g,
|
||||
const Key& key)
|
||||
{
|
||||
return get(get(p, g), key);
|
||||
}
|
||||
|
||||
template <typename Directed, typename VertexProperty, typename EdgeProperty, typename GraphProperty,
|
||||
typename Allocator, typename T, typename Bundle, typename Key>
|
||||
inline void
|
||||
put(T Bundle::* p, adjacency_matrix<Directed, VertexProperty, EdgeProperty, GraphProperty, Allocator>& g,
|
||||
const Key& key, const T& value)
|
||||
{
|
||||
put(get(p, g), key, value);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define ADJMAT_PARAMS \
|
||||
typename D, typename VP, typename EP, typename GP, typename A
|
||||
#define ADJMAT adjacency_matrix<D,VP,EP,GP,A>
|
||||
template <ADJMAT_PARAMS>
|
||||
struct graph_mutability_traits<ADJMAT> {
|
||||
typedef mutable_edge_property_graph_tag category;
|
||||
template <typename D, typename VP, typename EP, typename GP, typename A>
|
||||
struct graph_mutability_traits<adjacency_matrix<D, VP, EP, GP, A> > {
|
||||
typedef mutable_edge_property_graph_tag category;
|
||||
};
|
||||
#undef ADJMAT_PARAMS
|
||||
#undef ADJMAT
|
||||
|
||||
|
||||
} // namespace boost
|
||||
|
||||
@@ -171,7 +171,7 @@ namespace boost {
|
||||
bool
|
||||
bellman_dispatch2
|
||||
(VertexAndEdgeListGraph& g,
|
||||
detail::error_property_not_found,
|
||||
param_not_found,
|
||||
Size N, WeightMap weight, PredecessorMap pred, DistanceMap distance,
|
||||
const bgl_named_params<P, T, R>& params)
|
||||
{
|
||||
|
||||
@@ -498,14 +498,14 @@ namespace detail { namespace graph {
|
||||
};
|
||||
|
||||
template<>
|
||||
struct brandes_betweenness_centrality_dispatch1<error_property_not_found>
|
||||
struct brandes_betweenness_centrality_dispatch1<param_not_found>
|
||||
{
|
||||
template<typename Graph, typename CentralityMap,
|
||||
typename EdgeCentralityMap, typename VertexIndexMap>
|
||||
static void
|
||||
run(const Graph& g, CentralityMap centrality,
|
||||
EdgeCentralityMap edge_centrality_map, VertexIndexMap vertex_index,
|
||||
error_property_not_found)
|
||||
param_not_found)
|
||||
{
|
||||
brandes_betweenness_centrality_dispatch2(g, centrality, edge_centrality_map,
|
||||
vertex_index);
|
||||
@@ -532,7 +532,7 @@ brandes_betweenness_centrality(const Graph& g,
|
||||
{
|
||||
typedef bgl_named_params<Param,Tag,Rest> named_params;
|
||||
|
||||
typedef typename property_value<named_params, edge_weight_t>::type ew;
|
||||
typedef typename get_param_type<edge_weight_t, named_params>::type ew;
|
||||
detail::graph::brandes_betweenness_centrality_dispatch1<ew>::run(
|
||||
g,
|
||||
choose_param(get_param(params, vertex_centrality),
|
||||
|
||||
@@ -209,7 +209,7 @@ namespace boost
|
||||
};
|
||||
|
||||
template <>
|
||||
struct bicomp_dispatch3<error_property_not_found>
|
||||
struct bicomp_dispatch3<param_not_found>
|
||||
{
|
||||
template<typename Graph, typename ComponentMap, typename OutputIterator,
|
||||
typename VertexIndexMap, typename DiscoverTimeMap,
|
||||
@@ -218,7 +218,7 @@ namespace boost
|
||||
ComponentMap comp, OutputIterator out, VertexIndexMap index_map,
|
||||
DiscoverTimeMap dtm, LowPointMap lowpt,
|
||||
const bgl_named_params<P, T, R>& params,
|
||||
error_property_not_found)
|
||||
param_not_found)
|
||||
{
|
||||
typedef typename graph_traits<Graph>::vertex_descriptor vertex_t;
|
||||
std::vector<vertex_t> pred(num_vertices(g));
|
||||
@@ -243,7 +243,7 @@ namespace boost
|
||||
DiscoverTimeMap dtm, const bgl_named_params<P, T, R>& params,
|
||||
LowPointMap lowpt)
|
||||
{
|
||||
typedef typename property_value< bgl_named_params<P,T,R>,
|
||||
typedef typename get_param_type< bgl_named_params<P,T,R>,
|
||||
vertex_predecessor_t>::type dispatch_type;
|
||||
|
||||
return bicomp_dispatch3<dispatch_type>::apply
|
||||
@@ -254,7 +254,7 @@ namespace boost
|
||||
|
||||
|
||||
template <>
|
||||
struct bicomp_dispatch2<error_property_not_found>
|
||||
struct bicomp_dispatch2<param_not_found>
|
||||
{
|
||||
template<typename Graph, typename ComponentMap, typename OutputIterator,
|
||||
typename VertexIndexMap, typename DiscoverTimeMap,
|
||||
@@ -262,14 +262,14 @@ namespace boost
|
||||
static std::pair<std::size_t, OutputIterator> apply (const Graph& g,
|
||||
ComponentMap comp, OutputIterator out, VertexIndexMap index_map,
|
||||
DiscoverTimeMap dtm, const bgl_named_params<P, T, R>& params,
|
||||
error_property_not_found)
|
||||
param_not_found)
|
||||
{
|
||||
typedef typename graph_traits<Graph>::vertices_size_type
|
||||
vertices_size_type;
|
||||
std::vector<vertices_size_type> lowpt(num_vertices(g));
|
||||
vertices_size_type vst(0);
|
||||
|
||||
typedef typename property_value< bgl_named_params<P,T,R>,
|
||||
typedef typename get_param_type< bgl_named_params<P,T,R>,
|
||||
vertex_predecessor_t>::type dispatch_type;
|
||||
|
||||
return bicomp_dispatch3<dispatch_type>::apply
|
||||
@@ -288,7 +288,7 @@ namespace boost
|
||||
ComponentMap comp, OutputIterator out, VertexIndexMap index_map,
|
||||
const bgl_named_params<P, T, R>& params, DiscoverTimeMap dtm)
|
||||
{
|
||||
typedef typename property_value< bgl_named_params<P,T,R>,
|
||||
typedef typename get_param_type< bgl_named_params<P,T,R>,
|
||||
vertex_lowpoint_t>::type dispatch_type;
|
||||
|
||||
return bicomp_dispatch2<dispatch_type>::apply
|
||||
@@ -298,20 +298,20 @@ namespace boost
|
||||
};
|
||||
|
||||
template <>
|
||||
struct bicomp_dispatch1<error_property_not_found>
|
||||
struct bicomp_dispatch1<param_not_found>
|
||||
{
|
||||
template<typename Graph, typename ComponentMap, typename OutputIterator,
|
||||
typename VertexIndexMap, class P, class T, class R>
|
||||
static std::pair<std::size_t, OutputIterator> apply(const Graph& g,
|
||||
ComponentMap comp, OutputIterator out, VertexIndexMap index_map,
|
||||
const bgl_named_params<P, T, R>& params, error_property_not_found)
|
||||
const bgl_named_params<P, T, R>& params, param_not_found)
|
||||
{
|
||||
typedef typename graph_traits<Graph>::vertices_size_type
|
||||
vertices_size_type;
|
||||
std::vector<vertices_size_type> discover_time(num_vertices(g));
|
||||
vertices_size_type vst(0);
|
||||
|
||||
typedef typename property_value< bgl_named_params<P,T,R>,
|
||||
typedef typename get_param_type< bgl_named_params<P,T,R>,
|
||||
vertex_lowpoint_t>::type dispatch_type;
|
||||
|
||||
return bicomp_dispatch2<dispatch_type>::apply
|
||||
@@ -329,14 +329,14 @@ namespace boost
|
||||
biconnected_components(const Graph& g, ComponentMap comp,
|
||||
OutputIterator out, DiscoverTimeMap dtm, LowPointMap lowpt)
|
||||
{
|
||||
typedef detail::error_property_not_found dispatch_type;
|
||||
typedef param_not_found dispatch_type;
|
||||
|
||||
return detail::bicomp_dispatch3<dispatch_type>::apply
|
||||
(g, comp, out,
|
||||
get(vertex_index, g),
|
||||
dtm, lowpt,
|
||||
bgl_named_params<int, buffer_param_t>(0),
|
||||
detail::error_property_not_found());
|
||||
param_not_found());
|
||||
}
|
||||
|
||||
template <typename Graph, typename ComponentMap, typename OutputIterator,
|
||||
@@ -345,7 +345,7 @@ namespace boost
|
||||
biconnected_components(const Graph& g, ComponentMap comp, OutputIterator out,
|
||||
const bgl_named_params<P, T, R>& params)
|
||||
{
|
||||
typedef typename property_value< bgl_named_params<P,T,R>,
|
||||
typedef typename get_param_type< bgl_named_params<P,T,R>,
|
||||
vertex_discover_time_t>::type dispatch_type;
|
||||
|
||||
return detail::bicomp_dispatch1<dispatch_type>::apply(g, comp, out,
|
||||
|
||||
@@ -53,11 +53,12 @@ namespace boost {
|
||||
};
|
||||
|
||||
|
||||
// Multiple-source version
|
||||
template <class IncidenceGraph, class Buffer, class BFSVisitor,
|
||||
class ColorMap>
|
||||
class ColorMap, class SourceIterator>
|
||||
void breadth_first_visit
|
||||
(const IncidenceGraph& g,
|
||||
typename graph_traits<IncidenceGraph>::vertex_descriptor s,
|
||||
SourceIterator sources_begin, SourceIterator sources_end,
|
||||
Buffer& Q, BFSVisitor vis, ColorMap color)
|
||||
{
|
||||
BOOST_CONCEPT_ASSERT(( IncidenceGraphConcept<IncidenceGraph> ));
|
||||
@@ -70,8 +71,11 @@ namespace boost {
|
||||
typedef color_traits<ColorValue> Color;
|
||||
typename GTraits::out_edge_iterator ei, ei_end;
|
||||
|
||||
put(color, s, Color::gray()); vis.discover_vertex(s, g);
|
||||
Q.push(s);
|
||||
for (; sources_begin != sources_end; ++sources_begin) {
|
||||
Vertex s = *sources_begin;
|
||||
put(color, s, Color::gray()); vis.discover_vertex(s, g);
|
||||
Q.push(s);
|
||||
}
|
||||
while (! Q.empty()) {
|
||||
Vertex u = Q.top(); Q.pop(); vis.examine_vertex(u, g);
|
||||
for (boost::tie(ei, ei_end) = out_edges(u, g); ei != ei_end; ++ei) {
|
||||
@@ -89,12 +93,25 @@ namespace boost {
|
||||
} // end while
|
||||
} // breadth_first_visit
|
||||
|
||||
// Single-source version
|
||||
template <class IncidenceGraph, class Buffer, class BFSVisitor,
|
||||
class ColorMap>
|
||||
void breadth_first_visit
|
||||
(const IncidenceGraph& g,
|
||||
typename graph_traits<IncidenceGraph>::vertex_descriptor s,
|
||||
Buffer& Q, BFSVisitor vis, ColorMap color)
|
||||
{
|
||||
typename graph_traits<IncidenceGraph>::vertex_descriptor sources[1] = {s};
|
||||
breadth_first_visit(g, sources, sources + 1, Q, vis, color);
|
||||
}
|
||||
|
||||
template <class VertexListGraph, class Buffer, class BFSVisitor,
|
||||
|
||||
template <class VertexListGraph, class SourceIterator,
|
||||
class Buffer, class BFSVisitor,
|
||||
class ColorMap>
|
||||
void breadth_first_search
|
||||
(const VertexListGraph& g,
|
||||
typename graph_traits<VertexListGraph>::vertex_descriptor s,
|
||||
SourceIterator sources_begin, SourceIterator sources_end,
|
||||
Buffer& Q, BFSVisitor vis, ColorMap color)
|
||||
{
|
||||
// Initialization
|
||||
@@ -105,7 +122,18 @@ namespace boost {
|
||||
vis.initialize_vertex(*i, g);
|
||||
put(color, *i, Color::white());
|
||||
}
|
||||
breadth_first_visit(g, s, Q, vis, color);
|
||||
breadth_first_visit(g, sources_begin, sources_end, Q, vis, color);
|
||||
}
|
||||
|
||||
template <class VertexListGraph, class Buffer, class BFSVisitor,
|
||||
class ColorMap>
|
||||
void breadth_first_search
|
||||
(const VertexListGraph& g,
|
||||
typename graph_traits<VertexListGraph>::vertex_descriptor s,
|
||||
Buffer& Q, BFSVisitor vis, ColorMap color)
|
||||
{
|
||||
typename graph_traits<VertexListGraph>::vertex_descriptor sources[1] = {s};
|
||||
breadth_first_search(g, sources, sources + 1, Q, vis, color);
|
||||
}
|
||||
|
||||
namespace graph { struct bfs_visitor_event_not_overridden {}; }
|
||||
@@ -270,13 +298,13 @@ namespace boost {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct bfs_dispatch<detail::error_property_not_found> {
|
||||
struct bfs_dispatch<param_not_found> {
|
||||
template <class VertexListGraph, class P, class T, class R>
|
||||
static void apply
|
||||
(VertexListGraph& g,
|
||||
typename graph_traits<VertexListGraph>::vertex_descriptor s,
|
||||
const bgl_named_params<P, T, R>& params,
|
||||
detail::error_property_not_found)
|
||||
param_not_found)
|
||||
{
|
||||
null_visitor null_vis;
|
||||
|
||||
@@ -307,8 +335,7 @@ namespace boost {
|
||||
// graph is not really const since we may write to property maps
|
||||
// of the graph.
|
||||
VertexListGraph& ng = const_cast<VertexListGraph&>(g);
|
||||
typedef typename property_value< bgl_named_params<P,T,R>,
|
||||
vertex_color_t>::type C;
|
||||
typedef typename get_param_type< vertex_color_t, bgl_named_params<P,T,R> >::type C;
|
||||
detail::bfs_dispatch<C>::apply(ng, s, params,
|
||||
get_param(params, vertex_color));
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/functional/hash.hpp>
|
||||
#include <boost/utility.hpp>
|
||||
#include <boost/property_map/transform_value_property_map.hpp>
|
||||
|
||||
#ifdef BOOST_GRAPH_NO_BUNDLED_PROPERTIES
|
||||
# error The Compressed Sparse Row graph only supports bundled properties.
|
||||
@@ -195,8 +196,8 @@ class compressed_sparse_row_graph<directedS, VertexProperty, EdgeProperty, Graph
|
||||
|
||||
public:
|
||||
// For Property Graph
|
||||
typedef typename graph_detail::graph_prop<GraphProperty>::property graph_property_type;
|
||||
typedef typename graph_detail::graph_prop<GraphProperty>::bundle graph_bundled;
|
||||
typedef GraphProperty graph_property_type;
|
||||
typedef typename lookup_one_property<GraphProperty, graph_bundle_t>::type graph_bundled;
|
||||
|
||||
typedef detail::compressed_sparse_row_structure<EdgeProperty, Vertex, EdgeIndex> forward_type;
|
||||
|
||||
@@ -746,8 +747,8 @@ class compressed_sparse_row_graph<bidirectionalS, VertexProperty, EdgeProperty,
|
||||
|
||||
public:
|
||||
// For Property Graph
|
||||
typedef typename graph_detail::graph_prop<GraphProperty>::property graph_property_type;
|
||||
typedef typename graph_detail::graph_prop<GraphProperty>::bundle graph_bundled;
|
||||
typedef GraphProperty graph_property_type;
|
||||
typedef typename lookup_one_property<GraphProperty, graph_bundle_t>::type graph_bundled;
|
||||
// typedef GraphProperty graph_property_type;
|
||||
|
||||
typedef detail::compressed_sparse_row_structure<EdgeProperty, Vertex, EdgeIndex> forward_type;
|
||||
@@ -1404,6 +1405,61 @@ get_property(const BOOST_CSR_GRAPH_TYPE& g, Tag)
|
||||
return get_property_value(g.m_property, Tag());
|
||||
}
|
||||
|
||||
template <BOOST_CSR_GRAPH_TEMPLATE_PARMS, typename Tag>
|
||||
struct property_map<BOOST_CSR_GRAPH_TYPE, Tag> {
|
||||
typedef typename detail::property_kind_from_graph<BOOST_CSR_GRAPH_TYPE, Tag>::type kind;
|
||||
typedef typename boost::mpl::if_<
|
||||
boost::is_same<kind, vertex_property_tag>,
|
||||
vertex_all_t,
|
||||
typename boost::mpl::if_<
|
||||
boost::is_same<kind, edge_property_tag>,
|
||||
edge_all_t,
|
||||
graph_all_t>::type>::type all_tag;
|
||||
typedef typename property_traits<typename property_map<BOOST_CSR_GRAPH_TYPE, all_tag>::type>::key_type key_type;
|
||||
typedef typename property_traits<typename property_map<BOOST_CSR_GRAPH_TYPE, all_tag>::type>::value_type plist_type;
|
||||
typedef transform_value_property_map<detail::lookup_one_property_f<plist_type, Tag>, typename property_map<BOOST_CSR_GRAPH_TYPE, all_tag>::type> type;
|
||||
typedef transform_value_property_map<detail::lookup_one_property_f<const plist_type, Tag>, typename property_map<BOOST_CSR_GRAPH_TYPE, all_tag>::const_type> const_type;
|
||||
};
|
||||
|
||||
template <BOOST_CSR_GRAPH_TEMPLATE_PARMS, typename Tag>
|
||||
typename property_map<BOOST_CSR_GRAPH_TYPE, Tag>::type
|
||||
get(Tag tag, BOOST_CSR_GRAPH_TYPE& g) {
|
||||
return typename property_map<BOOST_CSR_GRAPH_TYPE, Tag>::type(tag, get(typename property_map<BOOST_CSR_GRAPH_TYPE, Tag>::all_tag(), g));
|
||||
}
|
||||
|
||||
template <BOOST_CSR_GRAPH_TEMPLATE_PARMS, typename Tag>
|
||||
typename property_map<BOOST_CSR_GRAPH_TYPE, Tag>::const_type
|
||||
get(Tag tag, const BOOST_CSR_GRAPH_TYPE& g) {
|
||||
return typename property_map<BOOST_CSR_GRAPH_TYPE, Tag>::const_type(tag, get(typename property_map<BOOST_CSR_GRAPH_TYPE, Tag>::all_tag(), g));
|
||||
}
|
||||
|
||||
template <BOOST_CSR_GRAPH_TEMPLATE_PARMS, typename Tag>
|
||||
typename property_traits<typename property_map<BOOST_CSR_GRAPH_TYPE, Tag>::type>::reference
|
||||
get(Tag tag, BOOST_CSR_GRAPH_TYPE& g, typename property_map<BOOST_CSR_GRAPH_TYPE, Tag>::key_type k) {
|
||||
typedef typename property_map<BOOST_CSR_GRAPH_TYPE, Tag>::all_tag all_tag;
|
||||
typedef typename property_map<BOOST_CSR_GRAPH_TYPE, all_tag>::type outer_pm;
|
||||
return lookup_one_property<typename property_traits<outer_pm>::value_type, Tag>::lookup(get(all_tag(), g, k), tag);
|
||||
}
|
||||
|
||||
template <BOOST_CSR_GRAPH_TEMPLATE_PARMS, typename Tag>
|
||||
typename property_traits<typename property_map<BOOST_CSR_GRAPH_TYPE, Tag>::const_type>::reference
|
||||
get(Tag tag, const BOOST_CSR_GRAPH_TYPE& g, typename property_map<BOOST_CSR_GRAPH_TYPE, Tag>::key_type k) {
|
||||
typedef typename property_map<BOOST_CSR_GRAPH_TYPE, Tag>::all_tag all_tag;
|
||||
typedef typename property_map<BOOST_CSR_GRAPH_TYPE, all_tag>::const_type outer_pm;
|
||||
return lookup_one_property<const typename property_traits<outer_pm>::value_type, Tag>::lookup(get(all_tag(), g, k), tag);
|
||||
}
|
||||
|
||||
template <BOOST_CSR_GRAPH_TEMPLATE_PARMS, typename Tag>
|
||||
void
|
||||
put(Tag tag,
|
||||
BOOST_CSR_GRAPH_TYPE& g,
|
||||
typename property_map<BOOST_CSR_GRAPH_TYPE, Tag>::key_type k,
|
||||
typename lookup_one_property<typename property_map<BOOST_CSR_GRAPH_TYPE, Tag>::plist_type, Tag>::type val) {
|
||||
typedef typename property_map<BOOST_CSR_GRAPH_TYPE, Tag>::all_tag all_tag;
|
||||
typedef typename property_map<BOOST_CSR_GRAPH_TYPE, all_tag>::type outer_pm;
|
||||
lookup_one_property<typename property_map<BOOST_CSR_GRAPH_TYPE, Tag>::plist_type, Tag>::lookup(get(all_tag(), g, k), tag) = val;
|
||||
}
|
||||
|
||||
template<BOOST_CSR_GRAPH_TEMPLATE_PARMS>
|
||||
struct property_map<BOOST_CSR_GRAPH_TYPE, vertex_index_t>
|
||||
{
|
||||
@@ -1419,14 +1475,14 @@ struct property_map<BOOST_CSR_GRAPH_TYPE, edge_index_t>
|
||||
};
|
||||
|
||||
template<BOOST_CSR_GRAPH_TEMPLATE_PARMS>
|
||||
struct property_map<BOOST_CSR_GRAPH_TYPE, vertex_bundle_t>
|
||||
struct property_map<BOOST_CSR_GRAPH_TYPE, vertex_all_t>
|
||||
{
|
||||
typedef typename BOOST_CSR_GRAPH_TYPE::inherited_vertex_properties::vertex_map_type type;
|
||||
typedef typename BOOST_CSR_GRAPH_TYPE::inherited_vertex_properties::const_vertex_map_type const_type;
|
||||
};
|
||||
|
||||
template<BOOST_CSR_GRAPH_TEMPLATE_PARMS>
|
||||
struct property_map<BOOST_CSR_GRAPH_TYPE, edge_bundle_t>
|
||||
struct property_map<BOOST_CSR_GRAPH_TYPE, edge_all_t>
|
||||
{
|
||||
typedef typename BOOST_CSR_GRAPH_TYPE::forward_type::inherited_edge_properties::edge_map_type type;
|
||||
typedef typename BOOST_CSR_GRAPH_TYPE::forward_type::inherited_edge_properties::const_edge_map_type const_type;
|
||||
@@ -1447,6 +1503,21 @@ get(vertex_index_t,
|
||||
return v;
|
||||
}
|
||||
|
||||
template<BOOST_CSR_GRAPH_TEMPLATE_PARMS>
|
||||
inline typed_identity_property_map<Vertex>
|
||||
get(vertex_index_t, BOOST_CSR_GRAPH_TYPE&)
|
||||
{
|
||||
return typed_identity_property_map<Vertex>();
|
||||
}
|
||||
|
||||
template<BOOST_CSR_GRAPH_TEMPLATE_PARMS>
|
||||
inline Vertex
|
||||
get(vertex_index_t,
|
||||
BOOST_CSR_GRAPH_TYPE&, Vertex v)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
|
||||
template<BOOST_CSR_GRAPH_TEMPLATE_PARMS>
|
||||
inline typename property_map<BOOST_CSR_GRAPH_TYPE, edge_index_t>::const_type
|
||||
get(edge_index_t, const BOOST_CSR_GRAPH_TYPE&)
|
||||
@@ -1465,125 +1536,102 @@ get(edge_index_t, const BOOST_CSR_GRAPH_TYPE&,
|
||||
}
|
||||
|
||||
template<BOOST_CSR_GRAPH_TEMPLATE_PARMS>
|
||||
inline typename property_map<BOOST_CSR_GRAPH_TYPE, vertex_bundle_t>::type
|
||||
get(vertex_bundle_t, BOOST_CSR_GRAPH_TYPE& g)
|
||||
inline typename property_map<BOOST_CSR_GRAPH_TYPE, edge_index_t>::const_type
|
||||
get(edge_index_t, BOOST_CSR_GRAPH_TYPE&)
|
||||
{
|
||||
typedef typename property_map<BOOST_CSR_GRAPH_TYPE, edge_index_t>::const_type
|
||||
result_type;
|
||||
return result_type();
|
||||
}
|
||||
|
||||
template<BOOST_CSR_GRAPH_TEMPLATE_PARMS>
|
||||
inline EdgeIndex
|
||||
get(edge_index_t, BOOST_CSR_GRAPH_TYPE&,
|
||||
typename BOOST_CSR_GRAPH_TYPE::edge_descriptor e)
|
||||
{
|
||||
return e.idx;
|
||||
}
|
||||
|
||||
template<BOOST_CSR_GRAPH_TEMPLATE_PARMS>
|
||||
inline typename property_map<BOOST_CSR_GRAPH_TYPE, vertex_all_t>::type
|
||||
get(vertex_all_t, BOOST_CSR_GRAPH_TYPE& g)
|
||||
{
|
||||
return g.get_vertex_bundle(get(vertex_index, g));
|
||||
}
|
||||
|
||||
template<BOOST_CSR_GRAPH_TEMPLATE_PARMS>
|
||||
inline typename property_map<BOOST_CSR_GRAPH_TYPE, vertex_bundle_t>::const_type
|
||||
get(vertex_bundle_t, const BOOST_CSR_GRAPH_TYPE& g)
|
||||
inline typename property_map<BOOST_CSR_GRAPH_TYPE, vertex_all_t>::const_type
|
||||
get(vertex_all_t, const BOOST_CSR_GRAPH_TYPE& g)
|
||||
{
|
||||
return g.get_vertex_bundle(get(vertex_index, g));
|
||||
}
|
||||
|
||||
template<BOOST_CSR_GRAPH_TEMPLATE_PARMS>
|
||||
inline VertexProperty&
|
||||
get(vertex_bundle_t,
|
||||
get(vertex_all_t,
|
||||
BOOST_CSR_GRAPH_TYPE& g, Vertex v)
|
||||
{
|
||||
return get(vertex_bundle, g)[v];
|
||||
return get(vertex_all, g)[v];
|
||||
}
|
||||
|
||||
template<BOOST_CSR_GRAPH_TEMPLATE_PARMS>
|
||||
inline const VertexProperty&
|
||||
get(vertex_bundle_t,
|
||||
get(vertex_all_t,
|
||||
const BOOST_CSR_GRAPH_TYPE& g, Vertex v)
|
||||
{
|
||||
return get(vertex_bundle, g)[v];
|
||||
return get(vertex_all, g)[v];
|
||||
}
|
||||
|
||||
template<BOOST_CSR_GRAPH_TEMPLATE_PARMS>
|
||||
inline void
|
||||
put(vertex_bundle_t,
|
||||
put(vertex_all_t,
|
||||
BOOST_CSR_GRAPH_TYPE& g,
|
||||
Vertex v,
|
||||
const VertexProperty& val)
|
||||
{
|
||||
put(get(vertex_bundle, g), v, val);
|
||||
put(get(vertex_all, g), v, val);
|
||||
}
|
||||
|
||||
template<BOOST_CSR_GRAPH_TEMPLATE_PARMS>
|
||||
inline typename property_map<BOOST_CSR_GRAPH_TYPE, edge_bundle_t>::type
|
||||
get(edge_bundle_t, BOOST_CSR_GRAPH_TYPE& g)
|
||||
inline typename property_map<BOOST_CSR_GRAPH_TYPE, edge_all_t>::type
|
||||
get(edge_all_t, BOOST_CSR_GRAPH_TYPE& g)
|
||||
{
|
||||
return g.m_forward.get_edge_bundle(get(edge_index, g));
|
||||
}
|
||||
|
||||
template<BOOST_CSR_GRAPH_TEMPLATE_PARMS>
|
||||
inline typename property_map<BOOST_CSR_GRAPH_TYPE, edge_bundle_t>::const_type
|
||||
get(edge_bundle_t, const BOOST_CSR_GRAPH_TYPE& g)
|
||||
inline typename property_map<BOOST_CSR_GRAPH_TYPE, edge_all_t>::const_type
|
||||
get(edge_all_t, const BOOST_CSR_GRAPH_TYPE& g)
|
||||
{
|
||||
return g.m_forward.get_edge_bundle(get(edge_index, g));
|
||||
}
|
||||
|
||||
template<BOOST_CSR_GRAPH_TEMPLATE_PARMS>
|
||||
inline EdgeProperty&
|
||||
get(edge_bundle_t,
|
||||
get(edge_all_t,
|
||||
BOOST_CSR_GRAPH_TYPE& g,
|
||||
const typename BOOST_CSR_GRAPH_TYPE::edge_descriptor& e)
|
||||
{
|
||||
return get(edge_bundle, g)[e];
|
||||
return get(edge_all, g)[e];
|
||||
}
|
||||
|
||||
template<BOOST_CSR_GRAPH_TEMPLATE_PARMS>
|
||||
inline const EdgeProperty&
|
||||
get(edge_bundle_t,
|
||||
get(edge_all_t,
|
||||
const BOOST_CSR_GRAPH_TYPE& g,
|
||||
const typename BOOST_CSR_GRAPH_TYPE::edge_descriptor& e)
|
||||
{
|
||||
return get(edge_bundle, g)[e];
|
||||
return get(edge_all, g)[e];
|
||||
}
|
||||
|
||||
template<BOOST_CSR_GRAPH_TEMPLATE_PARMS>
|
||||
inline void
|
||||
put(edge_bundle_t,
|
||||
put(edge_all_t,
|
||||
BOOST_CSR_GRAPH_TYPE& g,
|
||||
const typename BOOST_CSR_GRAPH_TYPE::edge_descriptor& e,
|
||||
const EdgeProperty& val)
|
||||
{
|
||||
put(get(edge_bundle, g), e, val);
|
||||
}
|
||||
|
||||
template<BOOST_CSR_GRAPH_TEMPLATE_PARMS, typename T, typename Bundle>
|
||||
inline
|
||||
typename property_map<BOOST_CSR_GRAPH_TYPE, T Bundle::*>::type
|
||||
get(T Bundle::* p, BOOST_CSR_GRAPH_TYPE& g)
|
||||
{
|
||||
typedef typename property_map<BOOST_CSR_GRAPH_TYPE,
|
||||
T Bundle::*>::type
|
||||
result_type;
|
||||
return result_type(&g, p);
|
||||
}
|
||||
|
||||
template<BOOST_CSR_GRAPH_TEMPLATE_PARMS, typename T, typename Bundle>
|
||||
inline
|
||||
typename property_map<BOOST_CSR_GRAPH_TYPE, T Bundle::*>::const_type
|
||||
get(T Bundle::* p, BOOST_CSR_GRAPH_TYPE const & g)
|
||||
{
|
||||
typedef typename property_map<BOOST_CSR_GRAPH_TYPE,
|
||||
T Bundle::*>::const_type
|
||||
result_type;
|
||||
return result_type(&g, p);
|
||||
}
|
||||
|
||||
template<BOOST_CSR_GRAPH_TEMPLATE_PARMS, typename T, typename Bundle,
|
||||
typename Key>
|
||||
inline T
|
||||
get(T Bundle::* p, BOOST_CSR_GRAPH_TYPE const & g,
|
||||
const Key& key)
|
||||
{
|
||||
return get(get(p, g), key);
|
||||
}
|
||||
|
||||
template<BOOST_CSR_GRAPH_TEMPLATE_PARMS, typename T, typename Bundle,
|
||||
typename Key>
|
||||
inline void
|
||||
put(T Bundle::* p, BOOST_CSR_GRAPH_TYPE& g,
|
||||
const Key& key, const T& value)
|
||||
{
|
||||
put(get(p, g), key, value);
|
||||
put(get(edge_all, g), e, val);
|
||||
}
|
||||
|
||||
#undef BOOST_CSR_GRAPH_TYPE
|
||||
|
||||
@@ -280,7 +280,7 @@ namespace boost {
|
||||
typedef choose_copier_parameter type;
|
||||
};
|
||||
template <>
|
||||
struct choose_edge_copy<detail::error_property_not_found> {
|
||||
struct choose_edge_copy<param_not_found> {
|
||||
typedef choose_default_edge_copier type;
|
||||
};
|
||||
template <class Param, class G1, class G2>
|
||||
@@ -314,7 +314,7 @@ namespace boost {
|
||||
typedef choose_copier_parameter type;
|
||||
};
|
||||
template <>
|
||||
struct choose_vertex_copy<detail::error_property_not_found> {
|
||||
struct choose_vertex_copy<param_not_found> {
|
||||
typedef choose_default_vertex_copier type;
|
||||
};
|
||||
template <class Param, class G1, class G2>
|
||||
|
||||
@@ -37,11 +37,6 @@
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
// Symbol truncation problems with MSVC, trying to shorten names.
|
||||
#define stored_edge se_
|
||||
#define stored_edge_property sep_
|
||||
#define stored_edge_iter sei_
|
||||
|
||||
/*
|
||||
Outline for this file:
|
||||
|
||||
@@ -67,11 +62,6 @@
|
||||
*/
|
||||
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
// Stay out of the way of the concept checking class
|
||||
# define Graph Graph_
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
|
||||
namespace detail {
|
||||
@@ -1511,10 +1501,16 @@ namespace boost {
|
||||
typedef typename Config::edges_size_type edges_size_type;
|
||||
typedef typename Config::degree_size_type degree_size_type;
|
||||
typedef typename Config::StoredEdge StoredEdge;
|
||||
typedef typename Config::vertex_property_type vertex_property_type;
|
||||
typedef typename Config::edge_property_type edge_property_type;
|
||||
typedef typename Config::graph_property_type graph_property_type;
|
||||
|
||||
typedef typename Config::global_edgelist_selector
|
||||
global_edgelist_selector;
|
||||
|
||||
typedef typename lookup_one_property<vertex_property_type, vertex_bundle_t>::type vertex_bundled;
|
||||
typedef typename lookup_one_property<edge_property_type, edge_bundle_t>::type edge_bundled;
|
||||
typedef typename lookup_one_property<graph_property_type, graph_bundle_t>::type graph_bundled;
|
||||
};
|
||||
|
||||
template <class Config, class Base>
|
||||
@@ -1645,43 +1641,43 @@ namespace boost {
|
||||
inline
|
||||
typename boost::property_map<typename Config::graph_type,
|
||||
Property>::type
|
||||
get_dispatch(adj_list_helper<Config,Base>&, Property,
|
||||
get_dispatch(adj_list_helper<Config,Base>&, Property p,
|
||||
boost::edge_property_tag) {
|
||||
typedef typename Config::graph_type Graph;
|
||||
typedef typename boost::property_map<Graph, Property>::type PA;
|
||||
return PA();
|
||||
return PA(p);
|
||||
}
|
||||
template <class Config, class Base, class Property>
|
||||
inline
|
||||
typename boost::property_map<typename Config::graph_type,
|
||||
Property>::const_type
|
||||
get_dispatch(const adj_list_helper<Config,Base>&, Property,
|
||||
get_dispatch(const adj_list_helper<Config,Base>&, Property p,
|
||||
boost::edge_property_tag) {
|
||||
typedef typename Config::graph_type Graph;
|
||||
typedef typename boost::property_map<Graph, Property>::const_type PA;
|
||||
return PA();
|
||||
return PA(p);
|
||||
}
|
||||
|
||||
template <class Config, class Base, class Property>
|
||||
inline
|
||||
typename boost::property_map<typename Config::graph_type,
|
||||
Property>::type
|
||||
get_dispatch(adj_list_helper<Config,Base>& g, Property,
|
||||
get_dispatch(adj_list_helper<Config,Base>& g, Property p,
|
||||
boost::vertex_property_tag) {
|
||||
typedef typename Config::graph_type Graph;
|
||||
typedef typename boost::property_map<Graph, Property>::type PA;
|
||||
return PA(&static_cast<Graph&>(g));
|
||||
return PA(&static_cast<Graph&>(g), p);
|
||||
}
|
||||
template <class Config, class Base, class Property>
|
||||
inline
|
||||
typename boost::property_map<typename Config::graph_type,
|
||||
Property>::const_type
|
||||
get_dispatch(const adj_list_helper<Config, Base>& g, Property,
|
||||
get_dispatch(const adj_list_helper<Config, Base>& g, Property p,
|
||||
boost::vertex_property_tag) {
|
||||
typedef typename Config::graph_type Graph;
|
||||
typedef typename boost::property_map<Graph, Property>::const_type PA;
|
||||
const Graph& cg = static_cast<const Graph&>(g);
|
||||
return PA(&cg);
|
||||
return PA(&cg, p);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
@@ -1691,7 +1687,7 @@ namespace boost {
|
||||
inline
|
||||
typename boost::property_map<typename Config::graph_type, Property>::type
|
||||
get(Property p, adj_list_helper<Config, Base>& g) {
|
||||
typedef typename property_kind<Property>::type Kind;
|
||||
typedef typename detail::property_kind_from_graph<adj_list_helper<Config, Base>, Property>::type Kind;
|
||||
return detail::get_dispatch(g, p, Kind());
|
||||
}
|
||||
template <class Config, class Base, class Property>
|
||||
@@ -1699,7 +1695,7 @@ namespace boost {
|
||||
typename boost::property_map<typename Config::graph_type,
|
||||
Property>::const_type
|
||||
get(Property p, const adj_list_helper<Config, Base>& g) {
|
||||
typedef typename property_kind<Property>::type Kind;
|
||||
typedef typename detail::property_kind_from_graph<adj_list_helper<Config, Base>, Property>::type Kind;
|
||||
return detail::get_dispatch(g, p, Kind());
|
||||
}
|
||||
|
||||
@@ -2427,15 +2423,15 @@ namespace boost {
|
||||
typedef Reference reference;
|
||||
typedef typename Graph::vertex_descriptor key_type;
|
||||
typedef boost::lvalue_property_map_tag category;
|
||||
inline adj_list_vertex_property_map() { }
|
||||
inline adj_list_vertex_property_map(const Graph*) { }
|
||||
inline adj_list_vertex_property_map(const Graph* = 0, Tag tag = Tag()): m_tag(tag) { }
|
||||
inline Reference operator[](key_type v) const {
|
||||
StoredVertex* sv = (StoredVertex*)v;
|
||||
return get_property_value(sv->m_property, Tag());
|
||||
return get_property_value(sv->m_property, m_tag);
|
||||
}
|
||||
inline Reference operator()(key_type v) const {
|
||||
return this->operator[](v);
|
||||
}
|
||||
Tag m_tag;
|
||||
};
|
||||
|
||||
template <class Graph, class Property, class PropRef>
|
||||
@@ -2449,8 +2445,7 @@ namespace boost {
|
||||
typedef PropRef reference;
|
||||
typedef typename Graph::vertex_descriptor key_type;
|
||||
typedef boost::lvalue_property_map_tag category;
|
||||
inline adj_list_vertex_all_properties_map() { }
|
||||
inline adj_list_vertex_all_properties_map(const Graph*) { }
|
||||
inline adj_list_vertex_all_properties_map(const Graph* = 0, vertex_all_t = vertex_all_t()) { }
|
||||
inline PropRef operator[](key_type v) const {
|
||||
StoredVertex* sv = (StoredVertex*)v;
|
||||
return sv->m_property;
|
||||
@@ -2473,15 +2468,15 @@ namespace boost {
|
||||
typedef Reference reference;
|
||||
typedef typename boost::graph_traits<Graph>::vertex_descriptor key_type;
|
||||
typedef boost::lvalue_property_map_tag category;
|
||||
vec_adj_list_vertex_property_map() { }
|
||||
vec_adj_list_vertex_property_map(GraphPtr g) : m_g(g) { }
|
||||
vec_adj_list_vertex_property_map(GraphPtr g = 0, Tag tag = Tag()) : m_g(g), m_tag(tag) { }
|
||||
inline Reference operator[](key_type v) const {
|
||||
return get_property_value(m_g->m_vertices[v].m_property, Tag());
|
||||
return get_property_value(m_g->m_vertices[v].m_property, m_tag);
|
||||
}
|
||||
inline Reference operator()(key_type v) const {
|
||||
return this->operator[](v);
|
||||
}
|
||||
GraphPtr m_g;
|
||||
Tag m_tag;
|
||||
};
|
||||
|
||||
template <class Graph, class GraphPtr, class Property, class PropertyRef>
|
||||
@@ -2495,8 +2490,7 @@ namespace boost {
|
||||
typedef PropertyRef reference;
|
||||
typedef typename boost::graph_traits<Graph>::vertex_descriptor key_type;
|
||||
typedef boost::lvalue_property_map_tag category;
|
||||
vec_adj_list_vertex_all_properties_map() { }
|
||||
vec_adj_list_vertex_all_properties_map(GraphPtr g) : m_g(g) { }
|
||||
vec_adj_list_vertex_all_properties_map(GraphPtr g = 0, vertex_all_t = vertex_all_t()) : m_g(g) { }
|
||||
inline PropertyRef operator[](key_type v) const {
|
||||
return m_g->m_vertices[v].m_property;
|
||||
}
|
||||
@@ -2542,7 +2536,7 @@ namespace boost {
|
||||
typedef boost::readable_property_map_tag category;
|
||||
inline vec_adj_list_vertex_id_map() { }
|
||||
template <class Graph>
|
||||
inline vec_adj_list_vertex_id_map(const Graph&) { }
|
||||
inline vec_adj_list_vertex_id_map(const Graph&, vertex_index_t) { }
|
||||
inline value_type operator[](key_type v) const { return v; }
|
||||
inline value_type operator()(key_type v) const { return v; }
|
||||
};
|
||||
@@ -2579,17 +2573,11 @@ namespace boost {
|
||||
};
|
||||
};
|
||||
namespace detail {
|
||||
template <class Tag>
|
||||
struct adj_list_choose_vertex_pa_helper {
|
||||
typedef adj_list_any_vertex_pa type;
|
||||
};
|
||||
template <>
|
||||
struct adj_list_choose_vertex_pa_helper<vertex_all_t> {
|
||||
typedef adj_list_all_vertex_pa type;
|
||||
};
|
||||
template <class Tag, class Graph, class Property>
|
||||
struct adj_list_choose_vertex_pa {
|
||||
typedef typename adj_list_choose_vertex_pa_helper<Tag>::type Helper;
|
||||
typedef typename
|
||||
boost::mpl::if_<boost::is_same<Tag, vertex_all_t>, adj_list_all_vertex_pa, adj_list_any_vertex_pa>::type
|
||||
Helper;
|
||||
typedef typename Helper::template bind_<Tag,Graph,Property> Bind;
|
||||
typedef typename Bind::type type;
|
||||
typedef typename Bind::const_type const_type;
|
||||
@@ -2629,13 +2617,16 @@ namespace boost {
|
||||
Tag>
|
||||
>
|
||||
{
|
||||
Tag tag;
|
||||
explicit adj_list_edge_property_map(Tag tag = Tag()): tag(tag) {}
|
||||
|
||||
typedef Value value_type;
|
||||
typedef Ref reference;
|
||||
typedef detail::edge_desc_impl<Directed, Vertex> key_type;
|
||||
typedef boost::lvalue_property_map_tag category;
|
||||
inline Ref operator[](key_type e) const {
|
||||
Property& p = *(Property*)e.get_property();
|
||||
return get_property_value(p, Tag());
|
||||
return get_property_value(p, tag);
|
||||
}
|
||||
inline Ref operator()(key_type e) const {
|
||||
return this->operator[](e);
|
||||
@@ -2650,6 +2641,7 @@ namespace boost {
|
||||
PropPtr, Vertex>
|
||||
>
|
||||
{
|
||||
explicit adj_list_edge_all_properties_map(edge_all_t = edge_all_t()) {}
|
||||
typedef Property value_type;
|
||||
typedef PropRef reference;
|
||||
typedef detail::edge_desc_impl<Directed, Vertex> key_type;
|
||||
@@ -2793,15 +2785,6 @@ namespace boost {
|
||||
#endif
|
||||
|
||||
|
||||
#undef stored_edge
|
||||
#undef stored_edge_property
|
||||
#undef stored_edge_iter
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
// Stay out of the way of the concept checking class
|
||||
#undef Graph
|
||||
#endif
|
||||
|
||||
#endif // BOOST_GRAPH_DETAIL_DETAIL_ADJACENCY_LIST_CCT
|
||||
|
||||
/*
|
||||
|
||||
@@ -33,14 +33,12 @@ template <
|
||||
class directed_graph
|
||||
{
|
||||
public:
|
||||
typedef typename graph_detail::graph_prop<GraphProp>::property graph_property_type;
|
||||
typedef typename graph_detail::graph_prop<GraphProp>::bundle graph_bundled;
|
||||
|
||||
typedef typename graph_detail::vertex_prop<VertexProp>::property vertex_property_type;
|
||||
typedef typename graph_detail::vertex_prop<VertexProp>::bundle vertex_bundled;
|
||||
|
||||
typedef typename graph_detail::edge_prop<EdgeProp>::property edge_property_type;
|
||||
typedef typename graph_detail::edge_prop<EdgeProp>::bundle edge_bundled;
|
||||
typedef GraphProp graph_property_type;
|
||||
typedef VertexProp vertex_property_type;
|
||||
typedef EdgeProp edge_property_type;
|
||||
typedef typename lookup_one_property<GraphProp, graph_bundle_t>::type graph_bundled;
|
||||
typedef typename lookup_one_property<VertexProp, vertex_bundle_t>::type vertex_bundled;
|
||||
typedef typename lookup_one_property<EdgeProp, edge_bundle_t>::type edge_bundled;
|
||||
|
||||
private:
|
||||
// Wrap the user-specified properties with an index.
|
||||
@@ -590,35 +588,6 @@ void
|
||||
set_property(DIRECTED_GRAPH& g, Property p, Value v)
|
||||
{ return set_property(g.impl(), p, v); }
|
||||
|
||||
#ifndef BOOST_GRAPH_NO_BUNDLED_PROPERTIES
|
||||
|
||||
template <DIRECTED_GRAPH_PARAMS, typename Type, typename Bundle>
|
||||
inline typename property_map<DIRECTED_GRAPH, Type Bundle::*>::type
|
||||
get(Type Bundle::* p, DIRECTED_GRAPH& g) {
|
||||
typedef typename property_map<
|
||||
DIRECTED_GRAPH, Type Bundle::*
|
||||
>::type return_type;
|
||||
return return_type(&g, p);
|
||||
}
|
||||
|
||||
template <DIRECTED_GRAPH_PARAMS, typename Type, typename Bundle>
|
||||
inline typename property_map<DIRECTED_GRAPH, Type Bundle::*>::const_type
|
||||
get(Type Bundle::* p, DIRECTED_GRAPH const& g) {
|
||||
typedef typename property_map<
|
||||
DIRECTED_GRAPH, Type Bundle::*
|
||||
>::const_type return_type;
|
||||
return return_type(&g, p);
|
||||
}
|
||||
|
||||
template <DIRECTED_GRAPH_PARAMS, typename Type, typename Bundle, typename Key>
|
||||
inline Type get(Type Bundle::* p, DIRECTED_GRAPH const& g, Key const& k)
|
||||
{ return get(p, g.impl(), k); }
|
||||
|
||||
template <DIRECTED_GRAPH_PARAMS, typename Type, typename Bundle, typename Key, typename Value>
|
||||
inline void put(Type Bundle::* p, DIRECTED_GRAPH& g, Key const& k, Value const& v)
|
||||
{ put(p, g.impl(), k, v); }
|
||||
#endif
|
||||
|
||||
// Vertex index management
|
||||
|
||||
template <DIRECTED_GRAPH_PARAMS>
|
||||
|
||||
@@ -140,7 +140,7 @@ namespace boost {
|
||||
}
|
||||
};
|
||||
template<>
|
||||
struct edmonds_karp_dispatch2<detail::error_property_not_found> {
|
||||
struct edmonds_karp_dispatch2<param_not_found> {
|
||||
template <class Graph, class PredMap, class P, class T, class R>
|
||||
static typename edge_capacity_value<Graph, P, T, R>::type
|
||||
apply
|
||||
@@ -149,7 +149,7 @@ namespace boost {
|
||||
typename graph_traits<Graph>::vertex_descriptor sink,
|
||||
PredMap pred,
|
||||
const bgl_named_params<P, T, R>& params,
|
||||
detail::error_property_not_found)
|
||||
param_not_found)
|
||||
{
|
||||
typedef typename graph_traits<Graph>::edge_descriptor edge_descriptor;
|
||||
typedef typename graph_traits<Graph>::vertices_size_type size_type;
|
||||
@@ -183,13 +183,13 @@ namespace boost {
|
||||
const bgl_named_params<P, T, R>& params,
|
||||
PredMap pred)
|
||||
{
|
||||
typedef typename property_value< bgl_named_params<P,T,R>, vertex_color_t>::type C;
|
||||
typedef typename get_param_type< bgl_named_params<P,T,R>, vertex_color_t>::type C;
|
||||
return edmonds_karp_dispatch2<C>::apply
|
||||
(g, src, sink, pred, params, get_param(params, vertex_color));
|
||||
}
|
||||
};
|
||||
template<>
|
||||
struct edmonds_karp_dispatch1<detail::error_property_not_found> {
|
||||
struct edmonds_karp_dispatch1<param_not_found> {
|
||||
|
||||
template <class Graph, class P, class T, class R>
|
||||
static typename edge_capacity_value<Graph, P, T, R>::type
|
||||
@@ -198,7 +198,7 @@ namespace boost {
|
||||
typename graph_traits<Graph>::vertex_descriptor src,
|
||||
typename graph_traits<Graph>::vertex_descriptor sink,
|
||||
const bgl_named_params<P, T, R>& params,
|
||||
detail::error_property_not_found)
|
||||
param_not_found)
|
||||
{
|
||||
typedef typename graph_traits<Graph>::edge_descriptor edge_descriptor;
|
||||
typedef typename graph_traits<Graph>::vertices_size_type size_type;
|
||||
@@ -206,7 +206,7 @@ namespace boost {
|
||||
num_vertices(g) : 1;
|
||||
std::vector<edge_descriptor> pred_vec(n);
|
||||
|
||||
typedef typename property_value< bgl_named_params<P,T,R>, vertex_color_t>::type C;
|
||||
typedef typename get_param_type< bgl_named_params<P,T,R>, vertex_color_t>::type C;
|
||||
return edmonds_karp_dispatch2<C>::apply
|
||||
(g, src, sink,
|
||||
make_iterator_property_map(pred_vec.begin(), choose_const_pmap
|
||||
@@ -227,7 +227,7 @@ namespace boost {
|
||||
typename graph_traits<Graph>::vertex_descriptor sink,
|
||||
const bgl_named_params<P, T, R>& params)
|
||||
{
|
||||
typedef typename property_value< bgl_named_params<P,T,R>, vertex_predecessor_t>::type Pred;
|
||||
typedef typename get_param_type< bgl_named_params<P,T,R>, vertex_predecessor_t>::type Pred;
|
||||
return detail::edmonds_karp_dispatch1<Pred>::apply
|
||||
(g, src, sink, params, get_param(params, vertex_predecessor));
|
||||
}
|
||||
|
||||
@@ -363,7 +363,7 @@ namespace detail {
|
||||
};
|
||||
|
||||
template<>
|
||||
struct fr_force_directed_layout<error_property_not_found>
|
||||
struct fr_force_directed_layout<param_not_found>
|
||||
{
|
||||
template<typename Topology, typename Graph, typename PositionMap,
|
||||
typename AttractiveForce, typename RepulsiveForce,
|
||||
@@ -377,7 +377,7 @@ namespace detail {
|
||||
RepulsiveForce repulsive_force,
|
||||
ForcePairs force_pairs,
|
||||
Cooling cool,
|
||||
error_property_not_found,
|
||||
param_not_found,
|
||||
const bgl_named_params<Param, Tag, Rest>& params)
|
||||
{
|
||||
typedef typename Topology::point_difference_type PointDiff;
|
||||
@@ -404,7 +404,7 @@ fruchterman_reingold_force_directed_layout
|
||||
const Topology& topology,
|
||||
const bgl_named_params<Param, Tag, Rest>& params)
|
||||
{
|
||||
typedef typename property_value<bgl_named_params<Param,Tag,Rest>,
|
||||
typedef typename get_param_type<bgl_named_params<Param,Tag,Rest>,
|
||||
vertex_displacement_t>::type D;
|
||||
|
||||
detail::fr_force_directed_layout<D>::run
|
||||
|
||||
@@ -15,8 +15,11 @@
|
||||
#include <utility> /* Primarily for std::pair */
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/eval_if.hpp>
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
#include <boost/mpl/has_xxx.hpp>
|
||||
#include <boost/mpl/void.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/iterator/iterator_categories.hpp>
|
||||
#include <boost/iterator/iterator_adaptor.hpp>
|
||||
@@ -218,28 +221,31 @@ namespace boost {
|
||||
//?? not the right place ?? Lee
|
||||
typedef boost::forward_traversal_tag multi_pass_input_iterator_tag;
|
||||
|
||||
// Forward declare graph_bundle_t property name (from
|
||||
// boost/graph/properties.hpp, which includes this file) for
|
||||
// bundled_result.
|
||||
enum graph_bundle_t {graph_bundle};
|
||||
namespace detail {
|
||||
BOOST_MPL_HAS_XXX_TRAIT_DEF(graph_property_type)
|
||||
BOOST_MPL_HAS_XXX_TRAIT_DEF(edge_property_type)
|
||||
BOOST_MPL_HAS_XXX_TRAIT_DEF(vertex_property_type)
|
||||
|
||||
template <typename G> struct get_graph_property_type {typedef typename G::graph_property_type type;};
|
||||
template <typename G> struct get_edge_property_type {typedef typename G::edge_property_type type;};
|
||||
template <typename G> struct get_vertex_property_type {typedef typename G::vertex_property_type type;};
|
||||
}
|
||||
|
||||
template <typename G>
|
||||
struct graph_property_type {
|
||||
typedef typename G::graph_property_type type;
|
||||
};
|
||||
struct graph_property_type
|
||||
: boost::mpl::eval_if<detail::has_graph_property_type<G>,
|
||||
detail::get_graph_property_type<G>,
|
||||
boost::mpl::void_> {};
|
||||
template <typename G>
|
||||
struct edge_property_type {
|
||||
typedef typename G::edge_property_type type;
|
||||
};
|
||||
struct edge_property_type
|
||||
: boost::mpl::eval_if<detail::has_edge_property_type<G>,
|
||||
detail::get_edge_property_type<G>,
|
||||
boost::mpl::void_> {};
|
||||
template <typename G>
|
||||
struct vertex_property_type {
|
||||
typedef typename G::vertex_property_type type;
|
||||
};
|
||||
|
||||
struct no_bundle { };
|
||||
struct no_graph_bundle : no_bundle { };
|
||||
struct no_vertex_bundle : no_bundle { };
|
||||
struct no_edge_bundle : no_bundle { };
|
||||
struct vertex_property_type
|
||||
: boost::mpl::eval_if<detail::has_vertex_property_type<G>,
|
||||
detail::get_vertex_property_type<G>,
|
||||
boost::mpl::void_> {};
|
||||
|
||||
template<typename G>
|
||||
struct graph_bundle_type {
|
||||
@@ -281,7 +287,7 @@ namespace boost {
|
||||
// A helper metafunction for determining whether or not a type is
|
||||
// bundled.
|
||||
template <typename T>
|
||||
struct is_no_bundle : mpl::bool_<is_convertible<T, no_bundle>::value>
|
||||
struct is_no_bundle : mpl::bool_<is_same<T, no_property>::value>
|
||||
{ };
|
||||
} // namespace graph_detail
|
||||
|
||||
|
||||
@@ -111,15 +111,16 @@ namespace boost {
|
||||
BOOST_BGL_ONE_PARAM_REF(max_priority_queue, max_priority_queue)
|
||||
|
||||
template <typename T, typename Tag, typename Base = no_property>
|
||||
struct bgl_named_params : public Base
|
||||
struct bgl_named_params
|
||||
{
|
||||
typedef bgl_named_params self;
|
||||
typedef Base next_type;
|
||||
typedef Tag tag_type;
|
||||
typedef T value_type;
|
||||
bgl_named_params(T v = T()) : m_value(v) { }
|
||||
bgl_named_params(T v, const Base& b) : Base(b), m_value(v) { }
|
||||
bgl_named_params(T v, const Base& b) : m_value(v), m_base(b) { }
|
||||
T m_value;
|
||||
Base m_base;
|
||||
|
||||
#define BOOST_BGL_ONE_PARAM_REF(name, key) \
|
||||
template <typename PType> \
|
||||
@@ -182,145 +183,142 @@ BOOST_BGL_DECLARE_NAMED_PARAMS
|
||||
//===========================================================================
|
||||
// Functions for extracting parameters from bgl_named_params
|
||||
|
||||
template <class Tag1, class Tag2, class T1, class Base>
|
||||
template <typename Tag, typename Args>
|
||||
struct lookup_named_param {};
|
||||
|
||||
template <typename T, typename Tag, typename Base>
|
||||
struct lookup_named_param<Tag, bgl_named_params<T, Tag, Base> > {
|
||||
typedef T type;
|
||||
static const T& get(const bgl_named_params<T, Tag, Base>& p) {
|
||||
return p.m_value;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Tag1, typename T, typename Tag, typename Base>
|
||||
struct lookup_named_param<Tag1, bgl_named_params<T, Tag, Base> > {
|
||||
typedef typename lookup_named_param<Tag1, Base>::type type;
|
||||
static const type& get(const bgl_named_params<T, Tag, Base>& p) {
|
||||
return lookup_named_param<Tag1, Base>::get(p.m_base);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Tag, typename Args, typename Def>
|
||||
struct lookup_named_param_def {
|
||||
typedef Def type;
|
||||
static const Def& get(const Args&, const Def& def) {return def;}
|
||||
};
|
||||
|
||||
template <typename T, typename Tag, typename Base, typename Def>
|
||||
struct lookup_named_param_def<Tag, bgl_named_params<T, Tag, Base>, Def> {
|
||||
typedef T type;
|
||||
static const type& get(const bgl_named_params<T, Tag, Base>& p, const Def&) {
|
||||
return p.m_value;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Tag1, typename T, typename Tag, typename Base, typename Def>
|
||||
struct lookup_named_param_def<Tag1, bgl_named_params<T, Tag, Base>, Def> {
|
||||
typedef typename lookup_named_param_def<Tag1, Base, Def>::type type;
|
||||
static const type& get(const bgl_named_params<T, Tag, Base>& p, const Def& def) {
|
||||
return lookup_named_param_def<Tag1, Base, Def>::get(p.m_base, def);
|
||||
}
|
||||
};
|
||||
|
||||
struct param_not_found {};
|
||||
|
||||
template <typename Tag, typename Args>
|
||||
struct get_param_type:
|
||||
lookup_named_param_def<Tag, Args, param_not_found> {};
|
||||
|
||||
template <class Tag, typename Args>
|
||||
inline
|
||||
typename property_value< bgl_named_params<T1,Tag1,Base>, Tag2>::type
|
||||
get_param(const bgl_named_params<T1,Tag1,Base>& p, Tag2 tag2)
|
||||
{
|
||||
enum { match = detail::same_property<Tag1,Tag2>::value };
|
||||
typedef typename
|
||||
property_value< bgl_named_params<T1,Tag1,Base>, Tag2>::type T2;
|
||||
T2* t2 = 0;
|
||||
typedef detail::property_value_dispatch<match> Dispatcher;
|
||||
return Dispatcher::const_get_value(p, t2, tag2);
|
||||
const typename lookup_named_param_def<Tag, Args, param_not_found>::type&
|
||||
get_param(const Args& p, Tag) {
|
||||
return lookup_named_param_def<Tag, Args, param_not_found>::get(p, param_not_found());
|
||||
}
|
||||
|
||||
|
||||
namespace detail {
|
||||
// MSVC++ workaround
|
||||
template <class Param>
|
||||
struct choose_param_helper {
|
||||
template <class Default> struct result { typedef Param type; };
|
||||
template <typename Default>
|
||||
static const Param& apply(const Param& p, const Default&) { return p; }
|
||||
};
|
||||
template <>
|
||||
struct choose_param_helper<error_property_not_found> {
|
||||
template <class Default> struct result { typedef Default type; };
|
||||
template <typename Default>
|
||||
static const Default& apply(const error_property_not_found&, const Default& d)
|
||||
{ return d; }
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
template <class P, class Default>
|
||||
const typename detail::choose_param_helper<P>::template result<Default>::type&
|
||||
choose_param(const P& param, const Default& d) {
|
||||
return detail::choose_param_helper<P>::apply(param, d);
|
||||
const P& choose_param(const P& param, const Default&) {
|
||||
return param;
|
||||
}
|
||||
|
||||
template <class Default>
|
||||
Default choose_param(const param_not_found&, const Default& d) {
|
||||
return d;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline bool is_default_param(const T&) { return false; }
|
||||
|
||||
inline bool is_default_param(const detail::error_property_not_found&)
|
||||
inline bool is_default_param(const param_not_found&)
|
||||
{ return true; }
|
||||
|
||||
namespace detail {
|
||||
template <typename T>
|
||||
struct const_type_as_type {typedef typename T::const_type type;};
|
||||
} // namespace detail
|
||||
|
||||
|
||||
struct choose_parameter {
|
||||
template <class P, class Graph, class Tag>
|
||||
struct bind_ {
|
||||
typedef const P& const_result_type;
|
||||
typedef const P& result_type;
|
||||
typedef P type;
|
||||
};
|
||||
// Use this function instead of choose_param() when you want
|
||||
// to avoid requiring get(tag, g) when it is not used.
|
||||
namespace detail {
|
||||
template <typename GraphIsConst, typename Graph, typename Param, typename Tag>
|
||||
struct choose_impl_result:
|
||||
boost::mpl::eval_if<
|
||||
boost::is_same<Param, param_not_found>,
|
||||
boost::mpl::eval_if<
|
||||
GraphIsConst,
|
||||
detail::const_type_as_type<property_map<Graph, Tag> >,
|
||||
property_map<Graph, Tag> >,
|
||||
boost::mpl::identity<Param> > {};
|
||||
|
||||
template <class P, class Graph, class Tag>
|
||||
static typename bind_<P, Graph, Tag>::const_result_type
|
||||
const_apply(const P& p, const Graph&, Tag&)
|
||||
{ return p; }
|
||||
// Parameters are (NotFound, GraphIsConst, Graph, Param, Tag)
|
||||
template <typename Param, typename Graph, typename PropertyTag>
|
||||
typename property_map<Graph, PropertyTag>::const_type
|
||||
choose_impl(boost::mpl::true_, boost::mpl::true_, const Graph& g, const Param&, PropertyTag tag) {
|
||||
return get(tag, g);
|
||||
}
|
||||
|
||||
template <class P, class Graph, class Tag>
|
||||
static typename bind_<P, Graph, Tag>::result_type
|
||||
apply(const P& p, Graph&, Tag&)
|
||||
{ return p; }
|
||||
};
|
||||
template <typename Param, typename Graph, typename PropertyTag>
|
||||
typename property_map<Graph, PropertyTag>::type
|
||||
choose_impl(boost::mpl::true_, boost::mpl::false_, Graph& g, const Param&, PropertyTag tag) {
|
||||
return get(tag, g);
|
||||
}
|
||||
|
||||
struct choose_default_param {
|
||||
template <class P, class Graph, class Tag>
|
||||
struct bind_ {
|
||||
typedef typename property_map<Graph, Tag>::type
|
||||
result_type;
|
||||
typedef typename property_map<Graph, Tag>::const_type
|
||||
const_result_type;
|
||||
typedef typename property_map<Graph, Tag>::const_type
|
||||
type;
|
||||
};
|
||||
template <typename GraphIsConst, typename Param, typename Graph, typename PropertyTag>
|
||||
Param
|
||||
choose_impl(boost::mpl::false_, GraphIsConst, const Graph&, const Param& p, PropertyTag) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
|
||||
template <class P, class Graph, class Tag>
|
||||
static typename bind_<P, Graph, Tag>::const_result_type
|
||||
const_apply(const P&, const Graph& g, Tag tag) {
|
||||
return get(tag, g);
|
||||
}
|
||||
template <class P, class Graph, class Tag>
|
||||
static typename bind_<P, Graph, Tag>::result_type
|
||||
apply(const P&, Graph& g, Tag tag) {
|
||||
return get(tag, g);
|
||||
}
|
||||
};
|
||||
template <typename Param, typename Graph, typename PropertyTag>
|
||||
typename detail::choose_impl_result<boost::mpl::true_, Graph, Param, PropertyTag>::type
|
||||
choose_const_pmap(const Param& p, const Graph& g, PropertyTag tag)
|
||||
{
|
||||
return detail::choose_impl(boost::mpl::bool_<boost::is_same<Param, param_not_found>::value>(),
|
||||
boost::mpl::true_(), g, p, tag);
|
||||
}
|
||||
|
||||
template <class Param>
|
||||
struct choose_property_map {
|
||||
typedef choose_parameter type;
|
||||
};
|
||||
template <>
|
||||
struct choose_property_map<detail::error_property_not_found> {
|
||||
typedef choose_default_param type;
|
||||
};
|
||||
template <typename Param, typename Graph, typename PropertyTag>
|
||||
typename detail::choose_impl_result<boost::mpl::false_, Graph, Param, PropertyTag>::type
|
||||
choose_pmap(const Param& p, Graph& g, PropertyTag tag)
|
||||
{
|
||||
return detail::choose_impl(boost::mpl::bool_<boost::is_same<Param, param_not_found>::value>(),
|
||||
boost::mpl::false_(), g, p, tag);
|
||||
}
|
||||
|
||||
template <class Param, class Graph, class Tag>
|
||||
struct choose_pmap_helper {
|
||||
typedef typename choose_property_map<Param>::type Selector;
|
||||
typedef typename Selector:: template bind_<Param, Graph, Tag> Bind;
|
||||
typedef Bind type;
|
||||
typedef typename Bind::result_type result_type;
|
||||
typedef typename Bind::const_result_type const_result_type;
|
||||
typedef typename Bind::type result;
|
||||
};
|
||||
namespace detail {
|
||||
|
||||
// used in the max-flow algorithms
|
||||
template <class Graph, class P, class T, class R>
|
||||
struct edge_capacity_value
|
||||
{
|
||||
typedef bgl_named_params<P, T, R> Params;
|
||||
typedef typename property_value< Params, edge_capacity_t>::type Param;
|
||||
typedef typename detail::choose_pmap_helper<Param, Graph,
|
||||
edge_capacity_t>::result CapacityEdgeMap;
|
||||
typedef typename detail::choose_impl_result<boost::mpl::true_, Graph, typename get_param_type<Params, edge_capacity_t>::type, edge_capacity_t>::type CapacityEdgeMap;
|
||||
typedef typename property_traits<CapacityEdgeMap>::value_type type;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
|
||||
// Use this function instead of choose_param() when you want
|
||||
// to avoid requiring get(tag, g) when it is not used.
|
||||
template <typename Param, typename Graph, typename PropertyTag>
|
||||
typename
|
||||
detail::choose_pmap_helper<Param,Graph,PropertyTag>::const_result_type
|
||||
choose_const_pmap(const Param& p, const Graph& g, PropertyTag tag)
|
||||
{
|
||||
typedef typename
|
||||
detail::choose_pmap_helper<Param,Graph,PropertyTag>::Selector Choice;
|
||||
return Choice::const_apply(p, g, tag);
|
||||
}
|
||||
|
||||
template <typename Param, typename Graph, typename PropertyTag>
|
||||
typename detail::choose_pmap_helper<Param,Graph,PropertyTag>::result_type
|
||||
choose_pmap(const Param& p, Graph& g, PropertyTag tag)
|
||||
{
|
||||
typedef typename
|
||||
detail::choose_pmap_helper<Param,Graph,PropertyTag>::Selector Choice;
|
||||
return Choice::apply(p, g, tag);
|
||||
}
|
||||
|
||||
// Declare all new tags
|
||||
@@ -353,7 +351,7 @@ BOOST_BGL_DECLARE_NAMED_PARAMS
|
||||
typedef convert_bgl_params_to_boost_parameter<typename T::next_type> rest_conv;
|
||||
typedef boost::parameter::aux::arg_list<tagged_arg_type, typename rest_conv::type> type;
|
||||
static type conv(const T& x) {
|
||||
return type(tagged_arg_type(x.m_value), rest_conv::conv(x));
|
||||
return type(tagged_arg_type(x.m_value), rest_conv::conv(x.m_base));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -362,7 +360,7 @@ BOOST_BGL_DECLARE_NAMED_PARAMS
|
||||
typedef convert_bgl_params_to_boost_parameter<R> rest_conv;
|
||||
typedef typename rest_conv::type type;
|
||||
static type conv(const bgl_named_params<P, int, R>& x) {
|
||||
return rest_conv::conv(x);
|
||||
return rest_conv::conv(x.m_base);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -375,7 +373,7 @@ BOOST_BGL_DECLARE_NAMED_PARAMS
|
||||
template <>
|
||||
struct convert_bgl_params_to_boost_parameter<boost::no_named_parameters> {
|
||||
typedef boost::parameter::aux::empty_arg_list type;
|
||||
static type conv(const boost::no_property&) {return type();}
|
||||
static type conv(const boost::no_named_parameters&) {return type();}
|
||||
};
|
||||
|
||||
struct bgl_parameter_not_found_type {};
|
||||
|
||||
@@ -155,51 +155,6 @@ struct internal_vertex_constructor<property<Tag, T, Base> >
|
||||
: internal_vertex_constructor<Base> { };
|
||||
#endif
|
||||
|
||||
/*******************************************************************
|
||||
* Named graph-specific metafunctions *
|
||||
*******************************************************************/
|
||||
namespace detail {
|
||||
/** @internal
|
||||
* Extracts the type of a bundled vertex property from a vertex
|
||||
* property. The primary template matches when we have hit the end
|
||||
* of the @c property<> list.
|
||||
*/
|
||||
template<typename VertexProperty>
|
||||
struct extract_bundled_vertex
|
||||
{
|
||||
typedef VertexProperty type;
|
||||
};
|
||||
|
||||
/** @internal
|
||||
* Recursively extract the bundled vertex property from a vertex
|
||||
* property.
|
||||
*/
|
||||
template<typename Tag, typename T, typename Base>
|
||||
struct extract_bundled_vertex<property<Tag, T, Base> >
|
||||
: extract_bundled_vertex<Base>
|
||||
{ };
|
||||
|
||||
/**
|
||||
* We have found the bundled vertex property type, marked with
|
||||
* vertex_bundle_t.
|
||||
*/
|
||||
template<typename T, typename Base>
|
||||
struct extract_bundled_vertex<property<vertex_bundle_t, T, Base> >
|
||||
{
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
/**
|
||||
* Translate @c no_property into @c error_property_not_found when we
|
||||
* have failed to extract a bundled vertex property type.
|
||||
*/
|
||||
template<>
|
||||
struct extract_bundled_vertex<no_property>
|
||||
{
|
||||
typedef boost::detail::error_property_not_found type;
|
||||
};
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
* Named graph mixin *
|
||||
*******************************************************************/
|
||||
@@ -228,7 +183,7 @@ public:
|
||||
typedef typename internal_vertex_name<VertexProperty>::type extract_name_type;
|
||||
/// The type of the "bundled" property, from which the name can be
|
||||
/// extracted.
|
||||
typedef typename detail::extract_bundled_vertex<VertexProperty>::type
|
||||
typedef typename lookup_one_property<VertexProperty, vertex_bundle_t>::type
|
||||
bundled_vertex_property_type;
|
||||
|
||||
/// The type of the function object that generates vertex properties
|
||||
@@ -477,7 +432,7 @@ struct maybe_named_graph<Graph, Vertex, VertexProperty, void>
|
||||
{
|
||||
/// The type of the "bundled" property, from which the name can be
|
||||
/// extracted.
|
||||
typedef typename detail::extract_bundled_vertex<VertexProperty>::type
|
||||
typedef typename lookup_one_property<VertexProperty, vertex_bundle_t>::type
|
||||
bundled_vertex_property_type;
|
||||
|
||||
/// Notify the named_graph that we have added the given vertex. This
|
||||
|
||||
@@ -250,13 +250,13 @@ namespace boost {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct neighbor_bfs_dispatch<detail::error_property_not_found> {
|
||||
struct neighbor_bfs_dispatch<param_not_found> {
|
||||
template <class VertexListGraph, class P, class T, class R>
|
||||
static void apply
|
||||
(VertexListGraph& g,
|
||||
typename graph_traits<VertexListGraph>::vertex_descriptor s,
|
||||
const bgl_named_params<P, T, R>& params,
|
||||
detail::error_property_not_found)
|
||||
param_not_found)
|
||||
{
|
||||
std::vector<default_color_type> color_vec(num_vertices(g));
|
||||
null_visitor null_vis;
|
||||
@@ -288,7 +288,7 @@ namespace boost {
|
||||
// graph is not really const since we may write to property maps
|
||||
// of the graph.
|
||||
VertexListGraph& ng = const_cast<VertexListGraph&>(g);
|
||||
typedef typename property_value< bgl_named_params<P,T,R>,
|
||||
typedef typename get_param_type< bgl_named_params<P,T,R>,
|
||||
vertex_color_t>::type C;
|
||||
detail::neighbor_bfs_dispatch<C>::apply(ng, s, params,
|
||||
get_param(params, vertex_color));
|
||||
|
||||
@@ -68,26 +68,20 @@ namespace boost {
|
||||
struct vertex_property_tag { };
|
||||
struct edge_property_tag { };
|
||||
|
||||
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
// See examples/edge_property.cpp for how to use this.
|
||||
#define BOOST_INSTALL_PROPERTY(KIND, NAME) \
|
||||
template <> struct property_kind<KIND##_##NAME##_t> { \
|
||||
typedef KIND##_property_tag type; \
|
||||
}
|
||||
#else
|
||||
#define BOOST_INSTALL_PROPERTY(KIND, NAME) \
|
||||
template <> struct property_kind<KIND##_##NAME##_t> { \
|
||||
typedef KIND##_property_tag type; \
|
||||
}
|
||||
#endif
|
||||
|
||||
#define BOOST_DEF_PROPERTY(KIND, NAME) \
|
||||
enum KIND##_##NAME##_t { KIND##_##NAME }; \
|
||||
BOOST_INSTALL_PROPERTY(KIND, NAME)
|
||||
|
||||
BOOST_DEF_PROPERTY(vertex, all);
|
||||
BOOST_DEF_PROPERTY(edge, all);
|
||||
BOOST_DEF_PROPERTY(graph, all);
|
||||
// These three are defined in boost/pending/property.hpp
|
||||
BOOST_INSTALL_PROPERTY(vertex, all);
|
||||
BOOST_INSTALL_PROPERTY(edge, all);
|
||||
BOOST_INSTALL_PROPERTY(graph, all);
|
||||
BOOST_DEF_PROPERTY(vertex, index);
|
||||
BOOST_DEF_PROPERTY(vertex, index1);
|
||||
BOOST_DEF_PROPERTY(vertex, index2);
|
||||
@@ -128,10 +122,10 @@ namespace boost {
|
||||
BOOST_DEF_PROPERTY(graph, visitor);
|
||||
|
||||
// These tags are used for property bundles
|
||||
// BOOST_DEF_PROPERTY(graph, bundle); -- needed in graph_traits.hpp, so enum is defined there
|
||||
// These three are defined in boost/pending/property.hpp
|
||||
BOOST_INSTALL_PROPERTY(graph, bundle);
|
||||
BOOST_DEF_PROPERTY(vertex, bundle);
|
||||
BOOST_DEF_PROPERTY(edge, bundle);
|
||||
BOOST_INSTALL_PROPERTY(vertex, bundle);
|
||||
BOOST_INSTALL_PROPERTY(edge, bundle);
|
||||
|
||||
// These tags are used to denote the owners and local descriptors
|
||||
// for the vertices and edges of a distributed graph.
|
||||
@@ -148,6 +142,25 @@ namespace boost {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename G, typename Tag>
|
||||
struct property_kind_from_graph: property_kind<Tag> {};
|
||||
|
||||
#ifndef BOOST_GRAPH_NO_BUNDLED_PROPERTIES
|
||||
template <typename G, typename R, typename T>
|
||||
struct property_kind_from_graph<G, R T::*> {
|
||||
typedef typename boost::mpl::if_<
|
||||
boost::is_same<T, typename vertex_bundle_type<G>::type>,
|
||||
vertex_property_tag,
|
||||
typename boost::mpl::if_<
|
||||
boost::is_same<T, typename edge_bundle_type<G>::type>,
|
||||
edge_property_tag,
|
||||
typename boost::mpl::if_<
|
||||
boost::is_same<T, typename graph_bundle_type<G>::type>,
|
||||
graph_property_tag,
|
||||
void>::type>::type>::type type;
|
||||
};
|
||||
#endif
|
||||
|
||||
struct dummy_edge_property_selector {
|
||||
template <class Graph, class Property, class Tag>
|
||||
struct bind_ {
|
||||
@@ -213,45 +226,16 @@ namespace boost {
|
||||
typedef typename Bind::type type;
|
||||
typedef typename Bind::const_type const_type;
|
||||
};
|
||||
|
||||
// This selects the kind of property map, whether is maps from
|
||||
// edges or from vertices.
|
||||
//
|
||||
// It is overly complicated because it's a workaround for
|
||||
// partial specialization.
|
||||
struct choose_vertex_property_map {
|
||||
template <class Graph, class Property>
|
||||
struct bind_ {
|
||||
typedef vertex_property_map<Graph, Property> type;
|
||||
};
|
||||
};
|
||||
struct choose_edge_property_map {
|
||||
template <class Graph, class Property>
|
||||
struct bind_ {
|
||||
typedef edge_property_map<Graph, Property> type;
|
||||
};
|
||||
};
|
||||
template <class Kind>
|
||||
struct property_map_kind_selector {
|
||||
// VC++ gets confused if this isn't defined, even though
|
||||
// this never gets used.
|
||||
typedef choose_vertex_property_map type;
|
||||
};
|
||||
template <> struct property_map_kind_selector<vertex_property_tag> {
|
||||
typedef choose_vertex_property_map type;
|
||||
};
|
||||
template <> struct property_map_kind_selector<edge_property_tag> {
|
||||
typedef choose_edge_property_map type;
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
template <class Graph, class Property>
|
||||
struct property_map {
|
||||
// private:
|
||||
typedef typename property_kind<Property>::type Kind;
|
||||
typedef typename detail::property_map_kind_selector<Kind>::type Selector;
|
||||
typedef typename Selector::template bind_<Graph, Property> Bind;
|
||||
typedef typename Bind::type Map;
|
||||
typedef typename detail::property_kind_from_graph<Graph, Property>::type Kind;
|
||||
typedef typename mpl::if_<
|
||||
is_same<Kind, edge_property_tag>,
|
||||
detail::edge_property_map<Graph, Property>,
|
||||
detail::vertex_property_map<Graph, Property> >::type Map;
|
||||
public:
|
||||
typedef typename Map::type type;
|
||||
typedef typename Map::const_type const_type;
|
||||
@@ -273,16 +257,8 @@ namespace boost {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template <class Graph>
|
||||
class vertex_property {
|
||||
public:
|
||||
typedef typename Graph::vertex_property_type type;
|
||||
};
|
||||
template <class Graph>
|
||||
class edge_property {
|
||||
public:
|
||||
typedef typename Graph::edge_property_type type;
|
||||
};
|
||||
template <class Graph> class vertex_property: vertex_property_type<Graph> {};
|
||||
template <class Graph> class edge_property: edge_property_type<Graph> {};
|
||||
|
||||
template <typename Graph>
|
||||
class degree_property_map
|
||||
@@ -383,99 +359,6 @@ namespace boost {
|
||||
# define BOOST_GRAPH_NO_BUNDLED_PROPERTIES
|
||||
#endif
|
||||
|
||||
#ifndef BOOST_GRAPH_NO_BUNDLED_PROPERTIES
|
||||
template<typename Graph, typename Descriptor, typename Bundle, typename T>
|
||||
struct bundle_property_map
|
||||
: put_get_helper<T&, bundle_property_map<Graph, Descriptor, Bundle, T> >
|
||||
{
|
||||
typedef Descriptor key_type;
|
||||
typedef typename remove_const<T>::type value_type;
|
||||
typedef T& reference;
|
||||
typedef lvalue_property_map_tag category;
|
||||
|
||||
bundle_property_map() { }
|
||||
bundle_property_map(Graph* g_, T Bundle::* pm_) : g(g_), pm(pm_) {}
|
||||
|
||||
reference operator[](key_type k) const { return (*g)[k].*pm; }
|
||||
private:
|
||||
Graph* g;
|
||||
T Bundle::* pm;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
template<typename VertexBundle, typename EdgeBundle, typename Bundle>
|
||||
struct is_vertex_bundle
|
||||
: mpl::and_<is_convertible<VertexBundle*, Bundle*>,
|
||||
mpl::and_<mpl::not_<is_void<VertexBundle> >,
|
||||
mpl::not_<is_same<VertexBundle, no_property> > > >
|
||||
{ };
|
||||
}
|
||||
|
||||
// Specialize the property map template to generate bundled property maps.
|
||||
template <typename Graph, typename T, typename Bundle>
|
||||
struct property_map<Graph, T Bundle::*>
|
||||
{
|
||||
private:
|
||||
typedef graph_traits<Graph> traits;
|
||||
typedef typename Graph::vertex_bundled vertex_bundled;
|
||||
typedef typename Graph::edge_bundled edge_bundled;
|
||||
typedef typename mpl::if_c<(detail::is_vertex_bundle<vertex_bundled, edge_bundled, Bundle>::value),
|
||||
typename traits::vertex_descriptor,
|
||||
typename traits::edge_descriptor>::type
|
||||
descriptor;
|
||||
typedef typename mpl::if_c<(detail::is_vertex_bundle<vertex_bundled, edge_bundled, Bundle>::value),
|
||||
vertex_bundled,
|
||||
edge_bundled>::type
|
||||
actual_bundle;
|
||||
|
||||
public:
|
||||
typedef bundle_property_map<Graph, descriptor, actual_bundle, T> type;
|
||||
typedef bundle_property_map<const Graph, descriptor, actual_bundle, const T>
|
||||
const_type;
|
||||
};
|
||||
#endif
|
||||
|
||||
// These metafunctions help implement the process of determining the vertex
|
||||
// and edge properties of a graph.
|
||||
namespace graph_detail {
|
||||
template<typename Retag>
|
||||
struct retagged_property {
|
||||
typedef typename Retag::type type;
|
||||
};
|
||||
|
||||
// Search the normalized PropList (as returned by retagged<>::type) for
|
||||
// the given bundle. Return the type error if no such bundle can be found.
|
||||
template <typename PropList, typename Bundle>
|
||||
struct retagged_bundle {
|
||||
typedef typename property_value<PropList, Bundle>::type Value;
|
||||
typedef typename mpl::if_<
|
||||
is_same<Value, detail::error_property_not_found>, no_bundle, Value
|
||||
>::type type;
|
||||
};
|
||||
|
||||
template<typename Prop, typename Bundle>
|
||||
class normal_property {
|
||||
// Normalize the property into a property list.
|
||||
typedef detail::retag_property_list<Bundle, Prop> List;
|
||||
public:
|
||||
// Extract the normalized property and bundle types.
|
||||
typedef typename retagged_property<List>::type property;
|
||||
typedef typename retagged_bundle<property, Bundle>::type bundle;
|
||||
};
|
||||
|
||||
template<typename Prop>
|
||||
struct graph_prop : normal_property<Prop, graph_bundle_t>
|
||||
{ };
|
||||
|
||||
template<typename Prop>
|
||||
struct vertex_prop : normal_property<Prop, vertex_bundle_t>
|
||||
{ };
|
||||
|
||||
template<typename Prop>
|
||||
struct edge_prop : normal_property<Prop, edge_bundle_t>
|
||||
{ };
|
||||
} // namespace graph_detail
|
||||
|
||||
// NOTE: These functions are declared, but never defined since they need to
|
||||
// be overloaded by graph implementations. However, we need them to be
|
||||
// declared for the functions below.
|
||||
@@ -498,17 +381,11 @@ get_property(Graph& g) {
|
||||
|
||||
template<typename Graph>
|
||||
inline typename graph_property<Graph, graph_bundle_t>::type const&
|
||||
get_property(Graph const& g) {
|
||||
get_property(const Graph& g) {
|
||||
return get_property(g, graph_bundle);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace boost
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
// Stay out of the way of the concept checking class
|
||||
# undef Graph
|
||||
# undef RandomAccessIterator
|
||||
#endif
|
||||
|
||||
#endif /* BOOST_GRAPH_PROPERTIES_HPPA */
|
||||
#endif /* BOOST_GRAPH_PROPERTIES_HPP */
|
||||
|
||||
@@ -358,36 +358,23 @@ namespace detail {
|
||||
}
|
||||
};
|
||||
|
||||
struct reverse_graph_vertex_property_selector {
|
||||
template <class ReverseGraph, class Property, class Tag>
|
||||
struct bind_ {
|
||||
typedef typename ReverseGraph::base_type Graph;
|
||||
typedef property_map<Graph, Tag> PMap;
|
||||
typedef typename PMap::type type;
|
||||
typedef typename PMap::const_type const_type;
|
||||
};
|
||||
};
|
||||
|
||||
struct reverse_graph_edge_property_selector {
|
||||
template <class ReverseGraph, class Property, class Tag>
|
||||
struct bind_ {
|
||||
typedef typename ReverseGraph::base_type Graph;
|
||||
typedef property_map<Graph, Tag> PMap;
|
||||
typedef reverse_graph_edge_property_map<typename PMap::type> type;
|
||||
typedef reverse_graph_edge_property_map<typename PMap::const_type> const_type;
|
||||
};
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
template <>
|
||||
struct vertex_property_selector<reverse_graph_tag> {
|
||||
typedef detail::reverse_graph_vertex_property_selector type;
|
||||
template <class BidirGraph, class GRef, class Property>
|
||||
struct property_map<reverse_graph<BidirGraph, GRef>, Property> {
|
||||
typedef boost::is_same<typename detail::property_kind_from_graph<BidirGraph, Property>::type, edge_property_tag> is_edge_prop;
|
||||
typedef typename property_map<BidirGraph, Property>::type orig_type;
|
||||
typedef typename property_map<BidirGraph, Property>::const_type orig_const_type;
|
||||
typedef typename boost::mpl::if_<is_edge_prop, detail::reverse_graph_edge_property_map<orig_type>, orig_type>::type type;
|
||||
typedef typename boost::mpl::if_<is_edge_prop, detail::reverse_graph_edge_property_map<orig_const_type>, orig_const_type>::type const_type;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct edge_property_selector<reverse_graph_tag> {
|
||||
typedef detail::reverse_graph_edge_property_selector type;
|
||||
template <class BidirGraph, class GRef, class Property>
|
||||
struct property_map<const reverse_graph<BidirGraph, GRef>, Property> {
|
||||
typedef boost::is_same<typename detail::property_kind_from_graph<BidirGraph, Property>::type, edge_property_tag> is_edge_prop;
|
||||
typedef typename property_map<BidirGraph, Property>::const_type orig_const_type;
|
||||
typedef typename boost::mpl::if_<is_edge_prop, detail::reverse_graph_edge_property_map<orig_const_type>, orig_const_type>::type const_type;
|
||||
typedef const_type type;
|
||||
};
|
||||
|
||||
template <class BidirGraph, class GRef, class Property>
|
||||
@@ -407,7 +394,7 @@ get(Property p, const reverse_graph<BidirGraph,GRef>& g)
|
||||
|
||||
template <class BidirectionalGraph, class GRef, class Property, class Key>
|
||||
typename property_traits<
|
||||
typename property_map<BidirectionalGraph, Property>::const_type
|
||||
typename property_map<reverse_graph<BidirectionalGraph, GRef>, Property>::const_type
|
||||
>::value_type
|
||||
get(Property p, const reverse_graph<BidirectionalGraph,GRef>& g, const Key& k)
|
||||
{
|
||||
@@ -459,6 +446,23 @@ struct property_map<reverse_graph<Graph, GRef>, edge_underlying_t> {
|
||||
typedef detail::underlying_edge_desc_map_type<ed> const_type;
|
||||
};
|
||||
|
||||
template <class Graph, class GRef>
|
||||
detail::underlying_edge_desc_map_type<typename graph_traits<Graph>::edge_descriptor>
|
||||
get(edge_underlying_t,
|
||||
reverse_graph<Graph,GRef>& g)
|
||||
{
|
||||
return detail::underlying_edge_desc_map_type<typename graph_traits<Graph>::edge_descriptor>();
|
||||
}
|
||||
|
||||
template <class Graph, class GRef>
|
||||
typename graph_traits<Graph>::edge_descriptor
|
||||
get(edge_underlying_t,
|
||||
reverse_graph<Graph,GRef>& g,
|
||||
const typename graph_traits<reverse_graph<Graph, GRef> >::edge_descriptor& k)
|
||||
{
|
||||
return k.underlying_descx;
|
||||
}
|
||||
|
||||
template <class Graph, class GRef>
|
||||
detail::underlying_edge_desc_map_type<typename graph_traits<Graph>::edge_descriptor>
|
||||
get(edge_underlying_t,
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace boost {
|
||||
|
||||
|
||||
template <>
|
||||
struct strong_comp_dispatch2<detail::error_property_not_found> {
|
||||
struct strong_comp_dispatch2<param_not_found> {
|
||||
template <class Graph, class ComponentMap, class RootMap,
|
||||
class P, class T, class R>
|
||||
inline static typename property_traits<ComponentMap>::value_type
|
||||
@@ -139,7 +139,7 @@ namespace boost {
|
||||
ComponentMap comp,
|
||||
RootMap r_map,
|
||||
const bgl_named_params<P, T, R>& params,
|
||||
detail::error_property_not_found)
|
||||
param_not_found)
|
||||
{
|
||||
typedef typename graph_traits<Graph>::vertices_size_type size_type;
|
||||
size_type n = num_vertices(g) > 0 ? num_vertices(g) : 1;
|
||||
@@ -179,7 +179,7 @@ namespace boost {
|
||||
}
|
||||
};
|
||||
template <>
|
||||
struct strong_comp_dispatch1<detail::error_property_not_found> {
|
||||
struct strong_comp_dispatch1<param_not_found> {
|
||||
|
||||
template <class Graph, class ComponentMap,
|
||||
class P, class T, class R>
|
||||
@@ -187,7 +187,7 @@ namespace boost {
|
||||
apply(const Graph& g,
|
||||
ComponentMap comp,
|
||||
const bgl_named_params<P, T, R>& params,
|
||||
detail::error_property_not_found)
|
||||
param_not_found)
|
||||
{
|
||||
typedef typename graph_traits<Graph>::vertex_descriptor Vertex;
|
||||
typename std::vector<Vertex>::size_type
|
||||
|
||||
@@ -103,13 +103,11 @@ public:
|
||||
|
||||
typedef typename Traits::in_edge_iterator in_edge_iterator;
|
||||
|
||||
typedef typename Graph::edge_property_type edge_property_type;
|
||||
typedef typename Graph::vertex_property_type vertex_property_type;
|
||||
typedef typename Graph::vertex_bundled vertex_bundled;
|
||||
typedef typename Graph::edge_bundled edge_bundled;
|
||||
typedef typename edge_property_type<Graph>::type edge_property_type;
|
||||
typedef typename vertex_property_type<Graph>::type vertex_property_type;
|
||||
typedef subgraph_tag graph_tag;
|
||||
typedef Graph graph_type;
|
||||
typedef typename Graph::graph_property_type graph_property_type;
|
||||
typedef typename graph_property_type<Graph>::type graph_property_type;
|
||||
|
||||
// Create the main graph, the root of the subgraph tree
|
||||
subgraph()
|
||||
@@ -348,9 +346,6 @@ public: // Probably shouldn't be public....
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef BOOST_GRAPH_NO_BUNDLED_PROPERTIES
|
||||
// TODO: I don't think these are required since the default metafunction
|
||||
// returns Graph::vertex_bundled.
|
||||
template <typename Graph>
|
||||
struct vertex_bundle_type<subgraph<Graph> >
|
||||
: vertex_bundle_type<Graph>
|
||||
@@ -360,7 +355,11 @@ template<typename Graph>
|
||||
struct edge_bundle_type<subgraph<Graph> >
|
||||
: edge_bundle_type<Graph>
|
||||
{ };
|
||||
#endif // BOOST_GRAPH_NO_BUNDLED_PROPERTIES
|
||||
|
||||
template<typename Graph>
|
||||
struct graph_bundle_type<subgraph<Graph> >
|
||||
: graph_bundle_type<Graph>
|
||||
{ };
|
||||
|
||||
//===========================================================================
|
||||
// Functions special to the Subgraph Class
|
||||
@@ -786,18 +785,19 @@ public:
|
||||
subgraph_global_property_map()
|
||||
{ }
|
||||
|
||||
subgraph_global_property_map(GraphPtr g)
|
||||
: m_g(g)
|
||||
subgraph_global_property_map(GraphPtr g, Tag tag)
|
||||
: m_g(g), m_tag(tag)
|
||||
{ }
|
||||
|
||||
reference operator[](key_type e) const {
|
||||
PropertyMap pmap = get(Tag(), m_g->root().m_graph);
|
||||
PropertyMap pmap = get(m_tag, m_g->root().m_graph);
|
||||
return m_g->is_root()
|
||||
? pmap[e]
|
||||
: pmap[m_g->local_to_global(e)];
|
||||
}
|
||||
|
||||
GraphPtr m_g;
|
||||
Tag m_tag;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -824,17 +824,18 @@ public:
|
||||
subgraph_local_property_map()
|
||||
{ }
|
||||
|
||||
subgraph_local_property_map(GraphPtr g)
|
||||
: m_g(g)
|
||||
subgraph_local_property_map(GraphPtr g, Tag tag)
|
||||
: m_g(g), m_tag(tag)
|
||||
{ }
|
||||
|
||||
reference operator[](key_type e) const {
|
||||
// Get property map on the underlying graph.
|
||||
PropertyMap pmap = get(Tag(), m_g->m_graph);
|
||||
PropertyMap pmap = get(m_tag, m_g->m_graph);
|
||||
return pmap[e];
|
||||
}
|
||||
|
||||
GraphPtr m_g;
|
||||
Tag m_tag;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
@@ -949,139 +950,37 @@ struct edge_property_selector<subgraph_tag> {
|
||||
typedef detail::subgraph_property_generator type;
|
||||
};
|
||||
|
||||
#ifndef BOOST_GRAPH_NO_BUNDLED_PROPERTIES
|
||||
/** @internal
|
||||
* This property map implements local or global bundled property access on
|
||||
* an underlying graph. The LocalGlobal template template parameter must be
|
||||
* one of the local_property or global_property templates.
|
||||
*/
|
||||
template <
|
||||
typename Graph, typename Descriptor, typename Bundle, typename T,
|
||||
template <typename> class LocalGlobal>
|
||||
struct subgraph_lg_bundle_property_map
|
||||
: put_get_helper<
|
||||
T&,
|
||||
subgraph_lg_bundle_property_map<Graph, Descriptor, Bundle, T, LocalGlobal>
|
||||
>
|
||||
{
|
||||
private:
|
||||
typedef LocalGlobal<Descriptor> Wrap;
|
||||
public:
|
||||
typedef Descriptor key_type;
|
||||
typedef typename remove_const<T>::type value_type;
|
||||
typedef T& reference;
|
||||
typedef lvalue_property_map_tag category;
|
||||
|
||||
subgraph_lg_bundle_property_map()
|
||||
{ }
|
||||
|
||||
subgraph_lg_bundle_property_map(Graph* g, T Bundle::* p)
|
||||
: m_g(g), m_prop(p)
|
||||
{ }
|
||||
|
||||
reference operator[](key_type k) const
|
||||
{ return (*m_g)[Wrap(k)].*m_prop; }
|
||||
|
||||
private:
|
||||
Graph* m_g;
|
||||
T Bundle::* m_prop;
|
||||
};
|
||||
|
||||
// Specialize the property map template to generate bundled property maps.
|
||||
// NOTE: I'm cheating (actually double-dipping) with the local/global subgraph
|
||||
// property templates. I'm not using them store descriptors, just specialize
|
||||
// the property map template for specific lookups.
|
||||
namespace graph_detail {
|
||||
// Help decoding some of the types required for property map definitions.
|
||||
template <typename Graph, typename T, typename Bundle>
|
||||
struct bundled_subgraph_pmap_helper {
|
||||
typedef subgraph<Graph> Subgraph;
|
||||
typedef graph_traits<Subgraph> Traits;
|
||||
typedef typename Subgraph::vertex_bundled VertBundled;
|
||||
typedef typename Subgraph::edge_bundled EdgeBundled;
|
||||
|
||||
// Deduce the descriptor from the template params
|
||||
typedef typename mpl::if_<
|
||||
detail::is_vertex_bundle<VertBundled, EdgeBundled, Bundle>,
|
||||
typename Traits::vertex_descriptor, typename Traits::edge_descriptor
|
||||
>::type Desc;
|
||||
|
||||
// Deduce the bundled property type
|
||||
typedef typename mpl::if_<
|
||||
detail::is_vertex_bundle<VertBundled, EdgeBundled, Bundle>,
|
||||
VertBundled, EdgeBundled
|
||||
>::type Prop;
|
||||
};
|
||||
} // namespace graph_detail
|
||||
|
||||
template <typename Graph, typename T, typename Bundle>
|
||||
struct property_map<subgraph<Graph>, local_property<T Bundle::*> >
|
||||
: graph_detail::bundled_subgraph_pmap_helper<Graph, T, Bundle>
|
||||
{
|
||||
private:
|
||||
typedef graph_detail::bundled_subgraph_pmap_helper<Graph, T, Bundle> Base;
|
||||
typedef typename Base::Subgraph Subgraph;
|
||||
typedef typename Base::Desc Desc;
|
||||
typedef typename Base::Prop Prop;
|
||||
public:
|
||||
typedef subgraph_lg_bundle_property_map<
|
||||
Subgraph, Desc, Prop, T, local_property
|
||||
> type;
|
||||
typedef subgraph_lg_bundle_property_map<
|
||||
Subgraph const, Desc, Prop, T const, local_property
|
||||
> const_type;
|
||||
};
|
||||
|
||||
template <typename Graph, typename T, typename Bundle>
|
||||
struct property_map<subgraph<Graph>, global_property<T Bundle::*> >
|
||||
: graph_detail::bundled_subgraph_pmap_helper<Graph, T, Bundle>
|
||||
{
|
||||
private:
|
||||
typedef graph_detail::bundled_subgraph_pmap_helper<Graph, T, Bundle> Base;
|
||||
typedef typename Base::Subgraph Subgraph;
|
||||
typedef typename Base::Desc Desc;
|
||||
typedef typename Base::Prop Prop;
|
||||
public:
|
||||
typedef subgraph_lg_bundle_property_map<
|
||||
Subgraph, Desc, Prop, T, global_property
|
||||
> type;
|
||||
typedef subgraph_lg_bundle_property_map<
|
||||
Subgraph const, Desc, Prop, T const, global_property
|
||||
> const_type;
|
||||
};
|
||||
#endif
|
||||
|
||||
// ==================================================
|
||||
// get(p, g), get(p, g, k), and put(p, g, k, v)
|
||||
// ==================================================
|
||||
template <typename G, typename Property>
|
||||
typename property_map<subgraph<G>, Property>::type
|
||||
get(Property, subgraph<G>& g) {
|
||||
get(Property p, subgraph<G>& g) {
|
||||
typedef typename property_map< subgraph<G>, Property>::type PMap;
|
||||
return PMap(&g);
|
||||
return PMap(&g, p);
|
||||
}
|
||||
|
||||
template <typename G, typename Property>
|
||||
typename property_map<subgraph<G>, Property>::const_type
|
||||
get(Property, const subgraph<G>& g) {
|
||||
get(Property p, const subgraph<G>& g) {
|
||||
typedef typename property_map< subgraph<G>, Property>::const_type PMap;
|
||||
return PMap(&g);
|
||||
return PMap(&g, p);
|
||||
}
|
||||
|
||||
template <typename G, typename Property, typename Key>
|
||||
typename property_traits<
|
||||
typename property_map<subgraph<G>, Property>::const_type
|
||||
>::value_type
|
||||
get(Property, const subgraph<G>& g, const Key& k) {
|
||||
get(Property p, const subgraph<G>& g, const Key& k) {
|
||||
typedef typename property_map< subgraph<G>, Property>::const_type PMap;
|
||||
PMap pmap(&g);
|
||||
PMap pmap(&g, p);
|
||||
return pmap[k];
|
||||
}
|
||||
|
||||
template <typename G, typename Property, typename Key, typename Value>
|
||||
void put(Property, subgraph<G>& g, const Key& k, const Value& val) {
|
||||
void put(Property p, subgraph<G>& g, const Key& k, const Value& val) {
|
||||
typedef typename property_map< subgraph<G>, Property>::type PMap;
|
||||
PMap pmap(&g);
|
||||
PMap pmap(&g, p);
|
||||
pmap[k] = val;
|
||||
}
|
||||
|
||||
@@ -1091,20 +990,20 @@ void put(Property, subgraph<G>& g, const Key& k, const Value& val) {
|
||||
// ==================================================
|
||||
template <typename G, typename Property>
|
||||
typename property_map<subgraph<G>, global_property<Property> >::type
|
||||
get(global_property<Property>, subgraph<G>& g) {
|
||||
get(global_property<Property> p, subgraph<G>& g) {
|
||||
typedef typename property_map<
|
||||
subgraph<G>, global_property<Property>
|
||||
>::type Map;
|
||||
return Map(&g);
|
||||
return Map(&g, p.value);
|
||||
}
|
||||
|
||||
template <typename G, typename Property>
|
||||
typename property_map<subgraph<G>, global_property<Property> >::const_type
|
||||
get(global_property<Property>, const subgraph<G>& g) {
|
||||
get(global_property<Property> p, const subgraph<G>& g) {
|
||||
typedef typename property_map<
|
||||
subgraph<G>, global_property<Property>
|
||||
>::const_type Map;
|
||||
return Map(&g);
|
||||
return Map(&g, p.value);
|
||||
}
|
||||
|
||||
// ==================================================
|
||||
@@ -1113,112 +1012,22 @@ get(global_property<Property>, const subgraph<G>& g) {
|
||||
// ==================================================
|
||||
template <typename G, typename Property>
|
||||
typename property_map<subgraph<G>, local_property<Property> >::type
|
||||
get(local_property<Property>, subgraph<G>& g) {
|
||||
get(local_property<Property> p, subgraph<G>& g) {
|
||||
typedef typename property_map<
|
||||
subgraph<G>, local_property<Property>
|
||||
>::type Map;
|
||||
return Map(&g);
|
||||
return Map(&g, p.value);
|
||||
}
|
||||
|
||||
template <typename G, typename Property>
|
||||
typename property_map<subgraph<G>, local_property<Property> >::const_type
|
||||
get(local_property<Property>, const subgraph<G>& g) {
|
||||
get(local_property<Property> p, const subgraph<G>& g) {
|
||||
typedef typename property_map<
|
||||
subgraph<G>, local_property<Property>
|
||||
>::const_type Map;
|
||||
return Map(&g);
|
||||
}
|
||||
|
||||
#ifndef BOOST_GRAPH_NO_BUNDLED_PROPERTIES
|
||||
// ==================================================
|
||||
// get(bundle(p), g)
|
||||
// ==================================================
|
||||
|
||||
template<typename G, typename T, typename Bundle>
|
||||
inline typename property_map<subgraph<G>, T Bundle::*>::type
|
||||
get(T Bundle::* p, subgraph<G>& g) {
|
||||
typedef typename property_map<subgraph<G>, T Bundle::*>::type Map;
|
||||
return Map(&g, p);
|
||||
}
|
||||
|
||||
template<typename G, typename T, typename Bundle>
|
||||
inline typename property_map<subgraph<G>, T Bundle::*>::const_type
|
||||
get(T Bundle::* p, subgraph<G> const& g) {
|
||||
typedef typename property_map<subgraph<G>, T Bundle::*>::const_type Map;
|
||||
return Map(&g, p);
|
||||
}
|
||||
|
||||
template <typename Graph, typename Type, typename Bundle, typename Key>
|
||||
inline Type get(Type Bundle::* p, subgraph<Graph> const& g, Key const& k)
|
||||
{ return get(get(p, g), k); }
|
||||
|
||||
template <typename Graph, typename Type, typename Bundle, typename Key,
|
||||
typename Value>
|
||||
inline void put(Type Bundle::* p, Graph& g, Key const& k, Value const& v)
|
||||
{ put(get(p, g), k, v); }
|
||||
|
||||
// =========================================================
|
||||
// Local bundled, get
|
||||
|
||||
template<typename G, typename T, typename Bundle>
|
||||
inline typename property_map<
|
||||
subgraph<G>, local_property<T Bundle::*>
|
||||
>::type
|
||||
get(local_property<T Bundle::*> p, subgraph<G>& g) {
|
||||
typedef typename property_map<
|
||||
subgraph<G>, local_property<T Bundle::*>
|
||||
>::type Map;
|
||||
return Map(&g, p.value);
|
||||
}
|
||||
|
||||
template<typename G, typename T, typename Bundle>
|
||||
inline typename property_map<
|
||||
subgraph<G>, local_property<T Bundle::*>
|
||||
>::const_type
|
||||
get(local_property<T Bundle::*> p, subgraph<G> const& g) {
|
||||
typedef typename property_map<
|
||||
subgraph<G>, local_property<T Bundle::*>
|
||||
>::const_type Map;
|
||||
return Map(&g, p.value);
|
||||
}
|
||||
|
||||
template <typename Graph, typename Type, typename Bundle, typename Key>
|
||||
inline Type get(local_property<Type Bundle::*> p, subgraph<Graph> const& g,
|
||||
Key const& k)
|
||||
{ return get(get(p, g), k); }
|
||||
|
||||
// =========================================================
|
||||
// Global bundled, get
|
||||
|
||||
template<typename G, typename T, typename Bundle>
|
||||
inline typename property_map<
|
||||
subgraph<G>, global_property<T Bundle::*>
|
||||
>::type
|
||||
get(global_property<T Bundle::*> p, subgraph<G>& g) {
|
||||
typedef typename property_map<
|
||||
subgraph<G>, global_property<T Bundle::*>
|
||||
>::type Map;
|
||||
return Map(&g, p.value);
|
||||
}
|
||||
|
||||
template<typename G, typename T, typename Bundle>
|
||||
inline typename property_map<
|
||||
subgraph<G>, global_property<T Bundle::*>
|
||||
>::const_type
|
||||
get(global_property<T Bundle::*> p, subgraph<G> const& g) {
|
||||
typedef typename property_map<
|
||||
subgraph<G>, global_property<T Bundle::*>
|
||||
>::const_type Map;
|
||||
return Map(&g, p.value);
|
||||
}
|
||||
|
||||
template <typename Graph, typename Type, typename Bundle, typename Key>
|
||||
inline Type get(global_property<Type Bundle::*> p, subgraph<Graph> const& g,
|
||||
Key const& k)
|
||||
{ return get(get(p, g), k); }
|
||||
|
||||
#endif
|
||||
|
||||
template <typename G, typename Tag>
|
||||
inline typename graph_property<G, Tag>::type&
|
||||
get_property(subgraph<G>& g, Tag tag) {
|
||||
|
||||
@@ -188,7 +188,7 @@ namespace boost {
|
||||
};
|
||||
|
||||
template <>
|
||||
struct udfs_dispatch<detail::error_property_not_found> {
|
||||
struct udfs_dispatch<param_not_found> {
|
||||
template <typename Graph, typename Vertex, typename DFSVisitor,
|
||||
typename EdgeColorMap,
|
||||
typename P, typename T, typename R>
|
||||
@@ -196,7 +196,7 @@ namespace boost {
|
||||
apply(const Graph& g, DFSVisitor vis, Vertex start_vertex,
|
||||
const bgl_named_params<P, T, R>& params,
|
||||
EdgeColorMap edge_color,
|
||||
detail::error_property_not_found)
|
||||
param_not_found)
|
||||
{
|
||||
std::vector<default_color_type> color_vec(num_vertices(g));
|
||||
default_color_type c = white_color; // avoid warning about un-init
|
||||
@@ -219,7 +219,7 @@ namespace boost {
|
||||
undirected_dfs(const Graph& g,
|
||||
const bgl_named_params<P, T, R>& params)
|
||||
{
|
||||
typedef typename property_value< bgl_named_params<P, T, R>,
|
||||
typedef typename get_param_type< bgl_named_params<P, T, R>,
|
||||
vertex_color_t>::type C;
|
||||
detail::udfs_dispatch<C>::apply
|
||||
(g,
|
||||
|
||||
@@ -38,14 +38,12 @@ template <
|
||||
class undirected_graph
|
||||
{
|
||||
public:
|
||||
typedef typename graph_detail::graph_prop<GraphProp>::property graph_property_type;
|
||||
typedef typename graph_detail::graph_prop<GraphProp>::bundle graph_bundled;
|
||||
|
||||
typedef typename graph_detail::vertex_prop<VertexProp>::property vertex_property_type;
|
||||
typedef typename graph_detail::vertex_prop<VertexProp>::bundle vertex_bundled;
|
||||
|
||||
typedef typename graph_detail::edge_prop<EdgeProp>::property edge_property_type;
|
||||
typedef typename graph_detail::edge_prop<EdgeProp>::bundle edge_bundled;
|
||||
typedef GraphProp graph_property_type;
|
||||
typedef VertexProp vertex_property_type;
|
||||
typedef EdgeProp edge_property_type;
|
||||
typedef typename lookup_one_property<GraphProp, graph_bundle_t>::type graph_bundled;
|
||||
typedef typename lookup_one_property<VertexProp, vertex_bundle_t>::type vertex_bundled;
|
||||
typedef typename lookup_one_property<EdgeProp, edge_bundle_t>::type edge_bundled;
|
||||
|
||||
private:
|
||||
// Embed indices into the vertex type.
|
||||
@@ -530,36 +528,12 @@ remove_in_edge_if(typename UNDIRECTED_GRAPH::vertex_descriptor v,
|
||||
UNDIRECTED_GRAPH& g)
|
||||
{ return remove_in_edge_if(v, pred, g.impl()); }
|
||||
|
||||
// Helper code for working with property maps
|
||||
namespace detail {
|
||||
struct undirected_graph_vertex_property_selector {
|
||||
template <class UndirectedGraph, class Property, class Tag>
|
||||
struct bind_ {
|
||||
typedef typename UndirectedGraph::graph_type Graph;
|
||||
typedef property_map<Graph, Tag> PropertyMap;
|
||||
typedef typename PropertyMap::type type;
|
||||
typedef typename PropertyMap::const_type const_type;
|
||||
};
|
||||
};
|
||||
|
||||
struct undirected_graph_edge_property_selector {
|
||||
template <class UndirectedGraph, class Property, class Tag>
|
||||
struct bind_ {
|
||||
typedef typename UndirectedGraph::graph_type Graph;
|
||||
typedef property_map<Graph, Tag> PropertyMap;
|
||||
typedef typename PropertyMap::type type;
|
||||
typedef typename PropertyMap::const_type const_type;
|
||||
};
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
template <>
|
||||
struct vertex_property_selector<undirected_graph_tag>
|
||||
{ typedef detail::undirected_graph_vertex_property_selector type; };
|
||||
|
||||
template <>
|
||||
struct edge_property_selector<undirected_graph_tag>
|
||||
{ typedef detail::undirected_graph_edge_property_selector type; };
|
||||
template <UNDIRECTED_GRAPH_PARAMS, typename Property>
|
||||
struct property_map<UNDIRECTED_GRAPH, Property> {
|
||||
typedef typename UNDIRECTED_GRAPH::graph_type Graph;
|
||||
typedef typename property_map<Graph, Property>::type type;
|
||||
typedef typename property_map<Graph, Property>::const_type const_type;
|
||||
};
|
||||
|
||||
// PropertyGraph concepts
|
||||
template <UNDIRECTED_GRAPH_PARAMS, typename Property>
|
||||
@@ -599,36 +573,6 @@ template <UNDIRECTED_GRAPH_PARAMS, class Property, class Value>
|
||||
inline void set_property(UNDIRECTED_GRAPH& g, Property p, Value v)
|
||||
{ return set_property(g.impl(), p, v); }
|
||||
|
||||
#ifndef BOOST_GRAPH_NO_BUNDLED_PROPERTIES
|
||||
template <UNDIRECTED_GRAPH_PARAMS, typename Type, typename Bundle>
|
||||
inline typename property_map<UNDIRECTED_GRAPH, Type Bundle::*>::type
|
||||
get(Type Bundle::* p, UNDIRECTED_GRAPH& g) {
|
||||
typedef typename property_map<
|
||||
UNDIRECTED_GRAPH, Type Bundle::*
|
||||
>::type return_type;
|
||||
return return_type(&g, p);
|
||||
}
|
||||
|
||||
template <UNDIRECTED_GRAPH_PARAMS, typename Type, typename Bundle>
|
||||
inline typename property_map<UNDIRECTED_GRAPH, Type Bundle::*>::const_type
|
||||
get(Type Bundle::* p, UNDIRECTED_GRAPH const& g) {
|
||||
typedef typename property_map<
|
||||
UNDIRECTED_GRAPH, Type Bundle::*
|
||||
>::const_type return_type;
|
||||
return return_type(&g, p);
|
||||
}
|
||||
|
||||
template <UNDIRECTED_GRAPH_PARAMS, typename Type, typename Bundle, typename Key>
|
||||
inline Type
|
||||
get(Type Bundle::* p, UNDIRECTED_GRAPH const& g, Key const& k)
|
||||
{ return get(p, g.impl(), k); }
|
||||
|
||||
template <UNDIRECTED_GRAPH_PARAMS, typename Type, typename Bundle, typename Key, typename Value>
|
||||
inline void
|
||||
put(Type Bundle::* p, UNDIRECTED_GRAPH& g, Key const& k, Value const& v)
|
||||
{ put(p, g.impl(), k, v); }
|
||||
#endif
|
||||
|
||||
// Indexed Vertex graph
|
||||
|
||||
template <UNDIRECTED_GRAPH_PARAMS>
|
||||
|
||||
@@ -13,147 +13,8 @@ namespace boost {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <class PropertyTag1, class PropertyTag2>
|
||||
struct same_property {
|
||||
enum { value = is_same<PropertyTag1,PropertyTag2>::value };
|
||||
};
|
||||
|
||||
struct error_property_not_found { };
|
||||
|
||||
template <int TagMatched>
|
||||
struct property_value_dispatch {
|
||||
template <class PropertyTag, class T, class Tag>
|
||||
inline static T& get_value(PropertyTag& p, T*, Tag) {
|
||||
return p.m_value;
|
||||
}
|
||||
template <class PropertyTag, class T, class Tag>
|
||||
inline static const T& const_get_value(const PropertyTag& p, T*, Tag) {
|
||||
return p.m_value;
|
||||
}
|
||||
};
|
||||
|
||||
template <class PropertyList>
|
||||
struct property_value_end {
|
||||
template <class T> struct result { typedef T type; };
|
||||
|
||||
template <class T, class Tag>
|
||||
inline static T& get_value(PropertyList& p, T* t, Tag tag) {
|
||||
typedef typename PropertyList::next_type Next;
|
||||
typedef typename Next::tag_type Next_tag;
|
||||
enum { match = same_property<Next_tag,Tag>::value };
|
||||
return property_value_dispatch<match>
|
||||
::get_value(static_cast<Next&>(p), t, tag);
|
||||
}
|
||||
template <class T, class Tag>
|
||||
inline static const T& const_get_value(const PropertyList& p, T* t, Tag tag) {
|
||||
typedef typename PropertyList::next_type Next;
|
||||
typedef typename Next::tag_type Next_tag;
|
||||
enum { match = same_property<Next_tag,Tag>::value };
|
||||
return property_value_dispatch<match>
|
||||
::const_get_value(static_cast<const Next&>(p), t, tag);
|
||||
}
|
||||
};
|
||||
template <>
|
||||
struct property_value_end<no_property> {
|
||||
template <class T> struct result {
|
||||
typedef detail::error_property_not_found type;
|
||||
};
|
||||
|
||||
// Stop the recursion and return error
|
||||
template <class T, class Tag>
|
||||
inline static detail::error_property_not_found&
|
||||
get_value(no_property&, T*, Tag) {
|
||||
static error_property_not_found s_prop_not_found;
|
||||
return s_prop_not_found;
|
||||
}
|
||||
template <class T, class Tag>
|
||||
inline static const detail::error_property_not_found&
|
||||
const_get_value(const no_property&, T*, Tag) {
|
||||
static error_property_not_found s_prop_not_found;
|
||||
return s_prop_not_found;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct property_value_dispatch<0> {
|
||||
template <class PropertyList, class T, class Tag>
|
||||
inline static typename property_value_end<PropertyList>::template result<T>::type&
|
||||
get_value(PropertyList& p, T* t, Tag tag) {
|
||||
return property_value_end<PropertyList>::get_value(p, t, tag);
|
||||
}
|
||||
template <class PropertyList, class T, class Tag>
|
||||
inline static const typename property_value_end<PropertyList>::template result<T>::type&
|
||||
const_get_value(const PropertyList& p, T* t, Tag tag) {
|
||||
return property_value_end<PropertyList>::const_get_value(p, t, tag);
|
||||
}
|
||||
};
|
||||
|
||||
template <class PropertyList>
|
||||
struct build_property_tag_value_alist
|
||||
{
|
||||
typedef typename PropertyList::next_type NextProperty;
|
||||
typedef typename PropertyList::value_type Value;
|
||||
typedef typename PropertyList::tag_type Tag;
|
||||
typedef typename build_property_tag_value_alist<NextProperty>::type Next;
|
||||
typedef std::pair< std::pair<Tag,Value>, Next> type;
|
||||
};
|
||||
template <>
|
||||
struct build_property_tag_value_alist<no_property>
|
||||
{
|
||||
typedef no_property type;
|
||||
};
|
||||
|
||||
#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
template <class TagValueAList, class Tag>
|
||||
struct extract_value {
|
||||
typedef error_property_not_found type;
|
||||
};
|
||||
template <class Value, class Tag1, class Tag2, class Rest>
|
||||
struct extract_value< std::pair<std::pair<Tag1,Value>,Rest>, Tag2> {
|
||||
typedef typename extract_value<Rest,Tag2>::type type;
|
||||
};
|
||||
template <class Value, class Tag, class Rest>
|
||||
struct extract_value< std::pair<std::pair<Tag,Value>,Rest>, Tag> {
|
||||
typedef Value type;
|
||||
};
|
||||
#else
|
||||
// VC++ workaround:
|
||||
// The main idea here is to replace partial specialization with
|
||||
// nested template member classes. Of course there is the
|
||||
// further complication that the outer class of the nested
|
||||
// template class cannot itself be a template class.
|
||||
// Hence the need for the ev_selector. -JGS
|
||||
|
||||
struct recursive_extract;
|
||||
struct end_extract;
|
||||
|
||||
template <class TagValueAList>
|
||||
struct ev_selector { typedef recursive_extract type; };
|
||||
template <>
|
||||
struct ev_selector<no_property> { typedef end_extract type; };
|
||||
|
||||
struct recursive_extract {
|
||||
template <class TagValueAList, class Tag1>
|
||||
struct bind_ {
|
||||
typedef typename TagValueAList::first_type AListFirst;
|
||||
typedef typename AListFirst::first_type Tag2;
|
||||
typedef typename AListFirst::second_type Value;
|
||||
enum { match = same_property<Tag1,Tag2>::value };
|
||||
typedef typename TagValueAList::second_type Next;
|
||||
typedef typename ev_selector<Next>::type Extractor;
|
||||
typedef typename boost::ct_if< match, Value,
|
||||
typename Extractor::template bind_<Next,Tag1>::type
|
||||
>::type type;
|
||||
};
|
||||
};
|
||||
struct end_extract {
|
||||
template <class AList, class Tag1>
|
||||
struct bind_ {
|
||||
typedef error_property_not_found type;
|
||||
};
|
||||
};
|
||||
#endif //!defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
} // namespace detail
|
||||
} // namespace boost
|
||||
|
||||
|
||||
@@ -7,32 +7,146 @@
|
||||
#define BOOST_PROPERTY_HPP
|
||||
|
||||
#include <boost/mpl/bool.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/type_traits.hpp>
|
||||
|
||||
namespace boost {
|
||||
|
||||
struct no_property {
|
||||
typedef no_property tag_type;
|
||||
typedef no_property next_type;
|
||||
typedef no_property value_type;
|
||||
enum { num = 0 };
|
||||
typedef void kind;
|
||||
};
|
||||
struct no_property {};
|
||||
|
||||
template <class Tag, class T, class Base = no_property>
|
||||
struct property : public Base {
|
||||
struct property {
|
||||
typedef Base next_type;
|
||||
typedef Tag tag_type;
|
||||
typedef T value_type;
|
||||
#if BOOST_WORKAROUND (__GNUC__, < 3)
|
||||
property() { }
|
||||
#else
|
||||
property() : m_value() { }
|
||||
#endif
|
||||
property(const T& v) : m_value(v) { }
|
||||
property(const T& v, const Base& b) : Base(b), m_value(v) { }
|
||||
property(const T& v = T()) : m_value(v) { }
|
||||
property(const T& v, const Base& b) : m_value(v), m_base(b) { }
|
||||
// copy constructor and assignment operator will be generated by compiler
|
||||
|
||||
T m_value;
|
||||
Base m_base;
|
||||
};
|
||||
|
||||
// Kinds of properties
|
||||
template <class PropertyTag>
|
||||
struct property_kind {
|
||||
typedef typename PropertyTag::kind type;
|
||||
};
|
||||
|
||||
// Some standard properties defined independently of Boost.Graph:
|
||||
enum vertex_all_t {vertex_all};
|
||||
enum edge_all_t {edge_all};
|
||||
enum graph_all_t {graph_all};
|
||||
enum vertex_bundle_t {vertex_bundle};
|
||||
enum edge_bundle_t {edge_bundle};
|
||||
enum graph_bundle_t {graph_bundle};
|
||||
|
||||
// Code to look up one property in a property list:
|
||||
template <typename PList, typename PropName>
|
||||
struct lookup_one_property_internal {BOOST_STATIC_CONSTANT(bool, found = false);};
|
||||
|
||||
// Special-case properties (vertex_all, edge_all, graph_all)
|
||||
#define BGL_ALL_PROP(tag) \
|
||||
template <typename T> \
|
||||
struct lookup_one_property_internal<T, tag> { \
|
||||
BOOST_STATIC_CONSTANT(bool, found = true); \
|
||||
typedef T type; \
|
||||
static T& lookup(T& x, tag) {return x;} \
|
||||
static const T& lookup(const T& x, tag) {return x;} \
|
||||
}; \
|
||||
template <typename Tag, typename T, typename Base> \
|
||||
struct lookup_one_property_internal<property<Tag, T, Base>, tag> { /* Avoid ambiguity */ \
|
||||
BOOST_STATIC_CONSTANT(bool, found = true); \
|
||||
typedef property<Tag, T, Base> type; \
|
||||
static type& lookup(type& x, tag) {return x;} \
|
||||
static const type& lookup(const type& x, tag) {return x;} \
|
||||
};
|
||||
|
||||
BGL_ALL_PROP(vertex_all_t)
|
||||
BGL_ALL_PROP(edge_all_t)
|
||||
BGL_ALL_PROP(graph_all_t)
|
||||
#undef BGL_ALL_PROP
|
||||
|
||||
// *_bundled; these need to be macros rather than inheritance to resolve ambiguities
|
||||
#define BGL_DO_ONE_BUNDLE_TYPE(kind) \
|
||||
template <typename T> \
|
||||
struct lookup_one_property_internal<T, BOOST_JOIN(kind, _bundle_t)> { \
|
||||
BOOST_STATIC_CONSTANT(bool, found = true); \
|
||||
typedef T type; \
|
||||
static T& lookup(T& x, BOOST_JOIN(kind, _bundle_t)) {return x;} \
|
||||
static const T& lookup(const T& x, BOOST_JOIN(kind, _bundle_t)) {return x;} \
|
||||
}; \
|
||||
\
|
||||
template <typename Tag, typename T, typename Base> \
|
||||
struct lookup_one_property_internal<property<Tag, T, Base>, BOOST_JOIN(kind, _bundle_t)>: lookup_one_property_internal<Base, BOOST_JOIN(kind, _bundle_t)> { \
|
||||
private: \
|
||||
typedef lookup_one_property_internal<Base, BOOST_JOIN(kind, _bundle_t)> base_type; \
|
||||
public: \
|
||||
static typename base_type::type& lookup(property<Tag, T, Base>& p, BOOST_JOIN(kind, _bundle_t)) {return base_type::lookup(p.m_base, BOOST_JOIN(kind, _bundle_t)());} \
|
||||
static const typename base_type::type& lookup(const property<Tag, T, Base>& p, BOOST_JOIN(kind, _bundle_t)) {return base_type::lookup(p.m_base, BOOST_JOIN(kind, _bundle_t)());} \
|
||||
}; \
|
||||
|
||||
BGL_DO_ONE_BUNDLE_TYPE(vertex)
|
||||
BGL_DO_ONE_BUNDLE_TYPE(edge)
|
||||
BGL_DO_ONE_BUNDLE_TYPE(graph)
|
||||
#undef BGL_DO_ONE_BUNDLE_TYPE
|
||||
|
||||
// Normal old-style properties; second case also handles chaining of bundled property accesses
|
||||
template <typename Tag, typename T, typename Base>
|
||||
struct lookup_one_property_internal<boost::property<Tag, T, Base>, Tag> {
|
||||
BOOST_STATIC_CONSTANT(bool, found = true);
|
||||
typedef property<Tag, T, Base> prop;
|
||||
typedef T type;
|
||||
template <typename U>
|
||||
static typename enable_if<is_same<prop, U>, T&>::type
|
||||
lookup(U& prop, const Tag&) {return prop.m_value;}
|
||||
template <typename U>
|
||||
static typename enable_if<is_same<prop, U>, const T&>::type
|
||||
lookup(const U& prop, const Tag&) {return prop.m_value;}
|
||||
};
|
||||
|
||||
template <typename Tag, typename T, typename Base, typename PropName>
|
||||
struct lookup_one_property_internal<boost::property<Tag, T, Base>, PropName>: lookup_one_property_internal<Base, PropName> {
|
||||
private:
|
||||
typedef lookup_one_property_internal<Base, PropName> base_type;
|
||||
public:
|
||||
template <typename PL>
|
||||
static typename enable_if<is_same<PL, boost::property<Tag, T, Base> >, typename base_type::type&>::type
|
||||
lookup(PL& prop, const PropName& tag) {
|
||||
return base_type::lookup(prop.m_base, tag);
|
||||
}
|
||||
template <typename PL>
|
||||
static typename enable_if<is_same<PL, boost::property<Tag, T, Base> >, const typename base_type::type&>::type
|
||||
lookup(const PL& prop, const PropName& tag) {
|
||||
return base_type::lookup(prop.m_base, tag);
|
||||
}
|
||||
};
|
||||
|
||||
// Pointer-to-member access to bundled properties
|
||||
#ifndef BOOST_GRAPH_NO_BUNDLED_PROPERTIES
|
||||
template <typename T, typename R>
|
||||
struct lookup_one_property_internal<T, R T::*> {
|
||||
BOOST_STATIC_CONSTANT(bool, found = true);
|
||||
typedef R type;
|
||||
static R& lookup(T& x, R T::*ptr) {return x.*ptr;}
|
||||
static const R& lookup(const T& x, R T::*ptr) {return x.*ptr;}
|
||||
};
|
||||
#endif
|
||||
|
||||
// Version of above handling const property lists properly
|
||||
template <typename T, typename Tag>
|
||||
struct lookup_one_property: lookup_one_property_internal<T, Tag> {};
|
||||
|
||||
template <typename T, typename Tag>
|
||||
struct lookup_one_property<const T, Tag> {
|
||||
BOOST_STATIC_CONSTANT(bool, found = (lookup_one_property_internal<T, Tag>::found));
|
||||
typedef const typename lookup_one_property_internal<T, Tag>::type type;
|
||||
template <typename U>
|
||||
static typename enable_if<is_same<T, U>, const typename lookup_one_property_internal<T, Tag>::type&>::type
|
||||
lookup(const U& p, Tag tag) {
|
||||
return lookup_one_property_internal<T, Tag>::lookup(p, tag);
|
||||
}
|
||||
};
|
||||
|
||||
// The BGL properties specialize property_kind and
|
||||
@@ -41,11 +155,6 @@ namespace boost {
|
||||
// instead with a nested kind type and num. Also, we may want to
|
||||
// switch BGL back to using class types for properties at some point.
|
||||
|
||||
template <class PropertyTag>
|
||||
struct property_kind {
|
||||
typedef typename PropertyTag::kind type;
|
||||
};
|
||||
|
||||
template <class P>
|
||||
struct has_property : boost::mpl::true_ {};
|
||||
template <>
|
||||
@@ -58,45 +167,18 @@ namespace boost {
|
||||
namespace boost {
|
||||
|
||||
template <class PropertyList, class Tag>
|
||||
struct property_value {
|
||||
#if !defined BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
typedef typename detail::build_property_tag_value_alist<PropertyList>::type AList;
|
||||
typedef typename detail::extract_value<AList,Tag>::type type;
|
||||
#else
|
||||
typedef typename detail::build_property_tag_value_alist<PropertyList>::type AList;
|
||||
typedef typename detail::ev_selector<AList>::type Extractor;
|
||||
typedef typename Extractor::template bind_<AList,Tag>::type type;
|
||||
#endif
|
||||
};
|
||||
struct property_value: lookup_one_property<PropertyList, Tag> {};
|
||||
|
||||
template <class Tag2>
|
||||
inline detail::error_property_not_found
|
||||
get_property_value(const no_property&, Tag2) {
|
||||
return detail::error_property_not_found();
|
||||
template <class PropertyList, class Tag>
|
||||
inline typename lookup_one_property<PropertyList, Tag>::type&
|
||||
get_property_value(PropertyList& p, Tag tag) {
|
||||
return lookup_one_property<PropertyList, Tag>::lookup(p, tag);
|
||||
}
|
||||
|
||||
template <class Tag1, class Tag2, class T1, class Base>
|
||||
inline typename property_value<property<Tag1,T1,Base>, Tag2>::type&
|
||||
get_property_value(property<Tag1,T1,Base>& p, Tag2 tag2) {
|
||||
BOOST_STATIC_CONSTANT(bool,
|
||||
match = (detail::same_property<Tag1,Tag2>::value));
|
||||
typedef property<Tag1,T1,Base> Prop;
|
||||
typedef typename property_value<Prop, Tag2>::type T2;
|
||||
T2* t2 = 0;
|
||||
typedef detail::property_value_dispatch<match> Dispatcher;
|
||||
return Dispatcher::get_value(p, t2, tag2);
|
||||
}
|
||||
template <class Tag1, class Tag2, class T1, class Base>
|
||||
inline
|
||||
const typename property_value<property<Tag1,T1,Base>, Tag2>::type&
|
||||
get_property_value(const property<Tag1,T1,Base>& p, Tag2 tag2) {
|
||||
BOOST_STATIC_CONSTANT(bool,
|
||||
match = (detail::same_property<Tag1,Tag2>::value));
|
||||
typedef property<Tag1,T1,Base> Prop;
|
||||
typedef typename property_value<Prop, Tag2>::type T2;
|
||||
T2* t2 = 0;
|
||||
typedef detail::property_value_dispatch<match> Dispatcher;
|
||||
return Dispatcher::const_get_value(p, t2, tag2);
|
||||
template <class PropertyList, class Tag>
|
||||
inline const typename lookup_one_property<PropertyList, Tag>::type&
|
||||
get_property_value(const PropertyList& p, Tag tag) {
|
||||
return lookup_one_property<PropertyList, Tag>::lookup(p, tag);
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
@@ -107,7 +189,6 @@ namespace boost {
|
||||
: mpl::bool_<is_same<T, no_property>::value>
|
||||
{ };
|
||||
|
||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
/** @internal @name Retag Property List
|
||||
* This metafunction is used internally to normalize a property if it is
|
||||
* actually modeling a property. Specifically this is used in Boost.Graph
|
||||
@@ -159,7 +240,40 @@ namespace boost {
|
||||
typedef no_property retagged;
|
||||
};
|
||||
//@}
|
||||
#endif
|
||||
|
||||
template <typename PList, typename Tag>
|
||||
class lookup_one_property_f;
|
||||
|
||||
template <typename PList, typename Tag, typename F> struct lookup_one_property_f_result;
|
||||
|
||||
template <typename PList, typename Tag>
|
||||
struct lookup_one_property_f_result<PList, Tag, const lookup_one_property_f<PList, Tag>(PList)> {
|
||||
typedef typename lookup_one_property<PList, Tag>::type type;
|
||||
};
|
||||
|
||||
template <typename PList, typename Tag>
|
||||
struct lookup_one_property_f_result<PList, Tag, const lookup_one_property_f<PList, Tag>(PList&)> {
|
||||
typedef typename lookup_one_property<PList, Tag>::type& type;
|
||||
};
|
||||
|
||||
template <typename PList, typename Tag>
|
||||
struct lookup_one_property_f_result<PList, Tag, const lookup_one_property_f<PList, Tag>(const PList&)> {
|
||||
typedef const typename lookup_one_property<PList, Tag>::type& type;
|
||||
};
|
||||
|
||||
template <typename PList, typename Tag>
|
||||
class lookup_one_property_f {
|
||||
Tag tag;
|
||||
public:
|
||||
lookup_one_property_f(Tag tag): tag(tag) {}
|
||||
template <typename F> struct result: lookup_one_property_f_result<PList, Tag, F> {};
|
||||
|
||||
typename lookup_one_property_f_result<PList, Tag, const lookup_one_property_f(PList&)>::type
|
||||
operator()(PList& pl) const {
|
||||
return lookup_one_property<PList, Tag>::lookup(pl, tag);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namesapce boost
|
||||
|
||||
Reference in New Issue
Block a user