HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
propertyIndex.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_USD_PCP_PROPERTY_INDEX_H
8 #define PXR_USD_PCP_PROPERTY_INDEX_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/usd/pcp/api.h"
12 #include "pxr/usd/pcp/errors.h"
13 #include "pxr/usd/pcp/iterator.h"
14 #include "pxr/usd/pcp/node.h"
15 
16 #include "pxr/usd/sdf/path.h"
18 
19 #include <memory>
20 #include <vector>
21 
23 
24 // Forward declarations:
25 class PcpCache;
26 
27 /// \class Pcp_PropertyInfo
28 ///
29 /// Private helper structure containing information about a property in the
30 /// property stack.
31 ///
33 {
35  Pcp_PropertyInfo(const SdfPropertySpecHandle& prop, const PcpNodeRef& node)
36  : propertySpec(prop), originatingNode(node) { }
37 
38  SdfPropertySpecHandle propertySpec;
40 };
41 
42 /// \class PcpPropertyIndex
43 ///
44 /// PcpPropertyIndex is an index of all sites in scene description that
45 /// contribute opinions to a specific property, under composition
46 /// semantics.
47 ///
49 {
50 public:
51  /// Construct an empty property index.
52  PCP_API
54 
55  /// Copy-construct a property index.
56  PCP_API
57  PcpPropertyIndex(const PcpPropertyIndex &rhs);
58 
59  /// Swap the contents of this property index with \p index.
60  PCP_API
61  void Swap(PcpPropertyIndex& index);
62 
63  /// Returns true if this property index contains no opinions, false
64  /// otherwise.
65  PCP_API
66  bool IsEmpty() const;
67 
68  /// Returns range of iterators that encompasses properties in this
69  /// index's property stack.
70  ///
71  /// By default, this returns a range encompassing all properties in the
72  /// index. If \p localOnly is specified, the range will only include
73  /// properties from local nodes in its owning prim's graph.
74  PCP_API
75  PcpPropertyRange GetPropertyRange(bool localOnly = false) const;
76 
77  /// Return the list of errors local to this property.
79  return _localErrors ? *_localErrors.get() : PcpErrorVector();
80  }
81 
82  /// Returns the number of local properties in this prim index.
83  PCP_API
84  size_t GetNumLocalSpecs() const;
85 
86 private:
87  friend class PcpPropertyIterator;
88  friend class Pcp_PropertyIndexer;
89 
90  // The property stack is a list of Pcp_PropertyInfo objects in
91  // strong-to-weak order.
92  std::vector<Pcp_PropertyInfo> _propertyStack;
93 
94  /// List of errors local to this property, encountered during computation.
95  /// NULL if no errors were found (the expected common case).
96  std::unique_ptr<PcpErrorVector> _localErrors;
97 };
98 
99 /// Builds a property index for the property at \p path,
100 /// internally computing and caching an owning prim index as necessary.
101 /// \p allErrors will contain any errors encountered.
102 PCP_API
103 void
104 PcpBuildPropertyIndex( const SdfPath& propertyPath,
105  PcpCache *cache,
106  PcpPropertyIndex *propertyIndex,
107  PcpErrorVector *allErrors );
108 
109 /// Builds a prim property index for the property at \p propertyPath.
110 /// \p allErrors will contain any errors encountered.
111 PCP_API
112 void
113 PcpBuildPrimPropertyIndex( const SdfPath& propertyPath,
114  const PcpCache& cache,
115  const PcpPrimIndex& owningPrimIndex,
116  PcpPropertyIndex *propertyIndex,
117  PcpErrorVector *allErrors );
118 
120 
121 #endif // PXR_USD_PCP_PROPERTY_INDEX_H
PCP_API void PcpBuildPrimPropertyIndex(const SdfPath &propertyPath, const PcpCache &cache, const PcpPrimIndex &owningPrimIndex, PcpPropertyIndex *propertyIndex, PcpErrorVector *allErrors)
PCP_API bool IsEmpty() const
Definition: cache.h:76
friend class Pcp_PropertyIndexer
Definition: propertyIndex.h:88
PcpErrorVector GetLocalErrors() const
Return the list of errors local to this property.
Definition: propertyIndex.h:78
SdfPropertySpecHandle propertySpec
Definition: propertyIndex.h:38
PCP_API PcpPropertyRange GetPropertyRange(bool localOnly=false) const
PCP_API PcpPropertyIndex()
Construct an empty property index.
Definition: path.h:273
PCP_API size_t GetNumLocalSpecs() const
Returns the number of local properties in this prim index.
std::vector< PcpErrorBasePtr > PcpErrorVector
Definition: errors.h:65
PCP_API void PcpBuildPropertyIndex(const SdfPath &propertyPath, PcpCache *cache, PcpPropertyIndex *propertyIndex, PcpErrorVector *allErrors)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
GLuint index
Definition: glcorearb.h:786
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
Pcp_PropertyInfo(const SdfPropertySpecHandle &prop, const PcpNodeRef &node)
Definition: propertyIndex.h:35
PCP_API void Swap(PcpPropertyIndex &index)
Swap the contents of this property index with index.
#define PCP_API
Definition: api.h:23
PcpNodeRef originatingNode
Definition: propertyIndex.h:39