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 <boost/functional/hash.hpp> 30 #include <boost/intrusive_ptr.hpp> 32 PXR_NAMESPACE_OPEN_SCOPE
37 #define USD_CHECK_ALL_PRIM_ACCESSES 40 void intrusive_ptr_add_ref(
const class Usd_PrimData *prim);
41 void intrusive_ptr_release(
const class Usd_PrimData *prim);
45 void Usd_ThrowExpiredPrimAccessError(Usd_PrimData
const *p);
46 bool Usd_IsDead(Usd_PrimData
const *p);
49 typedef Usd_PrimData *Usd_PrimDataPtr;
50 typedef const Usd_PrimData *Usd_PrimDataConstPtr;
53 typedef boost::intrusive_ptr<Usd_PrimData> Usd_PrimDataIPtr;
54 typedef boost::intrusive_ptr<const Usd_PrimData> Usd_PrimDataConstIPtr;
59 class Usd_PrimDataHandle
63 typedef Usd_PrimDataConstIPtr::element_type element_type;
66 Usd_PrimDataHandle() {}
68 Usd_PrimDataHandle(
const Usd_PrimDataIPtr &primData)
71 Usd_PrimDataHandle(
const Usd_PrimDataConstIPtr &primData)
74 Usd_PrimDataHandle(Usd_PrimDataPtr primData)
75 : _p(Usd_PrimDataConstIPtr(primData)) {}
77 Usd_PrimDataHandle(Usd_PrimDataConstPtr primData)
78 : _p(Usd_PrimDataConstIPtr(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 boost::hash_value(h._p.get());
132 friend element_type *get_pointer(
const Usd_PrimDataHandle &h) {
136 Usd_PrimDataConstIPtr _p;
140 PXR_NAMESPACE_CLOSE_SCOPE
142 #endif // PXR_USD_USD_PRIM_DATA_HANDLE_H void swap(UsdStageLoadRules &l, UsdStageLoadRules &r)
Swap the contents of rules l and r.
A path value used to locate objects in layers or scenegraphs.
size_t hash_value(const half h)
Overload hash_value for half.
VT_API bool operator==(VtDictionary const &, VtDictionary const &)
Equality comparison.