78 const std::optional<std::string>&
name() const noexcept {
79 return _pPropertyTable->
name;
88 int64_t
size() const noexcept {
136 template <
typename T,
bool Normalized = false>
139 if (this->
size() <= 0) {
145 if (!pClassProperty) {
150 return getPropertyViewImpl<T, Normalized>(propertyId, *pClassProperty);
175 template <
typename Callback>
178 if (this->
size() <= 0) {
187 if (!pClassProperty) {
212 if (pClassProperty->
array) {
214 getArrayPropertyViewImpl<Callback, true>(
219 std::forward<Callback>(callback));
221 getArrayPropertyViewImpl<Callback, false>(
226 std::forward<Callback>(callback));
233 getScalarPropertyViewImpl<Callback, true>(
237 std::forward<Callback>(callback));
239 getScalarPropertyViewImpl<Callback, false>(
243 std::forward<Callback>(callback));
250 getVecNPropertyViewImpl<Callback, true>(
255 std::forward<Callback>(callback));
257 getVecNPropertyViewImpl<Callback, false>(
262 std::forward<Callback>(callback));
269 getMatNPropertyViewImpl<Callback, true>(
274 std::forward<Callback>(callback));
276 getMatNPropertyViewImpl<Callback, false>(
281 std::forward<Callback>(callback));
289 getPropertyViewImpl<std::string_view, false>(
298 getPropertyViewImpl<bool, false>(propertyId, *pClassProperty));
330 for (
const auto& property : this->_pClass->
properties) {
336 template <
typename Callback,
bool Normalized>
337 void getScalarArrayPropertyViewImpl(
338 const std::string& propertyId,
341 Callback&& callback)
const {
342 switch (componentType) {
422 template <
typename Callback, glm::length_t N,
bool Normalized>
423 void getVecNArrayPropertyViewImpl(
424 const std::string& propertyId,
425 const ClassProperty& classProperty,
427 Callback&& callback)
const {
428 switch (componentType) {
433 PropertyArrayView<glm::vec<N, int8_t>>,
434 Normalized>(propertyId, classProperty));
440 PropertyArrayView<glm::vec<N, uint8_t>>,
441 Normalized>(propertyId, classProperty));
447 PropertyArrayView<glm::vec<N, int16_t>>,
448 Normalized>(propertyId, classProperty));
454 PropertyArrayView<glm::vec<N, uint16_t>>,
455 Normalized>(propertyId, classProperty));
461 PropertyArrayView<glm::vec<N, int32_t>>,
462 Normalized>(propertyId, classProperty));
468 PropertyArrayView<glm::vec<N, uint32_t>>,
469 Normalized>(propertyId, classProperty));
475 PropertyArrayView<glm::vec<N, int64_t>>,
476 Normalized>(propertyId, classProperty));
482 PropertyArrayView<glm::vec<N, uint64_t>>,
483 Normalized>(propertyId, classProperty));
488 getPropertyViewImpl<PropertyArrayView<glm::vec<N, float>>,
false>(
495 getPropertyViewImpl<PropertyArrayView<glm::vec<N, double>>,
false>(
502 PropertyTablePropertyView<uint8_t>(
508 template <
typename Callback,
bool Normalized>
509 void getVecNArrayPropertyViewImpl(
510 const std::string& propertyId,
511 const ClassProperty& classProperty,
514 Callback&& callback)
const {
518 getVecNArrayPropertyViewImpl<Callback, 2, Normalized>(
522 std::forward<Callback>(callback));
525 getVecNArrayPropertyViewImpl<Callback, 3, Normalized>(
529 std::forward<Callback>(callback));
532 getVecNArrayPropertyViewImpl<Callback, 4, Normalized>(
536 std::forward<Callback>(callback));
541 PropertyTablePropertyView<uint8_t>(
547 template <
typename Callback, glm::length_t N,
bool Normalized>
548 void getMatNArrayPropertyViewImpl(
549 const std::string& propertyId,
550 const ClassProperty& classProperty,
552 Callback&& callback)
const {
553 switch (componentType) {
558 PropertyArrayView<glm::mat<N, N, int8_t>>,
559 Normalized>(propertyId, classProperty));
565 PropertyArrayView<glm::mat<N, N, uint8_t>>,
566 Normalized>(propertyId, classProperty));
572 PropertyArrayView<glm::mat<N, N, int16_t>>,
573 Normalized>(propertyId, classProperty));
579 PropertyArrayView<glm::mat<N, N, uint16_t>>,
580 Normalized>(propertyId, classProperty));
586 PropertyArrayView<glm::mat<N, N, int32_t>>,
587 Normalized>(propertyId, classProperty));
593 PropertyArrayView<glm::mat<N, N, uint32_t>>,
594 Normalized>(propertyId, classProperty));
600 PropertyArrayView<glm::mat<N, N, int64_t>>,
601 Normalized>(propertyId, classProperty));
607 PropertyArrayView<glm::mat<N, N, uint64_t>>,
608 Normalized>(propertyId, classProperty));
613 getPropertyViewImpl<PropertyArrayView<glm::mat<N, N, float>>,
false>(
620 getPropertyViewImpl<PropertyArrayView<glm::mat<N, N, double>>,
false>(
627 PropertyTablePropertyView<uint8_t>(
633 template <
typename Callback,
bool Normalized>
634 void getMatNArrayPropertyViewImpl(
635 const std::string& propertyId,
636 const ClassProperty& classProperty,
639 Callback&& callback)
const {
643 getMatNArrayPropertyViewImpl<Callback, 2, Normalized>(
647 std::forward<Callback>(callback));
650 getMatNArrayPropertyViewImpl<Callback, 3, Normalized>(
654 std::forward<Callback>(callback));
657 getMatNArrayPropertyViewImpl<Callback, 4, Normalized>(
661 std::forward<Callback>(callback));
666 PropertyTablePropertyView<uint8_t>(
672 template <
typename Callback,
bool Normalized>
673 void getArrayPropertyViewImpl(
674 const std::string& propertyId,
675 const ClassProperty& classProperty,
678 Callback&& callback)
const {
680 getScalarArrayPropertyViewImpl<Callback, Normalized>(
684 std::forward<Callback>(callback));
686 getVecNArrayPropertyViewImpl<Callback, Normalized>(
691 std::forward<Callback>(callback));
693 getMatNArrayPropertyViewImpl<Callback, Normalized>(
698 std::forward<Callback>(callback));
702 getPropertyViewImpl<PropertyArrayView<bool>,
false>(
709 getPropertyViewImpl<PropertyArrayView<std::string_view>,
false>(
715 PropertyTablePropertyView<uint8_t>(
720 template <
typename Callback, glm::length_t N,
bool Normalized>
721 void getVecNPropertyViewImpl(
722 const std::string& propertyId,
723 const ClassProperty& classProperty,
725 Callback&& callback)
const {
727 switch (componentType) {
731 getPropertyViewImpl<glm::vec<N, int8_t>, Normalized>(
738 getPropertyViewImpl<glm::vec<N, uint8_t>, Normalized>(
745 getPropertyViewImpl<glm::vec<N, int16_t>, Normalized>(
752 getPropertyViewImpl<glm::vec<N, uint16_t>, Normalized>(
759 getPropertyViewImpl<glm::vec<N, int32_t>, Normalized>(
766 getPropertyViewImpl<glm::vec<N, uint32_t>, Normalized>(
773 getPropertyViewImpl<glm::vec<N, int64_t>, Normalized>(
780 getPropertyViewImpl<glm::vec<N, uint64_t>, Normalized>(
787 getPropertyViewImpl<glm::vec<N, float>,
false>(
794 getPropertyViewImpl<glm::vec<N, double>,
false>(
801 PropertyTablePropertyView<uint8_t>(
807 template <
typename Callback,
bool Normalized>
808 void getVecNPropertyViewImpl(
809 const std::string& propertyId,
810 const ClassProperty& classProperty,
813 Callback&& callback)
const {
817 getVecNPropertyViewImpl<Callback, 2, Normalized>(
821 std::forward<Callback>(callback));
824 getVecNPropertyViewImpl<Callback, 3, Normalized>(
828 std::forward<Callback>(callback));
831 getVecNPropertyViewImpl<Callback, 4, Normalized>(
835 std::forward<Callback>(callback));
840 PropertyTablePropertyView<uint8_t>(
846 template <
typename Callback, glm::length_t N,
bool Normalized>
847 void getMatNPropertyViewImpl(
848 const std::string& propertyId,
849 const ClassProperty& classProperty,
851 Callback&& callback)
const {
852 switch (componentType) {
856 getPropertyViewImpl<glm::mat<N, N, int8_t>, Normalized>(
863 getPropertyViewImpl<glm::mat<N, N, uint8_t>, Normalized>(
870 getPropertyViewImpl<glm::mat<N, N, int16_t>, Normalized>(
877 getPropertyViewImpl<glm::mat<N, N, uint16_t>, Normalized>(
884 getPropertyViewImpl<glm::mat<N, N, int32_t>, Normalized>(
891 getPropertyViewImpl<glm::mat<N, N, uint32_t>, Normalized>(
898 getPropertyViewImpl<glm::mat<N, N, int64_t>, Normalized>(
905 getPropertyViewImpl<glm::mat<N, N, uint64_t>, Normalized>(
912 getPropertyViewImpl<glm::mat<N, N, float>,
false>(
919 getPropertyViewImpl<glm::mat<N, N, double>,
false>(
926 PropertyTablePropertyView<uint8_t>(
932 template <
typename Callback,
bool Normalized>
933 void getMatNPropertyViewImpl(
934 const std::string& propertyId,
935 const ClassProperty& classProperty,
938 Callback&& callback)
const {
942 getMatNPropertyViewImpl<Callback, 2, Normalized>(
946 std::forward<Callback>(callback));
949 getMatNPropertyViewImpl<Callback, 3, Normalized>(
953 std::forward<Callback>(callback));
956 getMatNPropertyViewImpl<Callback, 4, Normalized>(
960 std::forward<Callback>(callback));
965 PropertyTablePropertyView<uint8_t>(
971 template <
typename Callback,
bool Normalized>
972 void getScalarPropertyViewImpl(
973 const std::string& propertyId,
974 const ClassProperty& classProperty,
976 Callback&& callback)
const {
977 switch (componentType) {
981 getPropertyViewImpl<int8_t, Normalized>(propertyId, classProperty));
986 getPropertyViewImpl<uint8_t, Normalized>(propertyId, classProperty));
991 getPropertyViewImpl<int16_t, Normalized>(propertyId, classProperty));
996 getPropertyViewImpl<uint16_t, Normalized>(propertyId, classProperty));
1001 getPropertyViewImpl<int32_t, Normalized>(propertyId, classProperty));
1006 getPropertyViewImpl<uint32_t, Normalized>(propertyId, classProperty));
1011 getPropertyViewImpl<int64_t, Normalized>(propertyId, classProperty));
1016 getPropertyViewImpl<uint64_t, Normalized>(propertyId, classProperty));
1021 getPropertyViewImpl<float, false>(propertyId, classProperty));
1026 getPropertyViewImpl<double, false>(propertyId, classProperty));
1031 PropertyTablePropertyView<uint8_t>(
1037 template <
typename T,
bool Normalized>
1038 PropertyTablePropertyView<T, Normalized> getPropertyViewImpl(
1039 const std::string& propertyId,
1040 const ClassProperty& classProperty)
const {
1041 auto propertyTablePropertyIter =
1042 _pPropertyTable->
properties.find(propertyId);
1043 if (propertyTablePropertyIter == _pPropertyTable->
properties.end()) {
1044 if (!classProperty.required && classProperty.defaultProperty) {
1048 return PropertyTablePropertyView<T, Normalized>(
1050 _pPropertyTable->
count);
1054 return PropertyTablePropertyView<T, Normalized>(
1058 const PropertyTableProperty& propertyTableProperty =
1059 propertyTablePropertyIter->second;
1061 if constexpr (IsMetadataNumeric<T>::value || IsMetadataBoolean<T>::value) {
1062 return getNumericOrBooleanPropertyValues<T, Normalized>(
1064 propertyTableProperty);
1067 if constexpr (IsMetadataString<T>::value) {
1068 return getStringPropertyValues(classProperty, propertyTableProperty);
1071 if constexpr (IsMetadataBooleanArray<T>::value) {
1072 return getBooleanArrayPropertyValues(
1074 propertyTableProperty);
1077 if constexpr (IsMetadataNumericArray<T>::value) {
1078 return getNumericArrayPropertyValues<
1080 Normalized>(classProperty, propertyTableProperty);
1083 if constexpr (IsMetadataStringArray<T>::value) {
1084 return getStringArrayPropertyValues(classProperty, propertyTableProperty);
1088 template <
typename T,
bool Normalized>
1089 PropertyTablePropertyView<T, Normalized> getNumericOrBooleanPropertyValues(
1090 const ClassProperty& classProperty,
1091 const PropertyTableProperty& propertyTableProperty)
const {
1092 if (classProperty.array) {
1093 return PropertyTablePropertyView<T, Normalized>(
1098 if (TypeToPropertyType<T>::value != type) {
1099 return PropertyTablePropertyView<T, Normalized>(
1104 classProperty.componentType.value_or(
""));
1105 if (TypeToPropertyType<T>::component != componentType) {
1106 return PropertyTablePropertyView<T, Normalized>(
1110 if (classProperty.normalized != Normalized) {
1111 return PropertyTablePropertyView<T, Normalized>(
1115 std::span<const std::byte> values;
1116 const auto status = getBufferSafe(propertyTableProperty.values, values);
1118 return PropertyTablePropertyView<T, Normalized>(
status);
1121 if (values.size() %
sizeof(T) != 0) {
1122 return PropertyTablePropertyView<T, Normalized>(
1123 PropertyTablePropertyViewStatus::
1124 ErrorBufferViewSizeNotDivisibleByTypeSize);
1127 size_t maxRequiredBytes = 0;
1128 if (IsMetadataBoolean<T>::value) {
1129 maxRequiredBytes =
static_cast<size_t>(
1130 glm::ceil(
static_cast<double>(_pPropertyTable->
count) / 8.0));
1132 maxRequiredBytes = _pPropertyTable->
count *
sizeof(T);
1135 if (values.size() < maxRequiredBytes) {
1136 return PropertyTablePropertyView<T, Normalized>(
1137 PropertyTablePropertyViewStatus::
1138 ErrorBufferViewSizeDoesNotMatchPropertyTableCount);
1141 return PropertyTablePropertyView<T, Normalized>(
1142 propertyTableProperty,
1144 _pPropertyTable->
count,
1148 PropertyTablePropertyView<std::string_view> getStringPropertyValues(
1149 const ClassProperty& classProperty,
1150 const PropertyTableProperty& propertyTableProperty)
const;
1152 PropertyTablePropertyView<PropertyArrayView<bool>>
1153 getBooleanArrayPropertyValues(
1154 const ClassProperty& classProperty,
1155 const PropertyTableProperty& propertyTableProperty)
const;
1157 template <
typename T,
bool Normalized>
1158 PropertyTablePropertyView<PropertyArrayView<T>, Normalized>
1159 getNumericArrayPropertyValues(
1160 const ClassProperty& classProperty,
1161 const PropertyTableProperty& propertyTableProperty)
const {
1162 if (!classProperty.array) {
1163 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1168 if (TypeToPropertyType<T>::value != type) {
1169 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1175 classProperty.componentType.value_or(
""));
1176 if (TypeToPropertyType<T>::component != componentType) {
1177 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1181 if (classProperty.normalized != Normalized) {
1182 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1186 std::span<const std::byte> values;
1187 auto status = getBufferSafe(propertyTableProperty.values, values);
1189 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1193 if (values.size() %
sizeof(T) != 0) {
1194 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1199 const int64_t fixedLengthArrayCount = classProperty.count.value_or(0);
1200 if (fixedLengthArrayCount > 0 && propertyTableProperty.arrayOffsets >= 0) {
1201 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1206 if (fixedLengthArrayCount <= 0 && propertyTableProperty.arrayOffsets < 0) {
1207 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1213 if (fixedLengthArrayCount > 0) {
1214 size_t maxRequiredBytes = maxRequiredBytes =
static_cast<size_t>(
1215 _pPropertyTable->
count * fixedLengthArrayCount *
sizeof(T));
1217 if (values.size() < maxRequiredBytes) {
1218 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1223 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1224 propertyTableProperty,
1226 _pPropertyTable->
count,
1233 propertyTableProperty.arrayOffsetType);
1235 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1239 constexpr bool checkBitsSize =
false;
1240 std::span<const std::byte> arrayOffsets;
1241 status = getArrayOffsetsBufferSafe(
1242 propertyTableProperty.arrayOffsets,
1245 static_cast<size_t>(_pPropertyTable->
count),
1249 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1253 if constexpr (Normalized) {
1254 return PropertyTablePropertyView<PropertyArrayView<T>,
true>(
1255 propertyTableProperty,
1257 _pPropertyTable->
count,
1262 return PropertyTablePropertyView<PropertyArrayView<T>,
false>(
1263 propertyTableProperty,
1265 _pPropertyTable->
count,
1268 std::span<const std::byte>(),
1274 PropertyTablePropertyView<PropertyArrayView<std::string_view>>
1275 getStringArrayPropertyValues(
1276 const ClassProperty& classProperty,
1277 const PropertyTableProperty& propertyTableProperty)
const;
1281 std::span<const std::byte>& buffer)
const noexcept;
1284 int32_t arrayOffsetsBufferView,
1286 size_t valuesBufferSize,
1287 size_t propertyTableCount,
1289 std::span<const std::byte>& arrayOffsetsBuffer)
const noexcept;
1292 int32_t stringOffsetsBufferView,
1294 size_t valuesBufferSize,
1295 size_t propertyTableCount,
1296 std::span<const std::byte>& stringOffsetsBuffer)
const noexcept;
1298 const Model* _pModel;
1299 const PropertyTable* _pPropertyTable;
1300 const Class* _pClass;