24#ifndef PXR_USD_USD_PRIM_DATA_HANDLE_H
25#define PXR_USD_USD_PRIM_DATA_HANDLE_H
28#include "pxr/usd/usd/api.h"
29#include "pxr/base/tf/delegatedCountPtr.h"
32PXR_NAMESPACE_OPEN_SCOPE
37#define USD_CHECK_ALL_PRIM_ACCESSES
40void TfDelegatedCountIncrement(
const class Usd_PrimData *prim)
noexcept;
41void TfDelegatedCountDecrement(
const class Usd_PrimData *prim)
noexcept;
45void Usd_ThrowExpiredPrimAccessError(Usd_PrimData
const *p);
46bool Usd_IsDead(Usd_PrimData
const *p);
49typedef Usd_PrimData *Usd_PrimDataPtr;
50typedef const Usd_PrimData *Usd_PrimDataConstPtr;
59class Usd_PrimDataHandle
63 typedef Usd_PrimDataConstIPtr::element_type element_type;
66 Usd_PrimDataHandle() {}
74 Usd_PrimDataHandle(Usd_PrimDataPtr primData)
75 : _p(TfDelegatedCountIncrementTag, primData) {}
77 Usd_PrimDataHandle(Usd_PrimDataConstPtr primData)
78 : _p(TfDelegatedCountIncrementTag, primData) {}
81 void reset() { _p.reset(); }
84 void swap(Usd_PrimDataHandle &other) { _p.swap(other._p); }
88 element_type *operator->()
const {
89 element_type *p = _p.get();
90#ifdef USD_CHECK_ALL_PRIM_ACCESSES
91 if (!p || Usd_IsDead(p)) {
92 Usd_ThrowExpiredPrimAccessError(p);
100 explicit operator bool()
const {
101 element_type *p = _p.get();
102 return p && !Usd_IsDead(p);
107 std::string GetDescription(
SdfPath const &proxyPrimPath)
const;
111 friend bool operator==(
const Usd_PrimDataHandle &lhs,
112 const Usd_PrimDataHandle &rhs) {
113 return lhs._p == rhs._p;
117 friend bool operator!=(
const Usd_PrimDataHandle &lhs,
118 const Usd_PrimDataHandle &rhs) {
119 return !(lhs == rhs);
123 friend void swap(Usd_PrimDataHandle &lhs, Usd_PrimDataHandle &rhs) {
128 friend size_t hash_value(
const Usd_PrimDataHandle &h) {
129 return TfHash()(h._p.get());
132 friend element_type *get_pointer(
const Usd_PrimDataHandle &h) {
140PXR_NAMESPACE_CLOSE_SCOPE
A path value used to locate objects in layers or scenegraphs.
Stores a pointer to a ValueType which uses TfDelegatedCountIncrement and TfDelegatedCountDecrement to...
A user-extensible hashing mechanism for use with runtime hash tables.
size_t hash_value(const half h)
Overload hash_value for half.