24 #ifndef PXR_USD_USD_PRIM_DATA_H
25 #define PXR_USD_USD_PRIM_DATA_H
43 #include <hboost/range/iterator_range.hpp>
44 #include <hboost/iterator/iterator_adaptor.hpp>
45 #include <hboost/intrusive_ptr.hpp>
107 return *_primTypeInfo;
205 return !_nextSiblingOrParent.
BitsAs<
bool>() ?
206 _nextSiblingOrParent.
Get() :
nullptr;
213 return _nextSiblingOrParent.
BitsAs<
bool>() ?
214 _nextSiblingOrParent.
Get() :
nullptr;
268 void _ComposeAndCacheFlags(
286 _nextSiblingOrParent.
Set(sibling,
false);
290 _nextSiblingOrParent.
Set(parent,
true);
297 _primIndex =
nullptr;
305 void _SetMayHaveOpinionsInClips(
bool hasClips) {
309 typedef hboost::iterator_range<
314 inline SiblingRange _GetChildrenRange()
const;
316 typedef hboost::iterator_range<
321 inline SubtreeRange _GetSubtreeRange()
const;
330 mutable std::atomic<int64_t> _refCount;
335 prim->_refCount.fetch_add(1, std::memory_order_relaxed);
338 if (prim->_refCount.fetch_sub(1, std::memory_order_release) == 1)
357 Usd_PrimDataSiblingIterator,
360 hboost::forward_traversal_tag,
373 : iterator_adaptor_(i) {}
377 reference dereference()
const {
return base(); }
379 base_reference() = base_reference()->GetNextSibling();
384 typedef hboost::iterator_range<
396 Usd_PrimData::_ChildrenBegin()
const
402 Usd_PrimData::_ChildrenEnd()
const
407 Usd_PrimData::SiblingRange
408 Usd_PrimData::_GetChildrenRange()
const
410 return Usd_PrimData::SiblingRange(_ChildrenBegin(), _ChildrenEnd());
416 Usd_PrimDataSubtreeIterator,
419 hboost::forward_traversal_tag,
433 : iterator_adaptor_(i) {}
437 reference dereference()
const {
return base(); }
439 base_type &
b = base_reference();
440 b = b->GetFirstChild() ? b->GetFirstChild() : b->GetNextPrim();
445 typedef hboost::iterator_range<
457 Usd_PrimData::_SubtreeBegin()
const
464 Usd_PrimData::_SubtreeEnd()
const
469 Usd_PrimData::SubtreeRange
470 Usd_PrimData::_GetSubtreeRange()
const
472 return Usd_PrimData::SubtreeRange(_SubtreeBegin(), _SubtreeEnd());
479 template <
class PrimDataPtr>
483 return !proxyPrimPath.
IsEmpty();
493 template <
class PrimDataPtr>
513 template <
class PrimDataPtr>
519 if (!proxyPrimPath.
IsEmpty()) {
522 if (p && p->IsPrototype()) {
523 p = p->GetPrimDataAtPathOrInPrototype(proxyPrimPath);
524 if (TF_VERIFY(p,
"No prim at <%s>", proxyPrimPath.
GetText()) &&
525 p->GetPath() == proxyPrimPath) {
543 template <
class PrimDataPtr>
553 PrimDataPtr next = p->GetNextSibling();
554 while (next && next != end &&
555 !Usd_EvalPredicate(pred, next, isInstanceProxy)) {
557 next = p->GetNextSibling();
559 p = next ? next : p->GetParentLink();
561 if (!proxyPrimPath.
IsEmpty()) {
565 else if (p == next) {
571 if (p && p->IsPrototype()) {
572 p = p->GetPrimDataAtPathOrInPrototype(proxyPrimPath);
573 if (TF_VERIFY(p,
"No prim at <%s>", proxyPrimPath.
GetText()) &&
574 p->GetPath() == proxyPrimPath) {
586 template <
class PrimDataPtr>
592 PrimDataPtr(
nullptr), pred);
600 template <
class PrimDataPtr>
609 if (src->IsInstance()) {
610 src = src->GetPrototype();
611 isInstanceProxy =
true;
614 if (PrimDataPtr child = src->GetFirstChild()) {
615 if (isInstanceProxy) {
616 proxyPrimPath = proxyPrimPath.
IsEmpty() ?
617 p->GetPath().AppendChild(child->GetName()) :
623 if (Usd_EvalPredicate(pred, p, isInstanceProxy) ||
632 template <
class PrimDataPtr>
642 #endif // PXR_USD_USD_PRIM_DATA_H
SDF_API const char * GetText() const
void Usd_MoveToParent(PrimDataPtr &p, SdfPath &proxyPrimPath)
USD_API Usd_PrimDataConstPtr GetParent() const
Return this prim's parent prim. Return nullptr if this is a root prim.
bool IsPseudoRoot() const
Returns true if this prim is the pseudoroot.
USD_API const class PcpPrimIndex & GetPrimIndex() const
Usd_PrimFlagsPredicate Usd_CreatePredicateForTraversal(const PrimDataPtr &p, const SdfPath &proxyPrimPath, Usd_PrimFlagsPredicate pred)
Usd_PrimDataPtr GetFirstChild() const
Return this prim's parent prim. Return nullptr if this is a root prim.
PXR_NAMESPACE_OPEN_SCOPE TF_DECLARE_WEAK_PTRS(UsdStage)
GLsizei const GLchar *const * string
Usd_PrimDataPtr GetParentLink() const
Return this prim's parent prim. Return nullptr if this is a root prim.
GLsizei const GLchar *const * path
USD_API SdfSpecifier GetSpecifier() const
Return this prim's composed specifier.
Usd_PrimDataSiblingIterator()
bool IsEmpty() const noexcept
Returns true if this is the empty path (SdfPath::EmptyPath()).
hboost::iterator_range< class Usd_PrimDataSubtreeIterator > Usd_PrimDataSubtreeRange
Usd_PrimFlagsPredicate & TraverseInstanceProxies(bool traverse)
const UsdPrimDefinition & GetPrimDefinition() const
constexpr T * Get() const noexcept
Retrieve the pointer.
const SdfPath & GetPath() const
bool IsInPrototype() const
bool IsPrototype() const
Return true if this prim is a shared prototype prim, false otherwise.
bool MayHaveOpinionsInClips() const
USD_API const class PcpPrimIndex & GetSourcePrimIndex() const
USD_API Usd_PrimDataConstPtr GetPrimDataAtPathOrInPrototype(const SdfPath &path) const
Return this prim's parent prim. Return nullptr if this is a root prim.
UsdStage * GetStage() const
Usd_PrimDataPtr GetNextPrim() const
Return this prim's parent prim. Return nullptr if this is a root prim.
friend class hboost::iterator_core_access
SDF_API SdfPath AppendChild(TfToken const &childName) const
friend void intrusive_ptr_add_ref(const Usd_PrimData *prim)
Return this prim's parent prim. Return nullptr if this is a root prim.
hboost::iterator_range< class Usd_PrimDataSiblingIterator > Usd_PrimDataSiblingRange
bool Usd_IsInstanceProxy(const PrimDataPtr &p, const SdfPath &proxyPrimPath)
friend std::string Usd_DescribePrimData(const Usd_PrimData *p, SdfPath const &proxyPrimPath)
Return this prim's parent prim. Return nullptr if this is a root prim.
bool IncludeInstanceProxiesInTraversal() const
const UsdPrimDefinition & GetPrimDefinition() const
Returns the prim definition for this prim.
constexpr Integral BitsAs() const noexcept
Retrieve the stored bits as the integral type Integral.
std::vector< TfToken > TfTokenVector
Convenience types.
bool HasDefiningSpecifier() const
friend class hboost::iterator_core_access
GLboolean GLboolean GLboolean b
SDF_API const TfToken & GetNameToken() const
bool Usd_MoveToChild(PrimDataPtr &p, SdfPath &proxyPrimPath, PrimDataPtr end, const Usd_PrimFlagsPredicate &pred)
bool IsAbstract() const
Return true if this prim or any of its ancestors is a class.
USD_API friend void Usd_ThrowExpiredPrimAccessError(Usd_PrimData const *p)
Return this prim's parent prim. Return nullptr if this is a root prim.
void Set(T *ptr) noexcept
Set the pointer value to ptr.
friend bool Usd_IsDead(Usd_PrimData const *p)
Return this prim's parent prim. Return nullptr if this is a root prim.
bool HasPayload() const
Return true if this prim has one or more payload composition arcs.
const TfToken & GetTypeName() const
Returns the concrete prim type name.
const TfToken & GetName() const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
bool Usd_MoveToNextSiblingOrParent(PrimDataPtr &p, SdfPath &proxyPrimPath, PrimDataPtr end, const Usd_PrimFlagsPredicate &pred)
SDF_API bool IsRootPrimPath() const
#define PXR_NAMESPACE_CLOSE_SCOPE
SDF_API SdfPath GetParentPath() const
USD_API Usd_PrimDataConstPtr GetPrototype() const
const TfToken & GetTypeName() const
std::bitset< Usd_PrimNumFlags > Usd_PrimFlagBits
Usd_PrimDataSubtreeIterator()
Usd_PrimDataPtr GetNextSibling() const
Return this prim's parent prim. Return nullptr if this is a root prim.
const UsdPrimTypeInfo & GetPrimTypeInfo() const
Returns the full type info for the prim.
friend void intrusive_ptr_release(const Usd_PrimData *prim)
Return this prim's parent prim. Return nullptr if this is a root prim.