7#ifndef PXR_BASE_VT_TYPES_H
8#define PXR_BASE_VT_TYPES_H
14#include "pxr/base/vt/api.h"
19#include "pxr/base/tf/meta.h"
20#include "pxr/base/tf/preprocessorUtilsLite.h"
27PXR_NAMESPACE_OPEN_SCOPE
31VT_TYPE_IS_CHEAP_TO_COPY(
TfToken);
35#define VT_FLOATING_POINT_BUILTIN_VALUE_TYPES \
40#define VT_INTEGRAL_BUILTIN_VALUE_TYPES \
43(( unsigned char, UChar )) \
45(( unsigned short, UShort )) \
47(( unsigned int, UInt )) \
51#define VT_VEC_INT_VALUE_TYPES \
56#define VT_VEC_HALF_VALUE_TYPES \
61#define VT_VEC_FLOAT_VALUE_TYPES \
66#define VT_VEC_DOUBLE_VALUE_TYPES \
71#define VT_VEC_VALUE_TYPES \
72 VT_VEC_INT_VALUE_TYPES \
73 VT_VEC_HALF_VALUE_TYPES \
74 VT_VEC_FLOAT_VALUE_TYPES \
75 VT_VEC_DOUBLE_VALUE_TYPES
77#define VT_MATRIX_FLOAT_VALUE_TYPES \
78(( GfMatrix4f, Matrix4f )) \
79(( GfMatrix3f, Matrix3f )) \
80(( GfMatrix2f, Matrix2f )) \
82#define VT_MATRIX_DOUBLE_VALUE_TYPES \
83(( GfMatrix4d, Matrix4d )) \
84(( GfMatrix3d, Matrix3d )) \
85(( GfMatrix2d, Matrix2d ))
87#define VT_MATRIX_VALUE_TYPES \
88 VT_MATRIX_FLOAT_VALUE_TYPES \
89 VT_MATRIX_DOUBLE_VALUE_TYPES \
91#define VT_GFRANGE_VALUE_TYPES \
92(( GfRange3f, Range3f )) \
93(( GfRange3d, Range3d )) \
94(( GfRange2f, Range2f )) \
95(( GfRange2d, Range2d )) \
96(( GfRange1f, Range1f )) \
97(( GfRange1d, Range1d ))
99#define VT_RANGE_VALUE_TYPES \
100 VT_GFRANGE_VALUE_TYPES \
101(( GfInterval, Interval )) \
102(( GfRect2i, Rect2i ))
104#define VT_STRING_VALUE_TYPES \
105(( std::string, String )) \
108#define VT_QUATERNION_VALUE_TYPES \
109(( GfQuath, Quath )) \
110(( GfQuatf, Quatf )) \
111(( GfQuatd, Quatd )) \
112(( GfQuaternion, Quaternion ))
114#define VT_DUALQUATERNION_VALUE_TYPES \
115(( GfDualQuath, DualQuath )) \
116(( GfDualQuatf, DualQuatf )) \
117(( GfDualQuatd, DualQuatd ))
119#define VT_NONARRAY_VALUE_TYPES \
120(( GfFrustum, Frustum)) \
121(( GfMultiInterval, MultiInterval))
124#define VT_TYPE(elem) \
125TF_PP_TUPLE_ELEM(0, elem)
126#define VT_TYPE_NAME(elem) \
127TF_PP_TUPLE_ELEM(1, elem)
131#define VT_BUILTIN_NUMERIC_VALUE_TYPES \
132VT_INTEGRAL_BUILTIN_VALUE_TYPES VT_FLOATING_POINT_BUILTIN_VALUE_TYPES
134#define VT_BUILTIN_VALUE_TYPES \
135VT_BUILTIN_NUMERIC_VALUE_TYPES VT_STRING_VALUE_TYPES
137#define VT_SCALAR_CLASS_VALUE_TYPES \
139VT_MATRIX_VALUE_TYPES \
140VT_RANGE_VALUE_TYPES \
141VT_QUATERNION_VALUE_TYPES \
142VT_DUALQUATERNION_VALUE_TYPES
144#define VT_SCALAR_VALUE_TYPES \
145VT_SCALAR_CLASS_VALUE_TYPES VT_BUILTIN_VALUE_TYPES
153template<
typename T>
class VtArray;
154#define VT_ARRAY_TYPEDEF(unused, elem) \
155typedef VtArray< VT_TYPE(elem) > \
156TF_PP_CAT(Vt, TF_PP_CAT(VT_TYPE_NAME(elem), Array)) ;
157TF_PP_SEQ_FOR_EACH(VT_ARRAY_TYPEDEF, ~, VT_SCALAR_VALUE_TYPES)
161#define VT_ARRAY_TYPE_TUPLE(unused, elem) \
162(( TF_PP_CAT(Vt, TF_PP_CAT(VT_TYPE_NAME(elem), Array)) , \
163 TF_PP_CAT(VT_TYPE_NAME(elem), Array) ))
164#define VT_ARRAY_VALUE_TYPES \
165TF_PP_SEQ_FOR_EACH(VT_ARRAY_TYPE_TUPLE, ~, VT_SCALAR_VALUE_TYPES)
167#define VT_CLASS_VALUE_TYPES \
168VT_ARRAY_VALUE_TYPES VT_SCALAR_CLASS_VALUE_TYPES VT_NONARRAY_VALUE_TYPES
170#define VT_VALUE_TYPES \
171 VT_BUILTIN_VALUE_TYPES VT_CLASS_VALUE_TYPES
173#define _VT_MAP_TYPE_LIST(unused, elem) , VT_TYPE(elem)
178using Vt_ValueTypeList =
179 TfMetaApply<TfMetaTail, TfMetaList<
180 void TF_PP_SEQ_FOR_EACH(_VT_MAP_TYPE_LIST, ~, VT_VALUE_TYPES)>>;
182namespace Vt_KnownValueTypeDetail
189GetIndexImpl(TfMetaList<>) {
193template <
typename T,
typename Typelist>
195GetIndexImpl(Typelist) {
196 if (std::is_same_v<T, TfMetaApply<TfMetaHead, Typelist>>) {
199 else if (
const int indexOfTail =
200 GetIndexImpl<T>(TfMetaApply<TfMetaTail, Typelist>{});
202 return 1 + indexOfTail;
212 return GetIndexImpl<T>(Vt_ValueTypeList{});
219VtGetNumKnownValueTypes() {
220 return TfMetaApply<TfMetaLength, Vt_ValueTypeList>::value;
239 constexpr int index = Vt_KnownValueTypeDetail::GetIndex<T>();
240 static_assert(index != -1,
"T is not one of the known VT_VALUE_TYPES.");
249 return Vt_KnownValueTypeDetail::GetIndex<T>() != -1;
256struct VtIsKnownValueType_Workaround
258 static const bool value = VtIsKnownValueType<T>();
264#define VT_SPECIALIZE_IS_VALUE_PROXY(unused, elem) \
266 VtIsValueProxy< VT_TYPE(elem) > : std::false_type {}; \
268 VtIsTypedValueProxy< VT_TYPE(elem) > : std::false_type {}; \
270 VtIsErasedValueProxy< VT_TYPE(elem) > : std::false_type {};
271TF_PP_SEQ_FOR_EACH(VT_SPECIALIZE_IS_VALUE_PROXY, ~, VT_VALUE_TYPES)
272#undef VT_SPECIALIZE_IS_VALUE_PROXY
284 unsigned int GetRank()
const {
286 otherDims[0] == 0 ? 1 :
287 otherDims[1] == 0 ? 2 :
288 otherDims[2] == 0 ? 3 : 4;
290 bool operator==(Vt_ShapeData
const &other)
const {
291 if (totalSize != other.totalSize)
293 unsigned int thisRank = GetRank(), otherRank = other.GetRank();
294 if (thisRank != otherRank)
296 return std::equal(otherDims, otherDims + GetRank() - 1,
299 bool operator!=(Vt_ShapeData
const &other)
const {
300 return !(*
this == other);
303 memset(
this, 0,
sizeof(*
this));
305 static const int NumOtherDims = 3;
307 unsigned int otherDims[NumOtherDims];
310PXR_NAMESPACE_CLOSE_SCOPE
constexpr int VtGetKnownValueTypeIndex()
Provide compile-time value type indexes for types that are "known" to Vt – specifically,...
constexpr bool VtIsKnownValueType()
Returns true if T is a type that appears in VT_VALUE_TYPES.
Token for efficient comparison, assignment, and hashing of known strings.
Represents an arbitrary dimensional rectangular container class.
This header serves to simply bring in the half float datatype and provide a hash_value function.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...