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);
83 BaseProperty(
const std::string& _name =
"<unknown>",
const std::string& _internal_type_name =
"<unknown>" )
84 : name_(_name), internal_type_name_(_internal_type_name), persistent_(false)
89 : name_( _rhs.name_ ), internal_type_name_(_rhs.internal_type_name_), persistent_( _rhs.persistent_ ) {}
97 virtual void reserve(
size_t _n) = 0;
100 virtual void resize(
size_t _n) = 0;
103 virtual void clear() = 0;
106 virtual void push_back() = 0;
109 virtual void swap(
size_t _i0,
size_t _i1) = 0;
112 virtual void copy(
size_t _io,
size_t _i1) = 0;
120 const std::string&
name()
const {
return name_; }
125 virtual void stats(std::ostream& _ostr)
const;
134 virtual void set_persistent(
bool _yn ) = 0;
137 virtual size_t n_elements()
const = 0;
140 virtual size_t element_size()
const = 0;
145 return size_of( n_elements() );
152 return (element_size()!=UnknownSize)
153 ? (_n_elem*element_size())
158 virtual size_t store( std::ostream& _ostr,
bool _swap )
const = 0;
163 virtual size_t restore( std::istream& _istr,
bool _swap ) = 0;
168 template <
typename T >
169 void check_and_set_persistent(
bool _yn )
171 if ( _yn && !IO::is_streamable<T>() )
172 omerr() <<
"Warning! Type of property value is not binary storable!\n";
173 persistent_ = IO::is_streamable<T>() && _yn;
179 std::string internal_type_name_;
185 #endif //OPENMESH_BASEPROPERTY_HH Abstract class defining the basic interface of a dynamic property.
Definition: BaseProperty.hh:60
bool persistent(void) const
Returns true if the persistent flag is enabled else false.
Definition: BaseProperty.hh:130
BaseProperty(const std::string &_name="<unknown>", const std::string &_internal_type_name="<unknown>")
Default constructor.
Definition: BaseProperty.hh:83
virtual ~BaseProperty()
Destructor.
Definition: BaseProperty.hh:92
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:123
This file provides the streams omlog, omout, and omerr.
const std::string & name() const
Return the name of the property.
Definition: BaseProperty.hh:120
virtual size_t size_of() const
Return size of property in bytes.
Definition: BaseProperty.hh:143
virtual size_t size_of(size_t _n_elem) const
Estimated size of property if it has _n_elem elements.
Definition: BaseProperty.hh:150
BaseProperty(const BaseProperty &_rhs)
Copy constructor.
Definition: BaseProperty.hh:88
Contains all the mesh ingredients like the polygonal mesh, the triangle mesh, different mesh kernels ...
Definition: MeshItems.hh:59