 |
OpenMesh
|
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_ ) {}
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;
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
virtual size_t restore(std::istream &_istr, bool _swap)=0
Restore self from a binary block.
virtual void clear()=0
Clear all elements and free memory.
bool persistent(void) const
Returns true if the persistent flag is enabled else false.
Definition: BaseProperty.hh:132
virtual size_t size_of(size_t _n_elem) const
Estimated size of property if it has _n_elem elements.
Definition: BaseProperty.hh:152
BaseProperty(const std::string &_name="<unknown>")
Default constructor.
Definition: BaseProperty.hh:88
const std::string & name() const
Return the name of the property.
Definition: BaseProperty.hh:125
virtual size_t size_of() const
Return size of property in bytes.
Definition: BaseProperty.hh:145
virtual size_t n_elements() const =0
Number of elements in property.
virtual ~BaseProperty()
Destructor.
Definition: BaseProperty.hh:97
virtual size_t store(std::ostream &_ostr, bool _swap) const =0
Store self as one binary block.
virtual void copy(size_t _io, size_t _i1)=0
Copy one element to another.
Martin, 26.12.2004: 1) replaced resize(size()-1) with pop_back(), since the later is more efficient 2...
Definition: MeshItems.hh:64
virtual size_t element_size() const =0
Size of one element in bytes or UnknownSize if not known.
BaseProperty(const BaseProperty &_rhs)
Copy constructor.
Definition: BaseProperty.hh:93
virtual void resize(size_t _n)=0
Resize storage to hold n elements.
virtual BaseProperty * clone() const =0
Return a deep copy of self.
virtual void push_back()=0
Extend the number of elements by one.
Definition: BaseProperty.hh:66
virtual void reserve(size_t _n)=0
Reserve memory for n elements.
virtual void swap(size_t _i0, size_t _i1)=0
Let two elements swap their storage place.
virtual void set_persistent(bool _yn)=0
Enable or disable persistency.
Project OpenMesh,
© Computer Graphics Group, RWTH Aachen.
Documentation generated using
doxygen
.