Developer Documentation
OpenMesh::PropertyT< T > Class Template Reference

Default property class for any type T. More...

#include <OpenMesh/Core/Utils/PropertyT.hh>

Inheritance diagram for OpenMesh::PropertyT< T >:
OpenMesh::BaseProperty

Public Types

typedef T Value
 
typedef std::vector< T > vector_type
 
typedef T value_type
 
typedef vector_type::reference reference
 
typedef vector_type::const_reference const_reference
 

Public Member Functions

 PropertyT (const std::string &_name="<unknown>", const std::string &_internal_type_name="<unknown>")
 Default constructor. More...
 
 PropertyT (const PropertyT &_rhs)
 Copy constructor. More...
 
virtual void reserve (size_t _n) override
 Reserve memory for n elements. More...
 
virtual void resize (size_t _n) override
 Resize storage to hold n elements. More...
 
virtual void clear () override
 Clear all elements and free memory. More...
 
virtual void push_back () override
 Extend the number of elements by one. More...
 
virtual void swap (size_t _i0, size_t _i1) override
 Let two elements swap their storage place. More...
 
virtual void copy (size_t _i0, size_t _i1) override
 Copy one element to another. More...
 
virtual void set_persistent (bool _yn) override
 
virtual size_t n_elements () const override
 Number of elements in property. More...
 
virtual size_t element_size () const override
 Size of one element in bytes or UnknownSize if not known. More...
 
virtual size_t size_of (void) const override
 Return size of property in bytes. More...
 
virtual size_t size_of (size_t _n_elem) const override
 
virtual size_t store (std::ostream &_ostr, bool _swap) const override
 Store self as one binary block. More...
 
virtual size_t restore (std::istream &_istr, bool _swap) override
 
const T * data () const
 Get pointer to array (does not work for T==bool) More...
 
vector_type & data_vector ()
 Get reference to property vector (be careful, improper usage, e.g. resizing, may crash OpenMesh!!!) More...
 
const vector_type & data_vector () const
 Const access to property vector. More...
 
reference operator[] (int _idx)
 Access the i'th element. No range check is performed! More...
 
const_reference operator[] (int _idx) const
 Const access to the i'th element. No range check is performed! More...
 
PropertyT< T > * clone () const override
 Make a copy of self. More...
 
std::string get_storage_name () const override
 returns a unique string for the type of the elements More...
 
- Public Member Functions inherited from OpenMesh::BaseProperty
 BaseProperty (const std::string &_name="<unknown>", const std::string &_internal_type_name="<unknown>")
 Default constructor. More...
 
 BaseProperty (const BaseProperty &_rhs)
 Copy constructor. More...
 
virtual ~BaseProperty ()
 Destructor. More...
 
virtual void reserve (size_t _n)=0
 Reserve memory for n elements. More...
 
virtual void resize (size_t _n)=0
 Resize storage to hold n elements. More...
 
virtual void clear ()=0
 Clear all elements and free memory. More...
 
virtual void push_back ()=0
 Extend the number of elements by one. More...
 
virtual void swap (size_t _i0, size_t _i1)=0
 Let two elements swap their storage place. More...
 
virtual void copy (size_t _io, size_t _i1)=0
 Copy one element to another. More...
 
virtual BasePropertyclone () const =0
 Return a deep copy of self. More...
 
const std::string & name () const
 Return the name of the property. More...
 
const std::string & internal_type_name () const
 Return internal type name of the property for type safe casting alternative to runtime information. More...
 
virtual void stats (std::ostream &_ostr) const
 
bool persistent (void) const
 Returns true if the persistent flag is enabled else false. More...
 
virtual void set_persistent (bool _yn)=0
 
virtual std::string get_storage_name () const =0
 returns a unique string for the type of the elements More...
 
virtual size_t n_elements () const =0
 Number of elements in property. More...
 
virtual size_t element_size () const =0
 Size of one element in bytes or UnknownSize if not known. More...
 
virtual size_t size_of () const
 Return size of property in bytes. More...
 
