7#ifndef PXR_USD_USD_PRIM_DATA_HANDLE_H
8#define PXR_USD_USD_PRIM_DATA_HANDLE_H
11#include "pxr/usd/usd/api.h"
12#include "pxr/base/tf/delegatedCountPtr.h"
15PXR_NAMESPACE_OPEN_SCOPE
20#define USD_CHECK_ALL_PRIM_ACCESSES
23void TfDelegatedCountIncrement(
const class Usd_PrimData *prim)
noexcept;
24void TfDelegatedCountDecrement(
const class Usd_PrimData *prim)
noexcept;
28void Usd_ThrowExpiredPrimAccessError(Usd_PrimData
const *p);
29bool Usd_IsDead(Usd_PrimData
const *p);
32typedef Usd_PrimData *Usd_PrimDataPtr;
33typedef const Usd_PrimData *Usd_PrimDataConstPtr;
42class Usd_PrimDataHandle
46 typedef Usd_PrimDataConstIPtr::element_type element_type;
49 Usd_PrimDataHandle() {}
57 Usd_PrimDataHandle(Usd_PrimDataPtr primData)
58 : _p(TfDelegatedCountIncrementTag, primData) {}
60 Usd_PrimDataHandle(Usd_PrimDataConstPtr primData)
61 : _p(TfDelegatedCountIncrementTag, primData) {}
64 void reset() { _p.reset(); }
67 void swap(Usd_PrimDataHandle &other) { _p.swap(other._p); }
71 element_type *operator->()
const {
72 element_type *p = _p.get();
73#ifdef USD_CHECK_ALL_PRIM_ACCESSES
74 if (!p || Usd_IsDead(p)) {
75 Usd_ThrowExpiredPrimAccessError(p);
83 explicit operator bool()
const {
84 element_type *p = _p.get();
85 return p && !Usd_IsDead(p);
90 std::string GetDescription(
SdfPath const &proxyPrimPath)
const;
94 friend bool operator==(
const Usd_PrimDataHandle &lhs,
95 const Usd_PrimDataHandle &rhs) {
96 return lhs._p == rhs._p;
100 friend bool operator!=(
const Usd_PrimDataHandle &lhs,
101 const Usd_PrimDataHandle &rhs) {
102 return !(lhs == rhs);
106 friend void swap(Usd_PrimDataHandle &lhs, Usd_PrimDataHandle &rhs) {
111 friend size_t hash_value(
const Usd_PrimDataHandle &h) {
112 return TfHash()(h._p.get());
115 friend element_type *get_pointer(
const Usd_PrimDataHandle &h) {
123PXR_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.