Easy3D 2.6.1
Loading...
Searching...
No Matches
PropertyArray< T > Class Template Reference

Implementation of a generic property array. More...

#include <easy3d/core/property.h>

Inheritance diagram for PropertyArray< T >:
BasePropertyArray

Public Types

typedef T value_type
 The value type of the property.
 
typedef std::vector< value_typevector_type
 The vector type of the property.
 
typedef vector_type::reference reference
 The reference type of the property.
 
typedef vector_type::const_reference const_reference
 The const reference type of the property.
 

Public Member Functions

 PropertyArray (const std::string &name, T t=T())
 Constructor.
 
void reserve (size_t n) override
 Reserves memory for n elements.
 
void resize (size_t n) override
 Resizes storage to hold n elements.
 
void push_back () override
 Extend the number of elements by one.
 
void reset (size_t idx) override
 Resets an element to its default value.
 
bool transfer (const BasePropertyArray &other) override
 Copies the entire properties from another property array.
 
bool transfer (const BasePropertyArray &other, std::size_t from, std::size_t to) override
 Copies a property from one index to another.
 
void shrink_to_fit () override
 Free unused memory.
 
void swap (size_t i0, size_t i1) override
 Swaps the storage place of two elements.
 
void copy (size_t from, size_t to) override
 Copies an element from one index to another.
 
BasePropertyArrayclone () const override
 Returns a deep copy of the property array.
 
BasePropertyArrayempty_clone () const override
 Returns an empty copy of the property array.
 
const std::type_info & type () const override
 Returns the type information of the property.
 
const T * data () const
 Gets a pointer to the array (does not work for T == bool).
 
std::vector< T > & vector ()
 Gets a reference to the underlying vector.
 
reference operator[] (size_t _idx)
 Accesses the i-th element. No range check is performed.
 
const_reference operator[] (size_t _idx) const
 Const access to the i-th element. No range check is performed.
 
const bool * data () const
 Specialization for bool properties. It crashes the program and simply returns nullptr as bool* is not allowed.
 
- Public Member Functions inherited from BasePropertyArray
 BasePropertyArray (const std::string &name)
 Default constructor.
 
virtual ~BasePropertyArray ()=default
 Destructor.
 
const std::string & name () const
 Returns the name of the property.
 
void set_name (const std::string &n)
 Sets the name of the property.
 
bool is_same (const BasePropertyArray &other) const
 Tests if two properties are the same.
 

Detailed Description

template<class T>
class easy3d::PropertyArray< T >

Implementation of a generic property array.

Template Parameters
TThe type of the property.

Constructor & Destructor Documentation

◆ PropertyArray()

template<class T>
PropertyArray ( const std::string & name,
T t = T() )
inlineexplicit

Constructor.

Parameters
nameThe name of the property array.
tThe default value of the property.

Member Function Documentation

◆ clone()

template<class T>
BasePropertyArray * clone ( ) const
inlineoverridevirtual

Returns a deep copy of the property array.

Returns
A pointer to the deep copy of the property array.

Implements BasePropertyArray.

◆ copy()

template<class T>
void copy ( size_t from,
size_t to )
inlineoverridevirtual

Copies an element from one index to another.

Parameters
fromThe index to copy from.
toThe index to copy to.

Implements BasePropertyArray.

◆ data()

template<class T>
const T * data ( ) const
inline

Gets a pointer to the array (does not work for T == bool).

Returns
A pointer to the array.

◆ empty_clone()

template<class T>
BasePropertyArray * empty_clone ( ) const
inlineoverridevirtual

Returns an empty copy of the property array.

Returns
A pointer to the empty copy of the property array.

Implements BasePropertyArray.

◆ operator[]() [1/2]

template<class T>
reference operator[] ( size_t _idx)
inline

Accesses the i-th element. No range check is performed.

Parameters
_idxThe index of the element.
Returns
A reference to the i-th element.

◆ operator[]() [2/2]

template<class T>
const_reference operator[] ( size_t _idx) const
inline

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

Parameters
_idxThe index of the element.
Returns
A const reference to the i-th element.

◆ push_back()

template<class T>
void push_back ( )
inlineoverridevirtual

Extend the number of elements by one.

Implements BasePropertyArray.

◆ reserve()

template<class T>
void reserve ( size_t n)
inlineoverridevirtual

Reserves memory for n elements.

Parameters
nThe number of elements to reserve memory for.

Implements BasePropertyArray.

◆ reset()

template<class T>
void reset ( size_t idx)
inlineoverridevirtual

Resets an element to its default value.

Parameters
idxThe index of the element to reset.

Implements BasePropertyArray.

◆ resize()

template<class T>
void resize ( size_t n)
inlineoverridevirtual

Resizes storage to hold n elements.

Parameters
nThe number of elements to resize to.

Implements BasePropertyArray.

◆ shrink_to_fit()

template<class T>
void shrink_to_fit ( )
inlineoverridevirtual

Free unused memory.

Implements BasePropertyArray.

◆ swap()

template<class T>
void swap ( size_t i0,
size_t i1 )
inlineoverridevirtual

Swaps the storage place of two elements.

Parameters
i0The index of the first element.
i1The index of the second element.

Implements BasePropertyArray.

◆ transfer() [1/2]

template<class T>
bool transfer ( const BasePropertyArray< T > & other)
inlineoverridevirtual

Copies the entire properties from another property array.

Parameters
otherThe other property array to copy from.
Returns
True if the transfer was successful, false otherwise.

Implements BasePropertyArray.

◆ transfer() [2/2]

template<class T>
bool transfer ( const BasePropertyArray< T > & other,
std::size_t from,
std::size_t to )
inlineoverridevirtual

Copies a property from one index to another.

Parameters
otherThe other property array to copy from.
fromThe index to copy from.
toThe index to copy to.
Returns
True if the transfer was successful, false otherwise.

Implements BasePropertyArray.

◆ type()

template<class T>
const std::type_info & type ( ) const
inlineoverridevirtual

Returns the type information of the property.

Returns
The type information of the property.

Implements BasePropertyArray.

◆ vector()

template<class T>
std::vector< T > & vector ( )
inline

Gets a reference to the underlying vector.

Returns
A reference to the underlying vector.

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