24 #ifndef PXR_BASE_VT_VALUE_H
25 #define PXR_BASE_VT_VALUE_H
29 #ifdef PXR_PYTHON_SUPPORT_ENABLED
33 #endif // PXR_PYTHON_SUPPORT_ENABLED
52 #include <hboost/intrusive_ptr.hpp>
53 #include <hboost/type_traits/has_trivial_assign.hpp>
54 #include <hboost/type_traits/has_trivial_constructor.hpp>
55 #include <hboost/type_traits/has_trivial_copy.hpp>
56 #include <hboost/type_traits/has_trivial_destructor.hpp>
60 #include <type_traits>
101 : _ptr(std::move(
ptr)), _type(&type) {}
104 std::type_info
const *_type;
113 #define VT_VALUE_SET_STORED_TYPE(SRC, DST) \
114 template <> struct Vt_ValueStoredType<SRC> { typedef DST Type; }
120 #ifdef PXR_PYTHON_SUPPORT_ENABLED
122 #endif // PXR_PYTHON_SUPPORT_ENABLED
124 #undef VT_VALUE_SET_STORED_TYPE
170 static const unsigned int _LocalFlag = 1 << 0;
171 static const unsigned int _TrivialCopyFlag = 1 << 1;
172 static const unsigned int _ProxyFlag = 1 << 2;
176 explicit _Counted(
T const &
obj) : _obj(obj) {
179 bool IsUnique()
const {
return _refCount == 1; }
180 T const &
Get()
const {
return _obj; }
181 T &GetMutable() {
return _obj; }
185 mutable std::atomic<int> _refCount;
188 d->_refCount.fetch_add(1, std::memory_order_relaxed);
191 if (d->_refCount.fetch_sub(1, std::memory_order_release) == 1) {
192 std::atomic_thread_fence(std::memory_order_acquire);
201 static const size_t _MaxLocalSize =
sizeof(
void*);
202 typedef std::aligned_storage<
203 _MaxLocalSize, _MaxLocalSize>
::type _Storage;
206 using _IsTriviallyCopyable = std::integral_constant<bool,
215 using _UsesLocalStore = std::integral_constant<bool,
216 (
sizeof(
T) <=
sizeof(_Storage)) &&
224 using _CopyInitFunc =
void (*)(_Storage
const &, _Storage &);
225 using _DestroyFunc =
void (*)(_Storage &);
226 using _MoveFunc =
void (*)(_Storage &, _Storage &);
227 using _CanHashFunc = bool (*)(_Storage
const &);
228 using _HashFunc = size_t (*)(_Storage
const &);
229 using _EqualFunc = bool (*)(_Storage
const &, _Storage
const &);
230 using _EqualPtrFunc = bool (*)(_Storage
const &,
void const *);
231 using _MakeMutableFunc =
void (*)(_Storage &);
232 #ifdef PXR_PYTHON_SUPPORT_ENABLED
234 #endif // PXR_PYTHON_SUPPORT_ENABLED
235 using _StreamOutFunc =
236 std::ostream & (*)(_Storage
const &, std::ostream &);
237 using _GetTypeidFunc = std::type_info
const & (*)(_Storage
const &);
238 using _IsArrayValuedFunc = bool (*)(_Storage
const &);
239 using _GetElementTypeidFunc =
240 std::type_info
const & (*)(_Storage
const &);
241 using _GetShapeDataFunc =
const Vt_ShapeData* (*)(_Storage
const &);
242 using _GetNumElementsFunc = size_t (*)(_Storage
const &);
243 using _ProxyHoldsTypeFunc = bool (*)(_Storage
const &, std::type_info
const &);
244 using _GetProxiedTypeFunc =
TfType (*)(_Storage
const &);
245 using _GetProxiedTypeidFunc =
246 std::type_info
const & (*)(_Storage
const &);
247 using _GetProxiedObjPtrFunc =
void const *(*)(_Storage
const &);
248 using _GetProxiedAsVtValueFunc =
VtValue (*)(_Storage
const &);
251 constexpr _TypeInfo(
const std::type_info &ti,
252 const std::type_info &elementTi,
256 _CopyInitFunc copyInit,
257 _DestroyFunc destroy,
259 _CanHashFunc canHash,
262 _EqualPtrFunc equalPtr,
263 _MakeMutableFunc makeMutable,
265 _GetPyObjFunc getPyObj,
267 _StreamOutFunc streamOut,
268 _GetTypeidFunc getTypeid,
269 _IsArrayValuedFunc isArrayValued,
270 _GetElementTypeidFunc getElementTypeid,
271 _GetShapeDataFunc getShapeData,
272 _GetNumElementsFunc getNumElements,
273 _ProxyHoldsTypeFunc proxyHoldsType,
274 _GetProxiedTypeFunc getProxiedType,
275 _GetProxiedTypeidFunc getProxiedTypeid,
276 _GetProxiedObjPtrFunc getProxiedObjPtr,
277 _GetProxiedAsVtValueFunc getProxiedAsVtValue)
279 , elementTypeInfo(elementTi)
282 , isHashable(isHashable)
284 , _copyInit(copyInit)
290 , _equalPtr(equalPtr)
291 , _makeMutable(makeMutable)
292 #ifdef PXR_PYTHON_SUPPORT_ENABLED
293 , _getPyObj(getPyObj)
294 #endif // PXR_PYTHON_SUPPORT_ENABLED
295 , _streamOut(streamOut)
296 , _getTypeid(getTypeid)
297 , _isArrayValued(isArrayValued)
298 , _getElementTypeid(getElementTypeid)
299 , _getShapeData(getShapeData)
300 , _getNumElements(getNumElements)
301 , _proxyHoldsType(proxyHoldsType)
302 , _getProxiedType(getProxiedType)
303 , _getProxiedTypeid(getProxiedTypeid)
304 , _getProxiedObjPtr(getProxiedObjPtr)
305 , _getProxiedAsVtValue(getProxiedAsVtValue)
309 void CopyInit(_Storage
const &
src, _Storage &
dst)
const {
312 void Destroy(_Storage &
storage)
const {
315 void Move(_Storage &src, _Storage &dst)
const noexcept {
318 bool CanHash(_Storage
const &storage)
const {
319 return _canHash(storage);
321 size_t Hash(_Storage
const &storage)
const {
322 return _hash(storage);
324 bool Equal(_Storage
const &lhs, _Storage
const &rhs)
const {
325 return _equal(lhs, rhs);
327 bool EqualPtr(_Storage
const &lhs,
void const *rhs)
const {
328 return _equalPtr(lhs, rhs);
330 void MakeMutable(_Storage &storage)
const {
331 _makeMutable(storage);
333 #ifdef PXR_PYTHON_SUPPORT_ENABLED
335 return _getPyObj(storage);
337 #endif // PXR_PYTHON_SUPPORT_ENABLED
338 std::ostream &StreamOut(_Storage
const &storage,
339 std::ostream &out)
const {
340 return _streamOut(storage, out);
343 return _isArrayValued(storage);
346 return _getElementTypeid(storage);
348 std::type_info
const &
GetTypeid(_Storage
const &storage)
const {
349 return _getTypeid(storage);
351 const Vt_ShapeData* GetShapeData(_Storage
const &storage)
const {
352 return _getShapeData(storage);
354 size_t GetNumElements(_Storage
const &storage)
const {
355 return _getNumElements(storage);
357 bool ProxyHoldsType(_Storage
const &storage,
358 std::type_info
const &
t)
const {
359 return _proxyHoldsType(storage, t);
361 TfType GetProxiedType(_Storage
const &storage)
const {
362 return _getProxiedType(storage);
364 std::type_info
const &GetProxiedTypeid(_Storage
const &storage)
const {
365 return _getProxiedTypeid(storage);
367 VtValue GetProxiedAsVtValue(_Storage
const &storage)
const {
368 return _getProxiedAsVtValue(storage);
370 void const *GetProxiedObjPtr(_Storage
const &storage)
const {
371 return _getProxiedObjPtr(storage);
374 const std::type_info &typeInfo;
375 const std::type_info &elementTypeInfo;
381 _CopyInitFunc _copyInit;
382 _DestroyFunc _destroy;
384 _CanHashFunc _canHash;
387 _EqualPtrFunc _equalPtr;
388 _MakeMutableFunc _makeMutable;
389 #ifdef PXR_PYTHON_SUPPORT_ENABLED
390 _GetPyObjFunc _getPyObj;
391 #endif // PXR_PYTHON_SUPPORT_ENABLED
392 _StreamOutFunc _streamOut;
393 _GetTypeidFunc _getTypeid;
394 _IsArrayValuedFunc _isArrayValued;
395 _GetElementTypeidFunc _getElementTypeid;
396 _GetShapeDataFunc _getShapeData;
397 _GetNumElementsFunc _getNumElements;
398 _ProxyHoldsTypeFunc _proxyHoldsType;
399 _GetProxiedTypeFunc _getProxiedType;
400 _GetProxiedTypeidFunc _getProxiedTypeid;
401 _GetProxiedObjPtrFunc _getProxiedObjPtr;
402 _GetProxiedAsVtValueFunc _getProxiedAsVtValue;
408 template <
class T,
class Enable=
void>
411 static const Vt_ShapeData* GetShapeData(
T const &) {
return NULL; }
412 static size_t GetNumElements(
T const &) {
return 0; }
417 template <
class Array>
419 Array, typename std::enable_if<VtIsArray<Array>::value>
::type>
422 return obj._GetShapeData();
424 static size_t GetNumElements(Array
const &obj) {
428 return typeid(
typename Array::ElementType);
435 _TypedProxyEqualityImpl(
T const &
a,
T const &
b,
int) -> decltype(a == b) {
439 template <
class NoEqual>
441 _TypedProxyEqualityImpl(NoEqual
const &a, NoEqual
const &b,
long) {
447 _ErasedProxyEqualityImpl(
T const &a,
T const &b,
int) -> decltype(a == b) {
451 template <
class NoEqual>
453 _ErasedProxyEqualityImpl(NoEqual
const &a, NoEqual
const &b,
long) {
454 return *VtGetErasedProxiedVtValue(a) == *VtGetErasedProxiedVtValue(b);
458 template <
class T,
class Enable =
void>
463 static bool CanHash(
T const &) {
return VtIsHashable<ProxiedType>(); }
467 static bool Equal(
T const &a,
T const &b) {
472 return _TypedProxyEqualityImpl(a, b, 0);
474 #ifdef PXR_PYTHON_SUPPORT_ENABLED
480 #endif //PXR_PYTHON_SUPPORT_ENABLED
481 static std::ostream &StreamOut(
T const &obj, std::ostream &out) {
485 return _ArrayHelper<ProxiedType>::GetShapeData(
488 static size_t GetNumElements(
T const &obj) {
489 return _ArrayHelper<ProxiedType>::GetNumElements(
495 static std::type_info
const &
GetTypeid(
T const &) {
496 return typeid(ProxiedType);
499 return _ArrayHelper<ProxiedType>::GetElementTypeid();
501 static VtValue GetProxiedAsVtValue(
T const &obj) {
504 static bool HoldsType(
T const &tp, std::type_info
const &
query) {
507 static TfType GetTfType(
T const &tp) {
508 return TfType::Find<ProxiedType>();
510 static void const *GetObjPtr(
T const &tp) {
515 template <
class ErasedProxy>
517 ErasedProxy, typename std::enable_if<
518 VtIsErasedValueProxy<ErasedProxy>::value>
::type>
520 static bool CanHash(ErasedProxy
const &proxy) {
521 return VtGetErasedProxiedVtValue(proxy)->CanHash();
523 static size_t Hash(ErasedProxy
const &proxy) {
524 return VtGetErasedProxiedVtValue(proxy)->GetHash();
526 static bool Equal(ErasedProxy
const &a, ErasedProxy
const &b) {
531 return _ErasedProxyEqualityImpl(a, b, 0);
533 #ifdef PXR_PYTHON_SUPPORT_ENABLED
535 VtValue const *
val = VtGetErasedProxiedVtValue(obj);
539 #endif //PXR_PYTHON_SUPPORT_ENABLED
541 static std::ostream &
542 StreamOut(ErasedProxy
const &obj, std::ostream &out) {
545 static Vt_ShapeData const *GetShapeData(ErasedProxy
const &obj) {
546 return VtGetErasedProxiedVtValue(obj)->_GetShapeData();
548 static size_t GetNumElements(ErasedProxy
const &obj) {
549 return VtGetErasedProxiedVtValue(obj)->_GetNumElements();
552 return VtGetErasedProxiedVtValue(obj)->IsArrayValued();
554 static std::type_info
const &
GetTypeid(ErasedProxy
const &obj) {
555 return VtGetErasedProxiedVtValue(obj)->GetTypeid();
558 return VtGetErasedProxiedVtValue(obj)->GetElementTypeid();
560 static VtValue GetProxiedAsVtValue(ErasedProxy
const &ep) {
561 return *VtGetErasedProxiedVtValue(ep);
564 HoldsType(ErasedProxy
const &ep, std::type_info
const &
query) {
565 return VtErasedProxyHoldsType(ep, query);
567 static TfType GetTfType(ErasedProxy
const &ep) {
568 return VtGetErasedProxiedTfType(ep);
570 static void const *GetObjPtr(ErasedProxy
const &ep) {
571 VtValue const *
val = VtGetErasedProxiedVtValue(ep);
572 return val ? val->_GetProxiedObjPtr() :
nullptr;
579 template <
class T,
class Container,
class Derived>
580 struct _TypeInfoImpl :
public _TypeInfo
582 static const bool IsLocal = _UsesLocalStore<T>::value;
583 static const bool HasTrivialCopy = _IsTriviallyCopyable<T>::value;
586 using ProxyHelper = _ProxyHelper<T>;
588 using This = _TypeInfoImpl;
590 constexpr _TypeInfoImpl()
591 : _TypeInfo(
typeid(
T),
592 _ArrayHelper<T>::GetElementTypeid(),
612 &This::_IsArrayValued,
613 &This::_GetElementTypeid,
614 &This::_GetShapeData,
615 &This::_GetNumElements,
618 &This::_ProxyHoldsType,
619 &This::_GetProxiedType,
620 &This::_GetProxiedTypeid,
621 &This::_GetProxiedObjPtr,
622 &This::_GetProxiedAsVtValue)
627 static T const &GetObj(_Storage
const &
storage) {
628 return Derived::_GetObj(_Container(storage));
631 static T &GetMutableObj(_Storage &storage) {
632 return Derived::_GetMutableObj(_Container(storage));
635 static void CopyInitObj(
T const &objSrc, _Storage &
dst) {
636 Derived::_PlaceCopy(&_Container(dst), objSrc);
640 static_assert(
sizeof(Container) <=
sizeof(_Storage),
641 "Container size cannot exceed storage size.");
645 static void _CopyInit(_Storage
const &
src, _Storage &dst) {
646 new (&_Container(dst)) Container(_Container(src));
649 static void _Destroy(_Storage &storage) {
650 _Container(storage).~Container();
653 static bool _CanHash(_Storage
const &storage) {
654 return ProxyHelper::CanHash(GetObj(storage));
657 static size_t _Hash(_Storage
const &storage) {
661 static bool _Equal(_Storage
const &lhs, _Storage
const &rhs) {
665 return ProxyHelper::Equal(GetObj(lhs), GetObj(rhs));
668 static bool _EqualPtr(_Storage
const &lhs,
void const *rhs) {
672 return ProxyHelper::Equal(
673 GetObj(lhs), *static_cast<T const *>(rhs));
676 static void _Move(_Storage &src, _Storage &dst) noexcept {
677 new (&_Container(dst)) Container(std::move(_Container(src)));
681 static void _MakeMutable(_Storage &storage) {
682 GetMutableObj(storage);
685 #ifdef PXR_PYTHON_SUPPORT_ENABLED
687 return ProxyHelper::GetPyObj(GetObj(storage));
689 #endif // PXR_PYTHON_SUPPORT_ENABLED
691 static std::ostream &_StreamOut(
692 _Storage
const &storage, std::ostream &out) {
693 return ProxyHelper::StreamOut(GetObj(storage), out);
696 static std::type_info
const &_GetTypeid(_Storage
const &storage) {
697 return ProxyHelper::GetTypeid(GetObj(storage));
700 static bool _IsArrayValued(_Storage
const &storage) {
701 return ProxyHelper::IsArrayValued(GetObj(storage));
704 static std::type_info
const &
705 _GetElementTypeid(_Storage
const &storage) {
706 return ProxyHelper::GetElementTypeid(GetObj(storage));
709 static const Vt_ShapeData* _GetShapeData(_Storage
const &storage) {
710 return ProxyHelper::GetShapeData(GetObj(storage));
713 static size_t _GetNumElements(_Storage
const &storage) {
714 return ProxyHelper::GetNumElements(GetObj(storage));
718 _ProxyHoldsType(_Storage
const &storage, std::type_info
const &
t) {
719 return ProxyHelper::HoldsType(GetObj(storage), t);
723 _GetProxiedType(_Storage
const &storage) {
724 return ProxyHelper::GetTfType(GetObj(storage));
727 static std::type_info
const &
728 _GetProxiedTypeid(_Storage
const &storage) {
729 return ProxyHelper::GetTypeid(GetObj(storage));
733 _GetProxiedObjPtr(_Storage
const &storage) {
734 return ProxyHelper::GetObjPtr(GetObj(storage));
738 _GetProxiedAsVtValue(_Storage
const &storage) {
739 return ProxyHelper::GetProxiedAsVtValue(GetObj(storage));
745 static Container &_Container(_Storage &storage) {
747 return *
reinterpret_cast<Container *
>(&
storage);
749 static Container
const &_Container(_Storage
const &storage) {
751 return *
reinterpret_cast<Container
const *
>(&
storage);
759 struct _LocalTypeInfo : _TypeInfoImpl<
765 constexpr _LocalTypeInfo()
766 : _TypeInfoImpl<T, T, _LocalTypeInfo<T>>()
770 static T &_GetMutableObj(
T &
obj) {
return obj; }
771 static T const &_GetObj(
T const &obj) {
return obj; }
773 static void _PlaceCopy(
T *
dst,
T const &
src) {
new (
dst)
T(src); }
780 struct _RemoteTypeInfo : _TypeInfoImpl<
782 hboost::intrusive_ptr<_Counted<T> >,
786 constexpr _RemoteTypeInfo()
788 T, hboost::intrusive_ptr<_Counted<T>>, _RemoteTypeInfo<T>>()
791 typedef hboost::intrusive_ptr<_Counted<T> > Ptr;
793 static T &_GetMutableObj(Ptr &
ptr) {
794 if (!ptr->IsUnique())
795 ptr.reset(
new _Counted<T>(ptr->Get()));
796 return ptr->GetMutable();
798 static T const &_GetObj(Ptr
const &ptr) {
return ptr->Get(); }
800 static void _PlaceCopy(Ptr *
dst,
T const &
src) {
801 new (
dst) Ptr(
new _Counted<T>(src));
807 struct _TypeInfoFor {
811 _RemoteTypeInfo<T>>
Type;
816 struct _TypeInfoFor<char[N]> : _TypeInfoFor<std::string> {};
822 typedef typename _TypeInfoFor<T>::Type TI;
824 static constexpr
unsigned int flags =
825 (TI::IsLocal ? _LocalFlag : 0) |
826 (TI::HasTrivialCopy ? _TrivialCopyFlag : 0) |
827 (TI::IsProxy ? _ProxyFlag : 0);
840 : info((val->
IsEmpty() || val->_IsLocalAndTriviallyCopyable())
841 ? static_cast<_TypeInfo
const *>(NULL) : val->_info.
Get()) {
843 info->Move(val->_storage,
storage);
850 _TypeInfo
const *info;
856 _Init(
T const &
obj) {
857 _info = GetTypeInfo<T>();
859 TypeInfo::CopyInitObj(obj, _storage);
865 _Init(
T const &
obj) {
941 _TypeInfoFor<T>::Type::IsLocal &&
942 _TypeInfoFor<T>::Type::HasTrivialCopy,
959 !_TypeInfoFor<T>::Type::IsLocal ||
960 !_TypeInfoFor<T>::Type::HasTrivialCopy,
979 return *
this =
const_cast<char const *
>(cstr);
985 if (!
IsEmpty() || !rhs.IsEmpty()) {
1010 if (!IsHolding<T>())
1030 swap(_GetMutable<T>(), rhs);
1107 return *(
static_cast<T const *
>(
1108 _FailGet(Factory::Invoke,
typeid(
T))));
1120 return IsHolding<T>() ? UncheckedGet<T>() : def;
1124 template <
typename From,
typename To>
1126 _RegisterCast(
typeid(From),
typeid(To), castFn);
1131 template <
typename From,
typename To>
1133 _RegisterCast(
typeid(From),
typeid(To), _SimpleCast<From, To>);
1138 template <
typename From,
typename To>
1140 RegisterSimpleCast<From, To>();
1141 RegisterSimpleCast<To, From>();
1151 template <
typename T>
1154 return ret.
Cast<
T>();
1181 std::type_info
const &to) {
1182 return _CanCast(from, to);
1192 template <
typename T>
1196 return *
this = _PerformCast(
typeid(
T), *
this);
1207 return *
this = _PerformCast(other.
GetTypeid(), *
this);
1218 return *
this = _PerformCast(type, *
this);
1224 template <
typename T>
1257 template <
typename T>
1262 template <
typename T>
1268 template <
typename T>
1270 return !(lhs == rhs);
1272 template <
typename T>
1274 return !(lhs == rhs);
1280 if (empty || rhsEmpty) {
1282 return empty == rhsEmpty;
1286 return _info.
Get()->Equal(_storage, rhs._storage);
1288 return _EqualityImpl(rhs);
1293 VT_API friend std::ostream &
1298 VT_API size_t _GetNumElements()
const;
1308 dst._info = src._info;
1309 if (src._IsLocalAndTriviallyCopyable()) {
1310 dst._storage = src._storage;
1312 dst._info->CopyInit(src._storage, dst._storage);
1323 dst._info = src._info;
1324 if (src._IsLocalAndTriviallyCopyable()) {
1325 dst._storage = src._storage;
1327 dst._info->Move(src._storage, dst._storage);
1330 src._info.
Set(
nullptr, 0);
1334 inline bool _TypeIs()
const {
1335 std::type_info
const &
t =
typeid(
T);
1337 return ARCH_UNLIKELY(_IsProxy() && !cmp) ? _TypeIsImpl(t) : cmp;
1340 VT_API bool _TypeIsImpl(std::type_info
const &queriedType)
const;
1344 template <
class Proxy>
1348 return TypeInfo::GetMutableObj(_storage);
1356 *
this = _info->GetProxiedAsVtValue(_storage);
1359 return TypeInfo::GetMutableObj(_storage);
1362 template <
class Proxy>
1366 return TypeInfo::GetObj(_storage);
1374 return *
static_cast<T const *
>(_GetProxiedObjPtr());
1376 return TypeInfo::GetObj(_storage);
1379 void const *_GetProxiedObjPtr()
const {
1380 return _info->GetProxiedObjPtr(_storage);
1387 std::type_info
const &queryType)
const;
1389 inline void _Clear() {
1391 if (_info.
GetLiteral() && !_IsLocalAndTriviallyCopyable())
1392 _info.
Get()->Destroy(_storage);
1393 _info.
Set(
nullptr, 0);
1396 inline bool _IsLocalAndTriviallyCopyable()
const {
1397 unsigned int bits = _info.
BitsAs<
unsigned int>();
1398 return (bits & (_LocalFlag | _TrivialCopyFlag)) ==
1399 (_LocalFlag | _TrivialCopyFlag);
1402 inline bool _IsProxy()
const {
1403 return _info.
BitsAs<
unsigned int>() & _ProxyFlag;
1406 VT_API static void _RegisterCast(std::type_info
const &from,
1407 std::type_info
const &to,
1411 _PerformCast(std::type_info
const &to,
VtValue const &val);
1414 _CanCast(std::type_info
const &from, std::type_info
const &to);
1417 template <
typename From,
typename To>
1422 #ifdef PXR_PYTHON_SUPPORT_ENABLED
1428 Vt_GetPythonObjectFromHeldValue(
VtValue const &
self);
1431 #endif // PXR_PYTHON_SUPPORT_ENABLED
1446 return Vt_DefaultValueHolder::Create<T>();
1452 return value._GetShapeData();
1456 return value._GetNumElements();
1470 #define _VT_DECLARE_ZERO_VALUE_FACTORY(r, unused, elem) \
1472 VT_API Vt_DefaultValueHolder Vt_DefaultValueFactory<VT_TYPE(elem)>::Invoke();
1480 #undef _VT_DECLARE_ZERO_VALUE_FACTORY
1489 VtValue::Get<VtValue>()
const {
1495 VtValue::UncheckedGet<VtValue>()
const {
1501 VtValue::IsHolding<VtValue>()
const {
1508 VtValue::IsHolding<void>()
const {
1518 #endif // PXR_BASE_VT_VALUE_H
T const & UncheckedGet() const
GLboolean GLboolean GLboolean b
static Vt_DefaultValueHolder Create(T const &val)
STATIC_INLINE size_t Hash(const char *s, size_t len)
static VtValue Take(T &obj)
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.
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.
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,.
VtValue & Swap(VtValue &rhs) noexcept
Swap this with rhs.
bool IsEmpty() const
Returns true iff this value is empty.
VtValue & operator=(char *cstr)
Assigning a char * gives a VtValue holding a std::string.
HBOOST_PP_SEQ_FOR_EACH(SDF_DECLARE_VALUE_TYPE_TRAITS,~, SDF_VALUE_TYPES)
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)
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)
GLint GLint GLsizei GLint GLenum GLenum type
VT_API bool IsArrayValued() const
Returns true iff this is holding an array type (see VtIsArray<>).
VT_API std::type_info const & GetElementTypeid() const
GLboolean GLboolean GLboolean GLboolean a
GLsizei const GLchar *const * string
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.
#define _VT_DECLARE_ZERO_VALUE_FACTORY(r, unused, elem)
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)
size_t VtHashValue(T const &val)
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.
GLsizei const GLfloat * value
static void RegisterSimpleCast()
Register a simple cast from VtValue holding From to VtValue.
bool equal(T1 a, T2 b, T3 t)
static Vt_DefaultValueHolder Invoke()
This function must return an object of type T.
typename std::enable_if< B, T >::type enable_if_t
getOption("OpenEXR.storage") storage
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
#define VT_MATRIX_VALUE_TYPES
#define PXR_PYTHON_SUPPORT_ENABLED
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.