42 #ifndef OPENMESH_BASEPROPERTY_HH
43 #define OPENMESH_BASEPROPERTY_HH
46 #include <OpenMesh/Core/IO/StoreRestore.hh>
63 static const size_t UnknownSize = size_t(-1);
82 : name_(_name), persistent_(false)
87 : name_( _rhs.name_ ), persistent_( _rhs.persistent_ ) {}
95 virtual void reserve(
size_t _n) = 0;
98 virtual void resize(
size_t _n) = 0;
101 virtual void clear() = 0;
104 virtual void push_back() = 0;
107 virtual void swap(
size_t _i0,
size_t _i1) = 0;
110 virtual void copy(
size_t _io,
size_t _i1) = 0;
118 const std::string&
name()
const {
return name_; }
120 virtual void stats(std::ostream& _ostr)
const;
129 virtual void set_persistent(
bool _yn ) = 0;
132 virtual size_t n_elements()
const = 0;
135 virtual size_t element_size()
const = 0;
140 return size_of( n_elements() );
147 return (element_size()!=UnknownSize)
148 ? (_n_elem*element_size())
153 virtual size_t store( std::ostream& _ostr,
bool _swap )
const = 0;
158 virtual size_t restore( std::istream& _istr,
bool _swap ) = 0;
163 template <
typename T >
164 void check_and_set_persistent(
bool _yn )
166 if ( _yn && !IO::is_streamable<T>() )
167 omerr() <<
"Warning! Type of property value is not binary storable!\n";
168 persistent_ = IO::is_streamable<T>() && _yn;
179 #endif //OPENMESH_BASEPROPERTY_HH
This file provides the streams omlog, omout, and omerr.
virtual size_t size_of(size_t _n_elem) const
Estimated size of property if it has _n_elem elements.
Definition: BaseProperty.hh:145
BaseProperty(const BaseProperty &_rhs)
Copy constructor.
Definition: BaseProperty.hh:86
virtual ~BaseProperty()
Destructor.
Definition: BaseProperty.hh:90
Abstract class defining the basic interface of a dynamic property.
Definition: BaseProperty.hh:58
const std::string & name() const
Return the name of the property.
Definition: BaseProperty.hh:118
BaseProperty(const std::string &_name="<unknown>")
Default constructor.
Definition: BaseProperty.hh:81
bool persistent(void) const
Returns true if the persistent flag is enabled else false.
Definition: BaseProperty.hh:125
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:56
virtual size_t size_of() const
Return size of property in bytes.
Definition: BaseProperty.hh:138