44#ifndef OPENMESH_BASEPROPERTY_HH
45#define OPENMESH_BASEPROPERTY_HH
48#include <OpenMesh/Core/IO/StoreRestore.hh>
65 static const size_t UnknownSize = size_t(-1);
84 BaseProperty(
const std::string& _name =
"<unknown>",
const std::string& _internal_type_name =
"<unknown>" )
85 : name_(_name), internal_type_name_(_internal_type_name), persistent_(false)
90 : name_( _rhs.name_ ), internal_type_name_(_rhs.internal_type_name_), persistent_( _rhs.persistent_ ) {}
110 virtual void swap(
size_t _i0,
size_t _i1) = 0;
113 virtual void copy(
size_t _io,
size_t _i1) = 0;
121 const std::string&
name()
const {
return name_; }
126 virtual void stats(std::ostream& _ostr)
const;
149 return size_of( n_elements() );
156 return (element_size()!=UnknownSize)
157 ? (_n_elem*element_size())
162 virtual size_t store( std::ostream& _ostr,
bool _swap )
const = 0;
167 virtual size_t restore( std::istream& _istr,
bool _swap ) = 0;
172 template <
typename T >
173 void check_and_set_persistent(
bool _yn )
175 if ( _yn && !IO::is_streamable<T>() )
176 omerr() <<
"Warning! Type of property value is not binary storable!\n";
177 persistent_ = IO::is_streamable<T>() && _yn;
183 std::string internal_type_name_;
This file provides the streams omlog, omout, and omerr.
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:59
Abstract class defining the basic interface of a dynamic property.
Definition: BaseProperty.hh:61
virtual size_t restore(std::istream &_istr, bool _swap)=0
Restore self from a binary block.
virtual void push_back()=0
Extend the number of elements by one.
BaseProperty(const std::string &_name="<unknown>", const std::string &_internal_type_name="<unknown>")
Default constructor.
Definition: BaseProperty.hh:84
virtual size_t size_of() const
Return size of property in bytes.
Definition: BaseProperty.hh:147
virtual void reserve(size_t _n)=0
Reserve memory for n elements.
bool persistent(void) const
Returns true if the persistent flag is enabled else false.
Definition: BaseProperty.hh:131
virtual void resize(size_t _n)=0
Resize storage to hold n elements.
virtual void swap(size_t _i0, size_t _i1)=0
Let two elements swap their storage place.
virtual void clear()=0
Clear all elements and free memory.
BaseProperty(const BaseProperty &_rhs)
Copy constructor.
Definition: BaseProperty.hh:89
virtual size_t n_elements() const =0
Number of elements in property.
virtual ~BaseProperty()
Destructor.
Definition: BaseProperty.hh:93
virtual void copy(size_t _io, size_t _i1)=0
Copy one element to another.
const std::string & internal_type_name() const
Return internal type name of the property for type safe casting alternative to runtime information.
Definition: BaseProperty.hh:124
virtual size_t store(std::ostream &_ostr, bool _swap) const =0
Store self as one binary block.
virtual size_t size_of(size_t _n_elem) const
Estimated size of property if it has _n_elem elements.
Definition: BaseProperty.hh:154
virtual std::string get_storage_name() const =0
returns a unique string for the type of the elements
virtual size_t element_size() const =0
Size of one element in bytes or UnknownSize if not known.
virtual void set_persistent(bool _yn)=0
Enable or disable persistency.
virtual BaseProperty * clone() const =0
Return a deep copy of self.
const std::string & name() const
Return the name of the property.
Definition: BaseProperty.hh:121