42 #ifndef OPENMESH_PROPERTYCONTAINER
43 #define OPENMESH_PROPERTYCONTAINER
47 #define OM_FORCE_STATIC_CAST
50 #include <OpenMesh/Core/Utils/Property.hh>
67 virtual ~
PropertyContainer() { std::for_each(properties_.begin(), properties_.end(), Delete()); }
72 typedef std::vector<BaseProperty*> Properties;
73 const Properties& properties()
const {
return properties_; }
74 size_t size()
const {
return properties_.size(); }
85 std::for_each(properties_.begin(), properties_.end(), Delete());
86 properties_ = _rhs.properties_;
87 Properties::iterator p_it=properties_.begin(), p_end=properties_.end();
88 for (; p_it!=p_end; ++p_it)
90 *p_it = (*p_it)->clone();
101 Properties::iterator p_it=properties_.begin(), p_end=properties_.end();
103 for ( ; p_it!=p_end && *p_it!=NULL; ++p_it, ++idx ) {};
104 if (p_it==p_end) properties_.push_back(NULL);
113 Properties::const_iterator p_it = properties_.begin();
114 for (
int idx=0; p_it != properties_.end(); ++p_it, ++idx)
117 (*p_it)->name() == _name
119 #ifndef OM_FORCE_STATIC_CAST
120 &&
dynamic_cast<PropertyT<T>*
>(properties_[idx]) != NULL
130 BaseProperty* property(
const std::string& _name )
const
132 Properties::const_iterator p_it = properties_.begin();
133 for (
int idx=0; p_it != properties_.end(); ++p_it, ++idx)
135 if (*p_it != NULL && (*p_it)->name() == _name)
145 assert(_h.
idx() >= 0 && _h.
idx() < (int)properties_.size());
146 assert(properties_[_h.
idx()] != NULL);
147 #ifdef OM_FORCE_STATIC_CAST
159 assert(_h.
idx() >= 0 && _h.
idx() < (int)properties_.size());
160 assert(properties_[_h.
idx()] != NULL);
161 #ifdef OM_FORCE_STATIC_CAST
173 assert(_h.
idx() >= 0 && _h.
idx() < (int)properties_.size());
174 delete properties_[_h.
idx()];
175 properties_[_h.
idx()] = NULL;
190 std::for_each(properties_.begin(), properties_.end(), ClearAll());
196 void reserve(
size_t _n)
const {
197 std::for_each(properties_.begin(), properties_.end(), Reserve(_n));
200 void resize(
size_t _n)
const {
201 std::for_each(properties_.begin(), properties_.end(), Resize(_n));
204 void swap(
size_t _i0,
size_t _i1)
const {
205 std::for_each(properties_.begin(), properties_.end(), Swap(_i0, _i1));
214 Properties::iterator p_it=properties_.begin(), p_end=properties_.end();
216 for (; p_it!=p_end && *p_it!=NULL; ++p_it, ++idx) {};
217 if (p_it==p_end) properties_.push_back(NULL);
218 properties_[idx] = _bp;
224 assert( _idx < properties_.size());
225 assert( properties_[_idx] != NULL);
233 assert( _idx < properties_.size());
234 assert( properties_[_idx] != NULL);
241 typedef Properties::iterator iterator;
242 typedef Properties::const_iterator const_iterator;
243 iterator begin() {
return properties_.begin(); }
244 iterator end() {
return properties_.end(); }
245 const_iterator begin()
const {
return properties_.begin(); }
246 const_iterator end()
const {
return properties_.end(); }
254 #ifndef DOXY_IGNORE_THIS
257 Reserve(
size_t _n) : n_(_n) {}
264 Resize(
size_t _n) : n_(_n) {}
277 Swap(
size_t _i0,
size_t _i1) : i0_(_i0), i1_(_i1) {}
285 void operator()(
BaseProperty* _p)
const {
if (_p)
delete _p; _p=NULL; }
289 Properties properties_;
294 #endif//OPENMESH_PROPERTYCONTAINER
virtual void swap(size_t _i0, size_t _i1)=0
Let two elements swap their storage place.
Abstract class defining the basic interface of a dynamic property.
Definition: BaseProperty.hh:58
int idx() const
Get the underlying index of this handle.
Definition: Handles.hh:67
virtual void resize(size_t _n)=0
Resize storage to hold n elements.
virtual void clear()=0
Clear all elements and free memory.
virtual void reserve(size_t _n)=0
Reserve memory for n elements.
Default property class for any type T.
Definition: Property.hh:87
A a container for properties.
Definition: PropertyContainer.hh:60
This class provides the basic property management like adding/removing properties and access to prope...
Definition: BaseKernel.hh:91
Base property handle.
Definition: Property.hh:460