/usr/include/CGAL/Dynamic_property_map.h is in libcgal-dev 4.11-2build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | // Copyright (c) 2007 GeometryFactory (France). All rights reserved.
//
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 3 of the License,
// or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
//
//
// Author(s) : Andreas Fabri
#ifndef CGAL_DYNAMIC_PROPERTY_MAP_H
#define CGAL_DYNAMIC_PROPERTY_MAP_H
#include <boost/graph/graph_traits.hpp>
#include <CGAL/boost/graph/properties.h>
#include <CGAL/property_map.h>
#include <boost/shared_ptr.hpp>
#include <boost/unordered_map.hpp>
namespace CGAL {
namespace internal {
template <typename K, typename V>
struct Dynamic_property_map {
typedef K key_type;
typedef V value_type;
typedef const value_type& reference;
typedef boost::read_write_property_map_tag category;
Dynamic_property_map(const V& default_value = V())
: map_(new Map()), default_value_(default_value)
{}
void clear()
{
if(map_){
map_->clear();
}
}
friend reference get(const Dynamic_property_map& m, const key_type& k)
{
typename Map::const_iterator it = m.map_->find(k);
if(it == m.map_->end()){
return m.default_value();
}
return it->second;
}
friend void put(Dynamic_property_map& m, const key_type& k, const value_type& v)
{
if(v != m.default_value()){
(*(m.map_))[k] = v;
}
}
const V& default_value() const
{
return default_value_;
}
typedef boost::unordered_map<K,V> Map;
boost::shared_ptr<Map> map_;
V default_value_;
};
template <typename T>
struct vertex_property_t
{
vertex_property_t(const std::string s, const T& t = T())
: s(s), t(t)
{}
std::string s;
T t;
};
template <typename T>
struct halfedge_property_t
{
halfedge_property_t(const std::string s, const T& t = T())
: s(s), t(t)
{}
std::string s;
T t;
};
template <typename T>
struct edge_property_t
{
edge_property_t(const std::string s, const T& t = T())
: s(s), t(t)
{}
std::string s;
T t;
};
template <typename T>
struct face_property_t
{
face_property_t(const std::string s, const T& t = T())
: s(s), t(t)
{}
std::string s;
T t;
};
template <typename G, typename Tag>
struct dynamic_property_map{};
template <typename G, typename T>
struct dynamic_property_map<G,vertex_property_t<T> >
{
typedef typename boost::graph_traits<G>::vertex_descriptor vertex_descriptor;
typedef CGAL::internal::Dynamic_property_map<vertex_descriptor,T> type;
typedef type const_type;
};
template <typename G, typename T>
struct dynamic_property_map<G,halfedge_property_t<T> >
{
typedef typename boost::graph_traits<G>::halfedge_descriptor halfedge_descriptor;
typedef CGAL::internal::Dynamic_property_map<halfedge_descriptor,T> type;
typedef type const_type;
};
template <typename G, typename T>
struct dynamic_property_map<G,edge_property_t<T> >
{
typedef typename boost::graph_traits<G>::edge_descriptor edge_descriptor;
typedef CGAL::internal::Dynamic_property_map<edge_descriptor,T> type;
typedef type const_type;
};
template <typename G, typename T>
struct dynamic_property_map<G,face_property_t<T> >
{
typedef typename boost::graph_traits<G>::face_descriptor face_descriptor;
typedef CGAL::internal::Dynamic_property_map<face_descriptor,T> type;
typedef type const_type;
};
template <typename T, typename G>
typename dynamic_property_map<G,vertex_property_t<T> >::const_type
add_property(vertex_property_t<T> prop, const G&)
{
typedef typename boost::graph_traits<G>::vertex_descriptor vertex_descriptor;
return internal::Dynamic_property_map<vertex_descriptor,T>(prop.t);
}
template <typename T, typename G>
typename dynamic_property_map<G,halfedge_property_t<T> >::const_type
add_property(halfedge_property_t<T> prop, const G&)
{
typedef typename boost::graph_traits<G>::halfedge_descriptor halfedge_descriptor;
return internal::Dynamic_property_map<halfedge_descriptor,T>(prop.t);
}
template <typename T, typename G>
typename dynamic_property_map<G,edge_property_t<T> >::const_type
add_property(edge_property_t<T> prop, const G&)
{
typedef typename boost::graph_traits<G>::edge_descriptor edge_descriptor;
return internal::Dynamic_property_map<edge_descriptor,T>(prop.t);
}
template <typename T, typename G>
typename dynamic_property_map<G,face_property_t<T> >::const_type
add_property(face_property_t<T> prop, const G&)
{
typedef typename boost::graph_traits<G>::face_descriptor face_descriptor;
return internal::Dynamic_property_map<face_descriptor,T>(prop.t);
}
template<class G, class T, typename Descriptor>
void remove_property(
internal::Dynamic_property_map<Descriptor, T> pm,
const G&)
{
pm.clear();
}
} // namespace internal
} // namespace CGAL
#endif // CGAL_DYNAMIC_PROPERTY_MAP_H
|