7#ifndef PXR_USD_PCP_NODE_H
8#define PXR_USD_PCP_NODE_H
11#include "pxr/usd/pcp/api.h"
15#include "pxr/base/tf/hashset.h"
17PXR_NAMESPACE_OPEN_SCOPE
23class PcpNodeRef_ChildrenIterator;
24class PcpNodeRef_ChildrenReverseIterator;
26typedef std::shared_ptr<PcpErrorBase> PcpErrorBasePtr;
49 typedef PcpNodeRef_ChildrenIterator child_const_iterator;
50 typedef PcpNodeRef_ChildrenReverseIterator child_const_reverse_iterator;
51 typedef std::pair<child_const_iterator,
52 child_const_iterator> child_const_range;
53 typedef std::pair<child_const_reverse_iterator,
54 child_const_reverse_iterator> child_const_reverse_range;
69 return _nodeIdx == rhs._nodeIdx && _graph == rhs._graph;
75 return !(*
this == rhs);
87 return !(rhs < *
this);
99 return !(*
this < rhs);
104 size_t operator()(
const PcpNodeRef& rhs)
const
147 PcpErrorBasePtr *error);
153 const PcpPrimIndex_GraphRefPtr& subgraph,
const PcpArc& arc,
154 PcpErrorBasePtr *error);
258 bool IsDueToAncestor()
const;
263 void SetHasTransitiveDirectDependency(
bool hasDep);
265 bool HasTransitiveDirectDependency()
const;
270 void SetHasTransitiveAncestralDependency(
bool hasDep);
272 bool HasTransitiveAncestralDependency()
const;
279 bool HasSymmetry()
const;
295 bool IsInert()
const;
303 bool IsCulled()
const;
310 bool IsRestricted()
const;
340 bool HasSpecs()
const;
347 bool HasValueClips()
const;
352 Pcp_CompressedSdSite GetCompressedSdSite(
size_t layerIndex)
const
354 return Pcp_CompressedSdSite(_nodeIdx, layerIndex);
358 friend std::ostream & operator<<(std::ostream &out,
const PcpNodeRef &node);
361 friend class PcpPrimIndex_Graph;
363 friend class PcpNodeRef_ChildrenIterator;
364 friend class PcpNodeRef_ChildrenReverseIterator;
365 friend class PcpNodeRef_PrivateChildrenConstIterator;
366 friend class PcpNodeRef_PrivateChildrenConstReverseIterator;
367 friend class PcpNodeRef_PrivateSubtreeConstIterator;
368 template <
class T>
friend class Pcp_TraversalCache;
369 friend bool Pcp_IsPropagatedSpecializesNode(
const PcpNodeRef& node);
370 friend bool Pcp_IsElided(
const PcpNodeRef& node);
371 friend void Pcp_SetElided(
const PcpNodeRef& node);
374 PcpNodeRef(PcpPrimIndex_Graph* graph,
size_t idx)
375 : _graph(graph), _nodeIdx(idx)
378 size_t _GetNodeIndex()
const {
return _nodeIdx; }
380 inline size_t _GetParentIndex()
const;
381 inline size_t _GetOriginIndex()
const;
383 inline void _SetInert(
bool inert);
384 inline void _SetRestricted(
bool restricted);
386 enum class _Restricted { Yes, Unknown };
387 void _RecordRestrictionDepth(_Restricted isRestricted);
390 PcpPrimIndex_Graph* _graph;
395template <
typename HashState>
398TfHashAppend(HashState& h,
const PcpNodeRef& x){
408typedef TfHashSet<PcpNodeRef, PcpNodeRef::Hash> PcpNodeRefHashSet;
409typedef std::vector<PcpNodeRef> PcpNodeRefVector;
411class PcpNodeRef_PtrProxy {
413 PcpNodeRef* operator->() {
return &_nodeRef; }
415 friend class PcpNodeRef_ChildrenIterator;
416 friend class PcpNodeRef_ChildrenReverseIterator;
417 explicit PcpNodeRef_PtrProxy(
const PcpNodeRef& nodeRef) : _nodeRef(nodeRef) {}
426class PcpNodeRef_ChildrenIterator
429 using iterator_category = std::forward_iterator_tag;
432 using pointer = PcpNodeRef_PtrProxy;
433 using difference_type = std::ptrdiff_t;
437 PcpNodeRef_ChildrenIterator();
442 PcpNodeRef_ChildrenIterator(
const PcpNodeRef& node,
bool end =
false);
444 reference operator*()
const {
return dereference(); }
445 pointer operator->()
const {
return pointer(dereference()); }
447 PcpNodeRef_ChildrenIterator& operator++() {
452 PcpNodeRef_ChildrenIterator operator++(
int) {
453 const PcpNodeRef_ChildrenIterator result = *
this;
458 bool operator==(
const PcpNodeRef_ChildrenIterator& other)
const {
462 bool operator!=(
const PcpNodeRef_ChildrenIterator& other)
const {
463 return !equal(other);
469 bool equal(
const PcpNodeRef_ChildrenIterator& other)
const
473 return (_node == other._node && _index == other._index);
475 reference dereference()
const
477 return reference(_node._graph, _index);
487 friend class PcpNodeRef_ChildrenReverseIterator;
495class PcpNodeRef_ChildrenReverseIterator
498 using iterator_category = std::forward_iterator_tag;
501 using pointer = PcpNodeRef_PtrProxy;
502 using difference_type = std::ptrdiff_t;
506 PcpNodeRef_ChildrenReverseIterator();
510 PcpNodeRef_ChildrenReverseIterator(
const PcpNodeRef_ChildrenIterator&);
515 PcpNodeRef_ChildrenReverseIterator(
const PcpNodeRef& node,
bool end =
false);
517 reference operator*()
const {
return dereference(); }
518 pointer operator->()
const {
return pointer(dereference()); }
520 PcpNodeRef_ChildrenReverseIterator& operator++() {
525 PcpNodeRef_ChildrenReverseIterator operator++(
int) {
526 const PcpNodeRef_ChildrenReverseIterator result = *
this;
531 bool operator==(
const PcpNodeRef_ChildrenReverseIterator& other)
const {
535 bool operator!=(
const PcpNodeRef_ChildrenReverseIterator& other)
const {
536 return !equal(other);
542 bool equal(
const PcpNodeRef_ChildrenReverseIterator& other)
const
546 return (_node == other._node && _index == other._index);
548 reference dereference()
const
550 return reference(_node._graph, _index);
562struct Tf_IteratorInterface<
PcpNodeRef::child_const_range, false> {
563 typedef PcpNodeRef::child_const_iterator IteratorType;
564 static IteratorType Begin(PcpNodeRef::child_const_range
const &c)
568 static IteratorType End(PcpNodeRef::child_const_range
const &c)
575struct Tf_IteratorInterface<
PcpNodeRef::child_const_range, true> {
576 typedef PcpNodeRef::child_const_reverse_iterator IteratorType;
577 static IteratorType Begin(PcpNodeRef::child_const_range
const &c)
581 static IteratorType End(PcpNodeRef::child_const_range
const &c)
588struct Tf_ShouldIterateOverCopy<
PcpNodeRef::child_const_range> :
593PcpNodeRef_ChildrenIterator
594begin(
const PcpNodeRef::child_const_range& r)
601PcpNodeRef_ChildrenIterator
602end(
const PcpNodeRef::child_const_range& r)
609PcpNodeRef_ChildrenReverseIterator
610begin(
const PcpNodeRef::child_const_reverse_range& r)
617PcpNodeRef_ChildrenReverseIterator
618end(
const PcpNodeRef::child_const_reverse_range& r)
626int PcpNode_GetNonVariantPathElementCount(
const SdfPath &path);
628PXR_NAMESPACE_CLOSE_SCOPE
A simple iterator adapter for STL containers.
Represents an arc connecting two nodes in the prim index.
Base class for all error types.
A site specifies a path in a layer stack of scene description.
An expression that yields a PcpMapFunction value.
Object used to iterate over nodes in the prim index graph in strong-to-weak order.
PcpNode represents a node in an expression tree for compositing scene description.
PCP_API void SetRestricted(bool restricted)
Get/set whether this node is restricted.
PCP_API bool CanContributeSpecs() const
Returns true if this node is allowed to contribute opinions for composition, false otherwise.
PCP_API SdfPath GetPathAtIntroduction() const
Returns the path for this node's site when it was introduced.
PCP_API void * GetUniqueIdentifier() const
Returns a value that uniquely identifies this node.
bool operator==(const PcpNodeRef &rhs) const
Returns true if this references the same node as rhs.
PCP_API void SetHasValueClips(bool hasValueClips)
Returns true if this node's site or a namespace ancestor has authored value clips.
PCP_API PcpNodeRef GetRootNode() const
Walk up to the root node of this expression.
PCP_API SdfPath GetIntroPath() const
Get the path that introduced this node.
PCP_API void SetPermission(SdfPermission perm)
Get/set the permission for this node.
PCP_API void SetIsDueToAncestor(bool isDueToAncestor)
Get/set whether this node was introduced by being copied from its namespace ancestor,...
bool operator>(const PcpNodeRef &rhs) const
Greater than operator.
PCP_API void SetHasSymmetry(bool hasSymmetry)
Get/set whether this node provides any symmetry opinions, either directly or from a namespace ancesto...
PCP_API PcpArcType GetArcType() const
Returns the type of arc connecting this node to its parent node.
PCP_API void SetSpecContributionRestrictedDepth(size_t depth)
Set this node's contribution restriction depth.
PCP_API size_t GetSpecContributionRestrictedDepth() const
Returns the namespace depth (i.e., the path element count) of this node's path when it was restricted...
PCP_API child_const_reverse_range GetChildrenReverseRange() const
Returns an iterator range over the children nodes in weakest to strongest order.
PCP_API PcpNodeRef GetOriginNode() const
Returns the immediate origin node for this node.
PCP_API PcpLayerStackSite GetSite() const
Get the site this node represents.
PCP_API PcpNodeRef InsertChildSubgraph(const PcpPrimIndex_GraphRefPtr &subgraph, const PcpArc &arc, PcpErrorBasePtr *error)
Inserts subgraph as a child of this node, with the root node of subtree connected to this node via ar...
bool operator<=(const PcpNodeRef &rhs) const
Less than or equal operator.
PCP_API PcpNodeRef GetParentNode() const
Returns this node's immediate parent node.
PCP_API bool IsRootNode() const
Returns true if this node is the root node of the prim index graph.
PCP_API PcpNodeRef GetOriginRootNode() const
Walk up to the root origin node for this node.
PcpPrimIndex_Graph * GetOwningGraph() const
Returns the graph that this node belongs to.
PCP_API const SdfPath & GetPath() const
Returns the path for the site this node represents.
PCP_API int GetSiblingNumAtOrigin() const
Returns this node's index among siblings with the same arc type at this node's origin.
PCP_API bool HasSameSiteAs(const PcpNodeRef &node) const
Equivalent to comparing this->GetSite() == node.GetSite() but without constructing a PcpLayerStackSit...
PCP_API void SetHasSpecs(bool hasSpecs)
Returns true if this node has opinions authored for composition, false otherwise.
PCP_API PcpNodeRef InsertChild(const PcpLayerStackSite &site, const PcpArc &arc, PcpErrorBasePtr *error)
Inserts a new child node for site, connected to this node via arc.
PCP_API int GetNamespaceDepth() const
Returns the absolute namespace depth of the node that introduced this node.
bool operator>=(const PcpNodeRef &rhs) const
Greater than or equal operator.
PCP_API bool operator<(const PcpNodeRef &rhs) const
Returns true if this node is 'less' than rhs.
PCP_API const PcpMapExpression & GetMapToRoot() const
Returns mapping function used to translate paths and values from this node directly to the root node.
PCP_API const PcpLayerStackRefPtr & GetLayerStack() const
Returns the layer stack for the site this node represents.
PCP_API void SetInert(bool inert)
Get/set whether this node is inert.
PCP_API int GetDepthBelowIntroduction() const
Return the number of levels of namespace this node's site is below the level at which it was introduc...
PCP_API child_const_range GetChildrenRange() const
Returns an iterator range over the children nodes in strongest to weakest order.
size_t PcpNodeRef::* UnspecifiedBoolType
Returns true if this is a valid node reference, false otherwise.
PCP_API SdfPath GetPathAtOriginRootIntroduction() const
Returns the node's path at the same level of namespace as its origin root node was when it was added ...
PCP_API void SetCulled(bool culled)
Get/set whether this node is culled.
PCP_API const PcpMapExpression & GetMapToParent() const
Returns mapping function used to translate paths and values from this node to its parent node.
bool operator!=(const PcpNodeRef &rhs) const
Inequality operator.
A path value used to locate objects in layers or scenegraphs.
A user-extensible hashing mechanism for use with runtime hash tables.
#define TF_DECLARE_REF_PTRS(type)
Define standard ref pointer types.
size_t hash_value(const TfToken &x)
Overload hash_value for TfToken.
PcpArcType
Describes the type of arc connecting two nodes in the prim index.
constexpr size_t PCP_INVALID_INDEX
A value which indicates an invalid index.
SdfPermission
An enum that defines permission levels.