cesium-native  0.41.0
CesiumGltf::PropertyTableView Class Reference

Utility to retrieve the data of PropertyTable. More...

#include <CesiumGltf/PropertyTableView.h>

Public Member Functions

 PropertyTableView (const Model &model, const PropertyTable &propertyTable)
 Creates an instance of PropertyTableView. More...
 
PropertyTableViewStatus status () const noexcept
 Gets the status of this property table view. More...
 
const std::optional< std::string > & name () const noexcept
 Gets the name of the property table being viewed. Returns std::nullopt if no name was specified.
 
int64_t size () const noexcept
 Get the number of elements in this PropertyTableView. If the view is valid, this returns PropertyTable::count. Otherwise, this returns 0. More...
 
const ClassgetClass () const noexcept
 Gets the Class that this property table conforms to. More...
 
const ClassPropertygetClassProperty (const std::string &propertyId) const
 Finds the ClassProperty that describes the type information of the property with the specified id. More...
 
template<typename T , bool Normalized = false>
PropertyTablePropertyView< T, Normalized > getPropertyView (const std::string &propertyId) const
 Gets a PropertyTablePropertyView that views the data of a property stored in the PropertyTable. More...
 
template<typename Callback >
void getPropertyView (const std::string &propertyId, Callback &&callback) const
 Gets a PropertyTablePropertyView through a callback that accepts a property id and a PropertyTablePropertyView<T> that views the data of the property with the specified id. More...
 
template<typename Callback >
void forEachProperty (Callback &&callback) const
 Iterates over each property in the PropertyTable with a callback that accepts a property id and a PropertyTablePropertyView<T> to view the data stored in the PropertyTableProperty. More...
 

Detailed Description

Utility to retrieve the data of PropertyTable.

This should be used to get a PropertyTablePropertyView of a property in the property table. It will validate the EXT_structural_metadata format and ensure PropertyTablePropertyView does not access out of bounds.

Definition at line 54 of file PropertyTableView.h.

Constructor & Destructor Documentation

◆ PropertyTableView()

CesiumGltf::PropertyTableView::PropertyTableView ( const Model model,
const PropertyTable propertyTable 
)

Creates an instance of PropertyTableView.

Parameters
modelThe glTF Model that contains the property table data.
propertyTableThe PropertyTable from which the view will retrieve data.

Member Function Documentation

◆ forEachProperty()

template<typename Callback >
void CesiumGltf::PropertyTableView::forEachProperty ( Callback &&  callback) const
inline

Iterates over each property in the PropertyTable with a callback that accepts a property id and a PropertyTablePropertyView<T> to view the data stored in the PropertyTableProperty.

This method will validate the EXT_structural_metadata format to ensure PropertyTablePropertyView retrieves the correct data. T must be one of the following: a scalar (uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t, uint64_t, int64_t, float, double), a glm vecN composed of one of the scalar types, a glm matN composed of one of the scalar types, bool, std::string_view, or PropertyArrayView<T> with T as one of the aforementioned types.

If the property is invalid, an empty PropertyTablePropertyView with an error status code will be passed to the callback. Otherwise, a valid property view will be passed to the callback.

Parameters
propertyIdThe id of the property to retrieve data from
Template Parameters
callbackA callback function that accepts property id and PropertyTablePropertyView<T>

Definition at line 328 of file PropertyTableView.h.

◆ getClass()

const Class* CesiumGltf::PropertyTableView::getClass ( ) const
inlinenoexcept

Gets the Class that this property table conforms to.

Returns
A pointer to the Class. Returns nullptr if the PropertyTable did not specify a valid class.

Definition at line 99 of file PropertyTableView.h.

◆ getClassProperty()

const ClassProperty* CesiumGltf::PropertyTableView::getClassProperty ( const std::string &  propertyId) const

Finds the ClassProperty that describes the type information of the property with the specified id.

Parameters
propertyIdThe id of the property to retrieve the class for.
Returns
A pointer to the ClassProperty. Returns nullptr if the PropertyTableView is invalid or if no class property was found.

◆ getPropertyView() [1/2]

template<typename T , bool Normalized = false>
PropertyTablePropertyView<T, Normalized> CesiumGltf::PropertyTableView::getPropertyView ( const std::string &  propertyId) const
inline

Gets a PropertyTablePropertyView that views the data of a property stored in the PropertyTable.

This method will validate the EXT_structural_metadata format to ensure PropertyTablePropertyView retrieves the correct data. T must be one of the following: a scalar (uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t, uint64_t, int64_t, float, double), a glm vecN composed of one of the scalar types, a glm matN composed of one of the scalar types, bool, std::string_view, or PropertyArrayView<T> with T as one of the aforementioned types.

If T does not match the type specified by the class property, this returns an invalid PropertyTablePropertyView. Likewise, if the value of Normalized does not match the value of {@ClassProperty::normalized} for that class property, this returns an invalid property view. Only types with integer components may be normalized.

Template Parameters
TThe C++ type corresponding to the type of the data retrieved.
NormalizedWhether the property is normalized. Only applicable to types with integer components.
Parameters
propertyIdThe id of the property to retrieve data from
Returns
A PropertyTablePropertyView of the property. If no valid property is found, the property view will be invalid.

Definition at line 138 of file PropertyTableView.h.

◆ getPropertyView() [2/2]

template<typename Callback >
void CesiumGltf::PropertyTableView::getPropertyView ( const std::string &  propertyId,
Callback &&  callback 
) const
inline

Gets a PropertyTablePropertyView through a callback that accepts a property id and a PropertyTablePropertyView<T> that views the data of the property with the specified id.

This method will validate the EXT_structural_metadata format to ensure PropertyTablePropertyView retrieves the correct data. T must be one of the following: a scalar (uint8_t, int8_t, uint16_t, int16_t, uint32_t, int32_t, uint64_t, int64_t, float, double), a glm vecN composed of one of the scalar types, a glm matN composed of one of the scalar types, bool, std::string_view, or PropertyArrayView<T> with T as one of the aforementioned types.

If the property is invalid, an empty PropertyTablePropertyView with an error status will be passed to the callback. Otherwise, a valid property view will be passed to the callback.

Parameters
propertyIdThe id of the property to retrieve data from
Template Parameters
callbackA callback function that accepts a property id and a PropertyTablePropertyView<T>

Definition at line 176 of file PropertyTableView.h.

◆ size()

int64_t CesiumGltf::PropertyTableView::size ( ) const
inlinenoexcept

Get the number of elements in this PropertyTableView. If the view is valid, this returns PropertyTable::count. Otherwise, this returns 0.

Returns
The number of elements in this PropertyTableView.

Definition at line 88 of file PropertyTableView.h.

◆ status()

PropertyTableViewStatus CesiumGltf::PropertyTableView::status ( ) const
inlinenoexcept

Gets the status of this property table view.

Indicates whether the view accurately reflects the property table's data, or whether an error occurred.

Returns
The status of this property table view.

Definition at line 72 of file PropertyTableView.h.


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