49 #ifndef OPENMESH_BASEPROPERTY_HH 50 #define OPENMESH_BASEPROPERTY_HH 53 #include <OpenMesh/Core/IO/StoreRestore.hh> 70 static const size_t UnknownSize = size_t(-1);
89 : name_(_name), persistent_(false)
94 : name_( _rhs.name_ ), persistent_( _rhs.persistent_ ) {}
102 virtual void reserve(
size_t _n) = 0;
105 virtual void resize(
size_t _n) = 0;
108 virtual void clear() = 0;
111 virtual void push_back() = 0;
114 virtual void swap(
size_t _i0,
size_t _i1) = 0;
117 virtual void copy(
size_t _io,
size_t _i1) = 0;
125 const std::string&
name()
const {
return name_; }
127 virtual void stats(std::ostream& _ostr)
const;
136 virtual void set_persistent(
bool _yn ) = 0;
139 virtual size_t n_elements()
const = 0;
142 virtual size_t element_size()
const = 0;
147 return size_of( n_elements() );
154 return (element_size()!=UnknownSize)
155 ? (_n_elem*element_size())
160 virtual size_t store( std::ostream& _ostr,
bool _swap )
const = 0;
165 virtual size_t restore( std::istream& _istr,
bool _swap ) = 0;
170 template <
typename T >
171 void check_and_set_persistent(
bool _yn )
173 if ( _yn && !IO::is_streamable<T>() )
174 omerr() <<
"Warning! Type of property value is not binary storable!\n";
175 persistent_ = IO::is_streamable<T>() && _yn;
186 #endif //OPENMESH_BASEPROPERTY_HH bool persistent(void) const
Returns true if the persistent flag is enabled else false.
virtual size_t size_of() const
Return size of property in bytes.
virtual size_t size_of(size_t _n_elem) const
BaseProperty(const BaseProperty &_rhs)
Copy constructor.
const std::string & name() const
Return the name of the property.
virtual ~BaseProperty()
Destructor.
BaseProperty(const std::string &_name="<unknown>")
Default constructor.