42 #ifndef PROPERTYMANAGER_HH_
43 #define PROPERTYMANAGER_HH_
68 template<
typename PROPTYPE,
typename MeshT>
96 PropertyManager(MeshT &mesh,
const char *propname,
bool existing =
false) : mesh_(&mesh), retain_(existing) {
98 if (!mesh_->get_property_handle(prop_, propname)) {
99 std::ostringstream oss;
100 oss <<
"Requested property handle \"" << propname <<
"\" does not exist.";
101 throw std::runtime_error(oss.str());
104 mesh_->add_property(prop_, propname);
112 void swap(PropertyManager &rhs) {
113 std::swap(mesh_, rhs.mesh_);
114 std::swap(prop_, rhs.prop_);
115 std::swap(retain_, rhs.retain_);
118 #if __cplusplus > 199711L or __GXX_EXPERIMENTAL_CXX0X__
122 PropertyManager(PropertyManager &&rhs) : mesh_(rhs.mesh_), prop_(rhs.prop_), retain_(rhs.retain_) {
129 PropertyManager &operator=(PropertyManager &&rhs) {
135 retain_ = rhs.retain_;
148 PropertyManager pm(mesh, propname, mesh.get_property_handle(dummy_prop, propname));
150 return std::move(pm);
156 Proxy(MeshT *mesh_, PROPTYPE prop_,
bool retain_) :
157 mesh_(mesh_), prop_(prop_), retain_(retain_) {}
166 Proxy p(mesh_, prop_, retain_);
172 PropertyManager(Proxy p) : mesh_(p.mesh_), prop_(p.prop_), retain_(p.retain_) {}
174 PropertyManager &operator=(Proxy p) {
175 PropertyManager(p).swap(*
this);
186 PropertyManager pm(mesh, propname, mesh.get_property_handle(dummy_prop, propname));
198 inline void retain(
bool doRetain =
true) {
223 template<
typename HandleType>
224 inline typename PROPTYPE::reference
operator[] (
const HandleType &handle) {
225 return mesh_->property(prop_, handle);
235 template<
typename HandleType>
236 inline typename PROPTYPE::const_reference
operator[] (
const HandleType &handle)
const {
237 return mesh_->property(prop_, handle);
241 void deleteProperty() {
243 mesh_->remove_property(prop_);