24 #ifndef PXR_BASE_VT_VALUE_H
25 #define PXR_BASE_VT_VALUE_H
52 #include <hboost/intrusive_ptr.hpp>
56 #include <type_traits>
97 : _ptr(std::move(
ptr)), _type(&type) {}
100 std::type_info
const *_type;
109 #define VT_VALUE_SET_STORED_TYPE(SRC, DST) \
110 template <> struct Vt_ValueStoredType<SRC> { typedef DST Type; }
116 #ifdef PXR_PYTHON_SUPPORT_ENABLED
118 #endif // PXR_PYTHON_SUPPORT_ENABLED
120 #undef VT_VALUE_SET_STORED_TYPE
166 static const unsigned int _LocalFlag = 1 << 0;
167 static const unsigned int _TrivialCopyFlag = 1 << 1;
168 static const unsigned int _ProxyFlag = 1 << 2;
172 explicit _Counted(
T const &obj) : _obj(obj) {
175 bool IsUnique()
const {
return _refCount == 1; }
176 T const &
Get()
const {
return _obj; }
177 T &GetMutable() {
return _obj; }
181 mutable std::atomic<int> _refCount;
184 d->_refCount.fetch_add(1, std::memory_order_relaxed);
187 if (d->_refCount.fetch_sub(1, std::memory_order_release) == 1) {
188 std::atomic_thread_fence(std::memory_order_acquire);
197 static const size_t _MaxLocalSize =
sizeof(
void*);
198 typedef std::aligned_storage<
199 _MaxLocalSize, _MaxLocalSize>
::type _Storage;
202 using _IsTriviallyCopyable = std::integral_constant<bool,
203 std::is_trivially_default_constructible_v<T> &&
204 std::is_trivially_copyable_v<T> &&
205 std::is_trivially_copy_assignable_v<T> &&
206 std::is_trivially_destructible_v<T>>;
211 using _UsesLocalStore = std::integral_constant<bool,
212 (
sizeof(
T) <=
sizeof(_Storage)) &&
220 using _CopyInitFunc =
void (*)(_Storage
const &, _Storage &);
221 using _DestroyFunc =
void (*)(_Storage &);
222 using _MoveFunc =
void (*)(_Storage &, _Storage &);
223 using _CanHashFunc = bool (*)(_Storage
const &);
224 using _HashFunc = size_t (*)(_Storage
const &);
225 using _EqualFunc = bool (*)(_Storage
const &, _Storage
const &);
226 using _EqualPtrFunc = bool (*)(_Storage
const &,
void const *);
227 using _MakeMutableFunc =
void (*)(_Storage &);
229 using _StreamOutFunc =
230 std::ostream & (*)(_Storage
const &, std::ostream &);
231 using _GetTypeidFunc = std::type_info
const & (*)(_Storage
const &);
232 using _IsArrayValuedFunc = bool (*)(_Storage
const &);
233 using _GetElementTypeidFunc =
234 std::type_info
const & (*)(_Storage
const &);
235 using _GetShapeDataFunc =
const Vt_ShapeData* (*)(_Storage
const &);
236 using _GetNumElementsFunc = size_t (*)(_Storage
const &);
237 using _ProxyHoldsTypeFunc = bool (*)(_Storage
const &, std::type_info
const &);
238 using _GetProxiedTypeFunc =
TfType (*)(_Storage
const &);
239 using _GetProxiedTypeidFunc =
240 std::type_info
const & (*)(_Storage
const &);
241 using _GetProxiedObjPtrFunc =
void const *(*)(_Storage
const &);
242 using _GetProxiedAsVtValueFunc =
VtValue (*)(_Storage
const &);
245 constexpr _TypeInfo(
const std::type_info &ti,
246 const std::type_info &elementTi,
251 _CopyInitFunc copyInit,
252 _DestroyFunc destroy,
254 _CanHashFunc canHash,
257 _EqualPtrFunc equalPtr,
258 _MakeMutableFunc makeMutable,
259 _GetPyObjFunc getPyObj,
260 _StreamOutFunc streamOut,
261 _GetTypeidFunc getTypeid,
262 _IsArrayValuedFunc isArrayValued,
263 _GetElementTypeidFunc getElementTypeid,
264 _GetShapeDataFunc getShapeData,
265 _GetNumElementsFunc getNumElements,
266 _ProxyHoldsTypeFunc proxyHoldsType,
267 _GetProxiedTypeFunc getProxiedType,
268 _GetProxiedTypeidFunc getProxiedTypeid,
269 _GetProxiedObjPtrFunc getProxiedObjPtr,
270 _GetProxiedAsVtValueFunc getProxiedAsVtValue)
272 , elementTypeInfo(elementTi)
273 , knownTypeIndex(knownTypeIndex)
276 , isHashable(isHashable)
278 , _copyInit(copyInit)
284 , _equalPtr(equalPtr)
285 , _makeMutable(makeMutable)
286 , _getPyObj(getPyObj)
287 , _streamOut(streamOut)
288 , _getTypeid(getTypeid)
289 , _isArrayValued(isArrayValued)
290 , _getElementTypeid(getElementTypeid)
291 , _getShapeData(getShapeData)
292 , _getNumElements(getNumElements)
293 , _proxyHoldsType(proxyHoldsType)
294 , _getProxiedType(getProxiedType)
295 , _getProxiedTypeid(getProxiedTypeid)
296 , _getProxiedObjPtr(getProxiedObjPtr)
297 , _getProxiedAsVtValue(getProxiedAsVtValue)
301 void CopyInit(_Storage
const &
src, _Storage &
dst)
const {
304 void Destroy(_Storage &
storage)
const {
307 void Move(_Storage &src, _Storage &dst)
const noexcept {
310 bool CanHash(_Storage
const &storage)
const {
311 return _canHash(storage);
313 size_t Hash(_Storage
const &storage)
const {
314 return _hash(storage);
316 bool Equal(_Storage
const &lhs, _Storage
const &rhs)
const {
317 return _equal(lhs, rhs);
319 bool EqualPtr(_Storage
const &lhs,
void const *rhs)
const {
320 return _equalPtr(lhs, rhs);
322 void MakeMutable(_Storage &storage)
const {
323 _makeMutable(storage);
326 return _getPyObj(storage);
328 std::ostream &StreamOut(_Storage
const &storage,
329 std::ostream &out)
const {
330 return _streamOut(storage, out);
333 return _isArrayValued(storage);
336 return _getElementTypeid(storage);
338 std::type_info
const &
GetTypeid(_Storage
const &storage)
const {
339 return _getTypeid(storage);
341 const Vt_ShapeData* GetShapeData(_Storage
const &storage)
const {
342 return _getShapeData(storage);
344 size_t GetNumElements(_Storage
const &storage)
const {
345 return _getNumElements(storage);
347 bool ProxyHoldsType(_Storage
const &storage,
348 std::type_info
const &
t)
const {
349 return _proxyHoldsType(storage, t);
351 TfType GetProxiedType(_Storage
const &storage)
const {
352 return _getProxiedType(storage);
354 std::type_info
const &GetProxiedTypeid(_Storage
const &storage)
const {
355 return _getProxiedTypeid(storage);
357 VtValue GetProxiedAsVtValue(_Storage
const &storage)
const {
358 return _getProxiedAsVtValue(storage);
360 void const *GetProxiedObjPtr(_Storage
const &storage)
const {
361 return _getProxiedObjPtr(storage);
364 const std::type_info &typeInfo;
365 const std::type_info &elementTypeInfo;
372 _CopyInitFunc _copyInit;
373 _DestroyFunc _destroy;
375 _CanHashFunc _canHash;
378 _EqualPtrFunc _equalPtr;
379 _MakeMutableFunc _makeMutable;
380 _GetPyObjFunc _getPyObj;
381 _StreamOutFunc _streamOut;
382 _GetTypeidFunc _getTypeid;
383 _IsArrayValuedFunc _isArrayValued;
384 _GetElementTypeidFunc _getElementTypeid;
385 _GetShapeDataFunc _getShapeData;
386 _GetNumElementsFunc _getNumElements;
387 _ProxyHoldsTypeFunc _proxyHoldsType;
388 _GetProxiedTypeFunc _getProxiedType;
389 _GetProxiedTypeidFunc _getProxiedTypeid;
390 _GetProxiedObjPtrFunc _getProxiedObjPtr;
391 _GetProxiedAsVtValueFunc _getProxiedAsVtValue;
397 template <
class T,
class Enable=
void>
400 static const Vt_ShapeData* GetShapeData(
T const &) {
return NULL; }
401 static size_t GetNumElements(
T const &) {
return 0; }
406 template <
class Array>
408 Array, typename std::enable_if<VtIsArray<Array>::value>
::type>
410 static const Vt_ShapeData* GetShapeData(Array
const &obj) {
411 return obj._GetShapeData();
413 static size_t GetNumElements(Array
const &obj) {
417 return typeid(
typename Array::ElementType);
424 _TypedProxyEqualityImpl(
T const &
a,
T const &
b,
int) -> decltype(a == b) {
428 template <
class NoEqual>
430 _TypedProxyEqualityImpl(NoEqual
const &a, NoEqual
const &b,
long) {
436 _ErasedProxyEqualityImpl(
T const &a,
T const &b,
int) -> decltype(a == b) {
440 template <
class NoEqual>
442 _ErasedProxyEqualityImpl(NoEqual
const &a, NoEqual
const &b,
long) {
443 return *VtGetErasedProxiedVtValue(a) == *VtGetErasedProxiedVtValue(b);
447 template <
class T,
class Enable =
void>
452 static bool CanHash(
T const &) {
return VtIsHashable<ProxiedType>(); }
453 static size_t Hash(
T const &obj) {
456 static bool Equal(
T const &a,
T const &b) {
461 return _TypedProxyEqualityImpl(a, b, 0);
464 #ifdef PXR_PYTHON_SUPPORT_ENABLED
470 #endif //PXR_PYTHON_SUPPORT_ENABLED
472 static std::ostream &StreamOut(
T const &obj, std::ostream &out) {
476 return _ArrayHelper<ProxiedType>::GetShapeData(
479 static size_t GetNumElements(
T const &obj) {
480 return _ArrayHelper<ProxiedType>::GetNumElements(
486 static std::type_info
const &
GetTypeid(
T const &) {
487 return typeid(ProxiedType);
490 return _ArrayHelper<ProxiedType>::GetElementTypeid();
492 static VtValue GetProxiedAsVtValue(
T const &obj) {
495 static bool HoldsType(
T const &tp, std::type_info
const &
query) {
498 static TfType GetTfType(
T const &tp) {
499 return TfType::Find<ProxiedType>();
501 static void const *GetObjPtr(
T const &tp) {
506 template <
class ErasedProxy>
508 ErasedProxy, typename std::enable_if<
509 VtIsErasedValueProxy<ErasedProxy>::value>
::type>
511 static bool CanHash(ErasedProxy
const &proxy) {
512 return VtGetErasedProxiedVtValue(proxy)->CanHash();
514 static size_t Hash(ErasedProxy
const &proxy) {
515 return VtGetErasedProxiedVtValue(proxy)->GetHash();
517 static bool Equal(ErasedProxy
const &a, ErasedProxy
const &b) {
522 return _ErasedProxyEqualityImpl(a, b, 0);
525 #ifdef PXR_PYTHON_SUPPORT_ENABLED
526 VtValue const *
val = VtGetErasedProxiedVtValue(obj);
531 #endif //PXR_PYTHON_SUPPORT_ENABLED
533 static std::ostream &
534 StreamOut(ErasedProxy
const &obj, std::ostream &out) {
537 static Vt_ShapeData const *GetShapeData(ErasedProxy
const &obj) {
538 return VtGetErasedProxiedVtValue(obj)->_GetShapeData();
540 static size_t GetNumElements(ErasedProxy
const &obj) {
541 return VtGetErasedProxiedVtValue(obj)->_GetNumElements();
544 return VtGetErasedProxiedVtValue(obj)->IsArrayValued();
546 static std::type_info
const &
GetTypeid(ErasedProxy
const &obj) {
547 return VtGetErasedProxiedVtValue(obj)->GetTypeid();
550 return VtGetErasedProxiedVtValue(obj)->GetElementTypeid();
552 static VtValue GetProxiedAsVtValue(ErasedProxy
const &ep) {
553 return *VtGetErasedProxiedVtValue(ep);
556 HoldsType(ErasedProxy
const &ep, std::type_info
const &
query) {
557 return VtErasedProxyHoldsType(ep, query);
559 static TfType GetTfType(ErasedProxy
const &ep) {
560 return VtGetErasedProxiedTfType(ep);
562 static void const *GetObjPtr(ErasedProxy
const &ep) {
563 VtValue const *
val = VtGetErasedProxiedVtValue(ep);
564 return val ? val->_GetProxiedObjPtr() :
nullptr;
571 template <
class T,
class Container,
class Derived>
572 struct _TypeInfoImpl :
public _TypeInfo
574 static const bool IsLocal = _UsesLocalStore<T>::value;
575 static const bool HasTrivialCopy = _IsTriviallyCopyable<T>::value;
578 using ProxyHelper = _ProxyHelper<T>;
580 using This = _TypeInfoImpl;
582 constexpr _TypeInfoImpl()
583 : _TypeInfo(
typeid(
T),
584 _ArrayHelper<T>::GetElementTypeid(),
585 Vt_KnownValueTypeDetail::GetIndex<T>(),
603 &This::_IsArrayValued,
604 &This::_GetElementTypeid,
605 &This::_GetShapeData,
606 &This::_GetNumElements,
609 &This::_ProxyHoldsType,
610 &This::_GetProxiedType,
611 &This::_GetProxiedTypeid,
612 &This::_GetProxiedObjPtr,
613 &This::_GetProxiedAsVtValue)
618 static T const &GetObj(_Storage
const &
storage) {
619 return Derived::_GetObj(_Container(storage));
622 static T &GetMutableObj(_Storage &storage) {
623 return Derived::_GetMutableObj(_Container(storage));
626 static void CopyInitObj(
T const &objSrc, _Storage &
dst) {
627 Derived::_PlaceCopy(&_Container(dst), objSrc);
631 static_assert(
sizeof(Container) <=
sizeof(_Storage),
632 "Container size cannot exceed storage size.");
636 static void _CopyInit(_Storage
const &
src, _Storage &dst) {
637 new (&_Container(dst)) Container(_Container(src));
640 static void _Destroy(_Storage &storage) {
641 _Container(storage).~Container();
644 static bool _CanHash(_Storage
const &storage) {
645 return ProxyHelper::CanHash(GetObj(storage));
648 static size_t _Hash(_Storage
const &storage) {
652 static bool _Equal(_Storage
const &lhs, _Storage
const &rhs) {
656 return ProxyHelper::Equal(GetObj(lhs), GetObj(rhs));
659 static bool _EqualPtr(_Storage
const &lhs,
void const *rhs) {
663 return ProxyHelper::Equal(
664 GetObj(lhs), *static_cast<T const *>(rhs));
667 static void _Move(_Storage &src, _Storage &dst) noexcept {
668 new (&_Container(dst)) Container(std::move(_Container(src)));
672 static void _MakeMutable(_Storage &storage) {
673 GetMutableObj(storage);
677 return ProxyHelper::GetPyObj(GetObj(storage));
680 static std::ostream &_StreamOut(
681 _Storage
const &storage, std::ostream &out) {
682 return ProxyHelper::StreamOut(GetObj(storage), out);
685 static std::type_info
const &_GetTypeid(_Storage
const &storage) {
686 return ProxyHelper::GetTypeid(GetObj(storage));
689 static bool _IsArrayValued(_Storage
const &storage) {
690 return ProxyHelper::IsArrayValued(GetObj(storage));
693 static std::type_info
const &
694 _GetElementTypeid(_Storage
const &storage) {
695 return ProxyHelper::GetElementTypeid(GetObj(storage));
698 static const Vt_ShapeData* _GetShapeData(_Storage
const &storage) {
699 return ProxyHelper::GetShapeData(GetObj(storage));
702 static size_t _GetNumElements(_Storage
const &storage) {
703 return ProxyHelper::GetNumElements(GetObj(storage));
707 _ProxyHoldsType(_Storage
const &storage, std::type_info
const &
t) {
708 return ProxyHelper::HoldsType(GetObj(storage), t);
712 _GetProxiedType(_Storage
const &storage) {
713 return ProxyHelper::GetTfType(GetObj(storage));
716 static std::type_info
const &
717 _GetProxiedTypeid(_Storage
const &storage) {
718 return ProxyHelper::GetTypeid(GetObj(storage));
722 _GetProxiedObjPtr(_Storage
const &storage) {
723 return ProxyHelper::GetObjPtr(GetObj(storage));
727 _GetProxiedAsVtValue(_Storage
const &storage) {
728 return ProxyHelper::GetProxiedAsVtValue(GetObj(storage));
734 static Container &_Container(_Storage &storage) {
736 return *
reinterpret_cast<Container *
>(&
storage);
738 static Container
const &_Container(_Storage
const &storage) {
740 return *
reinterpret_cast<Container
const *
>(&
storage);
748 struct _LocalTypeInfo : _TypeInfoImpl<
754 constexpr _LocalTypeInfo()
755 : _TypeInfoImpl<T, T, _LocalTypeInfo<T>>()
759 static T &_GetMutableObj(
T &obj) {
return obj; }
760 static T const &_GetObj(
T const &obj) {
return obj; }
762 static void _PlaceCopy(
T *
dst,
T const &
src) {
new (
dst)
T(src); }
769 struct _RemoteTypeInfo : _TypeInfoImpl<
771 hboost::intrusive_ptr<_Counted<T> >,
775 constexpr _RemoteTypeInfo()
777 T, hboost::intrusive_ptr<_Counted<T>>, _RemoteTypeInfo<T>>()
780 typedef hboost::intrusive_ptr<_Counted<T> > Ptr;
782 static T &_GetMutableObj(Ptr &
ptr) {
783 if (!ptr->IsUnique())
784 ptr.reset(
new _Counted<T>(ptr->Get()));
785 return ptr->GetMutable();
787 static T const &_GetObj(Ptr
const &ptr) {
return ptr->Get(); }
789 static void _PlaceCopy(Ptr *
dst,
T const &
src) {
790 new (
dst) Ptr(
new _Counted<T>(src));
796 struct _TypeInfoFor {
800 _RemoteTypeInfo<T>>
Type;
805 struct _TypeInfoFor<char[N]> : _TypeInfoFor<std::string> {};
811 typedef typename _TypeInfoFor<T>::Type TI;
813 static constexpr
unsigned int flags =
814 (TI::IsLocal ? _LocalFlag : 0) |
815 (TI::HasTrivialCopy ? _TrivialCopyFlag : 0) |
816 (TI::IsProxy ? _ProxyFlag : 0);
829 : info((val->
IsEmpty() || val->_IsLocalAndTriviallyCopyable())
830 ? static_cast<_TypeInfo const *>(NULL) : val->_info.
Get()) {
832 info->Move(val->_storage,
storage);
839 _TypeInfo
const *info;
845 _Init(
T const &obj) {
846 _info = GetTypeInfo<T>();
848 TypeInfo::CopyInitObj(obj, _storage);
854 _Init(
T const &obj) {
930 _TypeInfoFor<T>::Type::IsLocal &&
931 _TypeInfoFor<T>::Type::HasTrivialCopy,
948 !_TypeInfoFor<T>::Type::IsLocal ||
949 !_TypeInfoFor<T>::Type::HasTrivialCopy,
968 return *
this =
const_cast<char const *
>(cstr);
974 if (!
IsEmpty() || !rhs.IsEmpty()) {
1019 swap(_GetMutable<T>(), rhs);
1051 template <
class T,
class Fn>
1055 if (!IsHolding<T>()) {
1058 UncheckedMutate<T>(std::forward<Fn>(mutateFn));
1065 template <
class T,
class Fn>
1072 T &stored =_GetMutable<T>();
1073 T tmp = std::move(stored);
1074 std::forward<Fn>(mutateFn)(tmp);
1075 stored = std::move(tmp);
1111 return _info->GetProxiedAsVtValue(
1112 _storage).GetKnownValueTypeIndex();
1114 return _info.
GetLiteral() ? _info->knownTypeIndex : -1;
1143 return *(
static_cast<T const *
>(
1144 _FailGet(Factory::Invoke,
typeid(
T))));
1159 return *(
static_cast<T const *
>(
1160 _FailGet(Factory::Invoke,
typeid(
T))));
1163 return UncheckedRemove<T>();
1172 return IsHolding<T>() ? UncheckedGet<T>() : def;
1176 template <
typename From,
typename To>
1178 _RegisterCast(
typeid(From),
typeid(To), castFn);
1183 template <
typename From,
typename To>
1185 _RegisterCast(
typeid(From),
typeid(To), _SimpleCast<From, To>);
1190 template <
typename From,
typename To>
1192 RegisterSimpleCast<From, To>();
1193 RegisterSimpleCast<To, From>();
1203 template <
typename T>
1234 std::type_info
const &to) {
1235 return _CanCast(from, to);
1245 template <
typename T>
1249 return *
this = _PerformCast(
typeid(
T), *
this);
1272 *
this = _PerformCast(type, *
this);
1280 template <
typename T>
1313 template <
typename T>
1318 template <
typename T>
1324 template <
typename T>
1326 return !(lhs == rhs);
1328 template <
typename T>
1330 return !(lhs == rhs);
1336 if (empty || rhsEmpty) {
1338 return empty == rhsEmpty;
1342 return _info.
Get()->Equal(_storage, rhs._storage);
1344 return _EqualityImpl(rhs);
1349 VT_API friend std::ostream &
1354 VT_API size_t _GetNumElements()
const;
1364 dst._info = src._info;
1365 if (src._IsLocalAndTriviallyCopyable()) {
1366 dst._storage = src._storage;
1368 dst._info->CopyInit(src._storage, dst._storage);
1379 dst._info = src._info;
1380 if (src._IsLocalAndTriviallyCopyable()) {
1381 dst._storage = src._storage;
1383 dst._info->Move(src._storage, dst._storage);
1386 src._info.
Set(
nullptr, 0);
1392 return _info->knownTypeIndex == VtGetKnownValueTypeIndex<T>() ||
1399 std::type_info
const &
t =
typeid(
T);
1404 VT_API bool _TypeIsImpl(std::type_info
const &queriedType)
const;
1408 template <
class Proxy>
1412 return TypeInfo::GetMutableObj(_storage);
1420 *
this = _info->GetProxiedAsVtValue(_storage);
1423 return TypeInfo::GetMutableObj(_storage);
1426 template <
class Proxy>
1430 return TypeInfo::GetObj(_storage);
1438 return *
static_cast<T const *
>(_GetProxiedObjPtr());
1440 return TypeInfo::GetObj(_storage);
1443 void const *_GetProxiedObjPtr()
const {
1444 return _info->GetProxiedObjPtr(_storage);
1451 std::type_info
const &queryType)
const;
1453 inline void _Clear() {
1458 if (_info.
GetLiteral() && !_IsLocalAndTriviallyCopyable())
1459 _info.
Get()->Destroy(_storage);
1461 _info.
Set(
nullptr, 0);
1464 inline bool _IsLocalAndTriviallyCopyable()
const {
1465 unsigned int bits = _info.
BitsAs<
unsigned int>();
1466 return (bits & (_LocalFlag | _TrivialCopyFlag)) ==
1467 (_LocalFlag | _TrivialCopyFlag);
1470 inline bool _IsProxy()
const {
1471 return _info.
BitsAs<
unsigned int>() & _ProxyFlag;
1474 VT_API static void _RegisterCast(std::type_info
const &from,
1475 std::type_info
const &to,
1481 _PerformCast(std::type_info
const &to,
VtValue const &val);
1486 _CanCast(std::type_info
const &from, std::type_info
const &to);
1489 template <
typename From,
typename To>
1511 return value._GetShapeData();
1515 return value._GetNumElements();
1530 return Vt_DefaultValueHolder::Create<T>();
1541 #define _VT_DECLARE_ZERO_VALUE_FACTORY(unused, elem) \
1543 VT_API Vt_DefaultValueHolder Vt_DefaultValueFactory<VT_TYPE(elem)>::Invoke();
1551 #undef _VT_DECLARE_ZERO_VALUE_FACTORY
1560 VtValue::Get<VtValue>()
const & {
1566 VtValue::Get<VtValue>() && {
1567 return std::move(*
this);
1572 VtValue::UncheckedGet<VtValue>()
const & {
1578 VtValue::UncheckedGet<VtValue>() && {
1579 return std::move(*
this);
1584 VtValue::IsHolding<VtValue>()
const {
1591 VtValue::IsHolding<void>()
const {
1601 #endif // PXR_BASE_VT_VALUE_H
typename std::enable_if< B, T >::type enable_if_t
Define Imath::enable_if_t to be std for C++14, equivalent for C++11.
static Vt_DefaultValueHolder Create(T const &val)
T const & UncheckedGet() const &
STATIC_INLINE size_t Hash(const char *s, size_t len)
friend TfPyObjWrapper Vt_GetPythonObjectFromHeldValue(VtValue const &self)
static VtValue Take(T &obj)
getFileOption("OpenEXR:storage") storage
void swap(UT::ArraySet< Key, MULTI, MAX_LOAD_FACTOR_256, Clearer, Hash, KeyEqual > &a, UT::ArraySet< Key, MULTI, MAX_LOAD_FACTOR_256, Clearer, Hash, KeyEqual > &b)
VtValue & CastToTypeOf(VtValue const &other)
static void RegisterCast(VtValue(*castFn)(VtValue const &))
Register a cast from VtValue holding From to VtValue holding To.
GLsizei const GLchar *const * string
GLsizei const GLfloat * value
static const Vt_ShapeData * _GetShapeData(const VtValue &value)
VtValue & operator=(char const *cstr)
Assigning a char const * gives a VtValue holding a std::string.
std::enable_if_t< !_TypeInfoFor< T >::Type::IsLocal||!_TypeInfoFor< T >::Type::HasTrivialCopy, VtValue & > operator=(T const &obj)
Assignment operator from any type.
GLboolean GLboolean GLboolean GLboolean a
size_t GetArraySize() const
std::enable_if_t< std::is_same< T, typename Vt_ValueGetStored< T >::Type >::value > Swap(T &rhs)
Swap the held value with rhs. If this value is holding a T,.
IMATH_HOSTDEVICE constexpr bool equal(T1 a, T2 b, T3 t) IMATH_NOEXCEPT
VtValue & Swap(VtValue &rhs) noexcept
Swap this with rhs.
**But if you need a result
bool IsEmpty() const
Returns true iff this value is empty.
#define VT_DUALQUATERNION_VALUE_TYPES
VtValue & operator=(char *cstr)
Assigning a char * gives a VtValue holding a std::string.
T const & VtGetProxiedObject(T const &nonProxy)
static size_t _GetNumElements(const VtValue &value)
VtValue(VtValue const &other)
Copy construct with other.
constexpr T * Get() const noexcept
Retrieve the pointer.
bool CanCastToTypeOf(VtValue const &other) const
static VT_API VtValue CastToTypeOf(VtValue const &val, VtValue const &other)
int GetKnownValueTypeIndex() const
constexpr uintptr_t GetLiteral() const noexcept
static VT_API VtValue CastToTypeid(VtValue const &val, std::type_info const &type)
void intrusive_ptr_release(T *x)
std::enable_if_t< std::is_same< T, typename Vt_ValueGetStored< T >::Type >::value > UncheckedMutate(Fn &&mutateFn)
VT_API bool IsArrayValued() const
Returns true iff this is holding an array type (see VtIsArray<>).
TF_PP_SEQ_FOR_EACH(_VT_DECLARE_ZERO_VALUE_FACTORY,~, VT_VEC_VALUE_TYPES VT_MATRIX_VALUE_TYPES VT_QUATERNION_VALUE_TYPES VT_DUALQUATERNION_VALUE_TYPES) template<> inline const VtValue &VtValue
VT_API std::type_info const & GetElementTypeid() const
#define _VT_DECLARE_ZERO_VALUE_FACTORY(unused, elem)
std::enable_if_t< _TypeInfoFor< T >::Type::IsLocal &&_TypeInfoFor< T >::Type::HasTrivialCopy, VtValue & > operator=(T obj)
friend bool operator!=(VtValue const &lhs, T const &rhs)
Tests for inequality.
void UncheckedSwap(VtValue &rhs)
typename std::decay< decltype(VtGetProxiedObject(std::declval< T >()))>::type type
constexpr Integral BitsAs() const noexcept
Retrieve the stored bits as the integral type Integral.
static bool CanCastFromTypeidToTypeid(std::type_info const &from, std::type_info const &to)
friend bool operator==(VtValue const &lhs, T const &rhs)
Tests for equality.
#define VT_VEC_VALUE_TYPES
VT_API std::ostream & VtStreamOut(std::vector< VtValue > const &val, std::ostream &)
#define VT_VALUE_SET_STORED_TYPE(SRC, DST)
VtValue(VtValue &&other) noexcept
Move construct with other.
GLboolean GLboolean GLboolean b
void const * GetPointer() const
VtValue & operator=(VtValue &&other) noexcept
Move assignment from another VtValue.
void Set(T *ptr) noexcept
Set the pointer value to ptr.
VT_API std::type_info const & GetTypeid() const
Returns the typeid of the type held by this value.
Array concept. By default, types are not arrays.
VT_API size_t GetHash() const
Return a hash code for the held object by calling VtHashValue() on it.
std::enable_if_t< std::is_same< T, typename Vt_ValueGetStored< T >::Type >::value > UncheckedSwap(T &rhs)
void intrusive_ptr_add_ref(T *x)
VtValue & operator=(VtValue const &other)
Copy assignment from another VtValue.
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
friend size_t hash_value(VtValue const &val)
#define ARCH_PRAGMA_MAYBE_UNINITIALIZED
size_t VtHashValue(T const &val)
std::enable_if_t< std::is_same< T, typename Vt_ValueGetStored< T >::Type >::value, bool > Mutate(Fn &&mutateFn)
static VtValue Cast(VtValue const &val)
std::type_info const & GetType() const
static Vt_DefaultValueHolder Create()
VT_API std::string GetTypeName() const
Return the type name of the held typeid.
#define PXR_NAMESPACE_CLOSE_SCOPE
friend void swap(VtValue &lhs, VtValue &rhs)
Overloaded swap() for generic code/stl/etc.
static void RegisterSimpleCast()
Register a simple cast from VtValue holding From to VtValue.
static TfAnyUniquePtr New()
#define VT_QUATERNION_VALUE_TYPES
VtValue & CastToTypeid(std::type_info const &type)
PXR_NAMESPACE_OPEN_SCOPE bool TfSafeTypeCompare(const std::type_info &t1, const std::type_info &t2)
VtValue()
Default ctor gives empty VtValue.
static void RegisterSimpleBidirectionalCast()
VT_API friend std::ostream & operator<<(std::ostream &out, const VtValue &self)
Calls through to operator << on the held object.
T GetWithDefault(T const &def=T()) const
static Vt_DefaultValueHolder Invoke()
#define VT_MATRIX_VALUE_TYPES
bool CanCastToTypeid(std::type_info const &type) const
VT_API TfType GetType() const
Returns the TfType of the type held by this value.
VT_API bool CanHash() const
Return true if the held object provides a hash implementation.
void const * Get() const
Return a pointer to the owned object.