virtual size_t size_of (size_t _n_elem) const
 
virtual size_t store (std::ostream &_ostr, bool _swap) const =0
 Store self as one binary block. More...
 
virtual size_t restore (std::istream &_istr, bool _swap)=0
 

Private Attributes

vector_type data_
 

Additional Inherited Members

- Static Public Attributes inherited from OpenMesh::BaseProperty
static const size_t UnknownSize = size_t(-1)
 Indicates an error when a size is returned by a member. More...
 
- Protected Member Functions inherited from OpenMesh::BaseProperty
template<typename T >
void check_and_set_persistent (bool _yn)
 

Detailed Description

template<class T>
class OpenMesh::PropertyT< T >

Default property class for any type T.

The default property class for any type T.

The property supports persistency if T is a "fundamental" type:

  • integer fundamental types except bool: char, short, int, long, long long (__int64 for MS VC++) and their unsigned companions.
  • float fundamentals except long double: float, double
  • OpenMesh vector types

Persistency of non-fundamental types is supported if and only if a specialization of struct IO::binary<> exists for the wanted type.

Definition at line 92 of file Property.hh.

Member Typedef Documentation

◆ const_reference

template<class T >
typedef vector_type::const_reference OpenMesh::PropertyT< T >::const_reference

Definition at line 100 of file Property.hh.

◆ reference

template<class T >
typedef vector_type::reference OpenMesh::PropertyT< T >::reference

Definition at line 99 of file Property.hh.

◆ Value

template<class T >
typedef T OpenMesh::PropertyT< T >::Value

Definition at line 96 of file Property.hh.

◆ value_type

template<class T >
typedef T OpenMesh::PropertyT< T >::value_type

Definition at line 98 of file Property.hh.

◆ vector_type

template<class T >
typedef std::vector<T> OpenMesh::PropertyT< T >::vector_type

Definition at line 97 of file Property.hh.

Constructor & Destructor Documentation

◆ PropertyT() [1/2]

template<class T >
OpenMesh::PropertyT< T >::PropertyT ( const std::string &  _name = "<unknown>",
const std::string &  _internal_type_name = "<unknown>" 
)
inlineexplicit

Default constructor.

Definition at line 105 of file Property.hh.

◆ PropertyT() [2/2]

template<class T >
OpenMesh::PropertyT< T >::PropertyT ( const PropertyT< T > &  _rhs)
inline

Copy constructor.

Definition at line 112 of file Property.hh.

Member Function Documentation

◆ clear()

template<class T >
virtual void OpenMesh::PropertyT< T >::clear ( )
inlineoverridevirtual

Clear all elements and free memory.

Implements OpenMesh::BaseProperty.

Definition at line 119 of file Property.hh.

◆ clone()

template<class T >
PropertyT< T > * OpenMesh::PropertyT< T >::clone ( ) const
inlineoverridevirtual

Make a copy of self.

Implements OpenMesh::BaseProperty.

Definition at line 209 of file Property.hh.

◆ copy()

template<class T >
virtual void OpenMesh::PropertyT< T >::copy ( size_t  _io,
size_t  _i1 
)
inlineoverridevirtual

Copy one element to another.

Implements OpenMesh::BaseProperty.

Definition at line 123 of file Property.hh.

◆ data()

template<class T >
const T * OpenMesh::PropertyT< T >::data ( ) const
inline

Get pointer to array (does not work for T==bool)

Definition at line 176 of file Property.hh.

◆ data_vector() [1/2]

template<class T >
vector_type & OpenMesh::PropertyT< T >::data_vector ( )
inline

Get reference to property vector (be careful, improper usage, e.g. resizing, may crash OpenMesh!!!)

Definition at line 185 of file Property.hh.

◆ data_vector() [2/2]

template<class T >
const vector_type & OpenMesh::PropertyT< T >::data_vector ( ) const
inline

Const access to property vector.

Definition at line 190 of file Property.hh.

◆ element_size()

template<class T >
virtual size_t OpenMesh::PropertyT< T >::element_size ( ) const
inlineoverridevirtual

Size of one element in bytes or UnknownSize if not known.

Implements OpenMesh::BaseProperty.

Definition at line 132 of file Property.hh.

◆ get_storage_name()

template<class T >
std::string OpenMesh::PropertyT< T >::get_storage_name ( ) const
inlineoverridevirtual

returns a unique string for the type of the elements

Implements OpenMesh::BaseProperty.

Definition at line 215 of file Property.hh.

◆ n_elements()

template<class T >
virtual size_t OpenMesh::PropertyT< T >::n_elements ( ) const
inlineoverridevirtual

Number of elements in property.

Implements OpenMesh::BaseProperty.

Definition at line 131 of file Property.hh.

◆ operator[]() [1/2]

template<class T >
reference OpenMesh::PropertyT< T >::operator[] ( int  _idx)
inline

Access the i'th element. No range check is performed!

Definition at line 195 of file Property.hh.

◆ operator[]() [2/2]

template<class T >
const_reference OpenMesh::PropertyT< T >::operator[] ( int  _idx) const
inline

Const access to the i'th element. No range check is performed!

Definition at line 202 of file Property.hh.

◆ push_back()

template<class T >
virtual void OpenMesh::PropertyT< T >::push_back ( )
inlineoverridevirtual

Extend the number of elements by one.

Implements OpenMesh::BaseProperty.

Definition at line 120 of file Property.hh.

◆ reserve()

template<class T >
virtual void OpenMesh::PropertyT< T >::reserve ( size_t  _n)
inlineoverridevirtual

Reserve memory for n elements.

Implements OpenMesh::BaseProperty.

Definition at line 117 of file Property.hh.

◆ resize()

template<class T >
virtual void OpenMesh::PropertyT< T >::resize ( size_t  _n)
inlineoverridevirtual

Resize storage to hold n elements.

Implements OpenMesh::BaseProperty.

Definition at line 118 of file Property.hh.

◆ restore()

template<class T >
virtual size_t OpenMesh::PropertyT< T >::restore ( std::istream &  _istr,
bool  _swap 
)
inlineoverridevirtual

Restore self from a binary block. Uses reserve() to set the size of self before restoring.

Implements OpenMesh::BaseProperty.

Definition at line 162 of file Property.hh.

◆ set_persistent()

template<class T >
virtual void OpenMesh::PropertyT< T >::set_persistent ( bool  _yn)
inlineoverridevirtual

Enable or disable persistency. Self must be a named property to enable persistency.

Implements OpenMesh::BaseProperty.

Definition at line 128 of file Property.hh.

◆ size_of() [1/2]

template<class T >
virtual size_t OpenMesh::PropertyT< T >::size_of ( size_t  _n_elem) const
inlineoverridevirtual

Estimated size of property if it has _n_elem elements. The member returns UnknownSize if the size cannot be estimated.

Reimplemented from OpenMesh::BaseProperty.

Definition at line 148 of file Property.hh.

◆ size_of() [2/2]

template<class T >
virtual size_t OpenMesh::PropertyT< T >::size_of ( void  ) const
inlineoverridevirtual

Return size of property in bytes.

Reimplemented from OpenMesh::BaseProperty.

Definition at line 141 of file Property.hh.

◆ store()

template<class T >
virtual size_t OpenMesh::PropertyT< T >::store ( std::ostream &  _ostr,
bool  _swap 
) const
inlineoverridevirtual

Store self as one binary block.

Implements OpenMesh::BaseProperty.

Definition at line 151 of file Property.hh.

◆ swap()

template<class T >
virtual void OpenMesh::PropertyT< T >::swap ( size_t  _i0,
size_t  _i1 
)
inlineoverridevirtual

Let two elements swap their storage place.

Implements OpenMesh::BaseProperty.

Definition at line 121 of file Property.hh.

Member Data Documentation

◆ data_

template<class T >
vector_type OpenMesh::PropertyT< T >::data_
private

Definition at line 222 of file Property.hh.


The documentation for this class was generated from the following file: