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 Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_USD_PCP_PROPERTY_INDEX_H
25 #define PXR_USD_PCP_PROPERTY_INDEX_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/usd/pcp/api.h"
29 #include "pxr/usd/pcp/errors.h"
30 #include "pxr/usd/pcp/iterator.h"
31 #include "pxr/usd/pcp/node.h"
32 
33 #include "pxr/usd/sdf/path.h"
35 
36 #include <memory>
37 #include <vector>
38 
40 
41 // Forward declarations:
42 class PcpCache;
43 
44 /// \class Pcp_PropertyInfo
45 ///
46 /// Private helper structure containing information about a property in the
47 /// property stack.
48 ///
50 {
52  Pcp_PropertyInfo(const SdfPropertySpecHandle& prop, const PcpNodeRef& node)
53  : propertySpec(prop), originatingNode(node) { }
54 
55  SdfPropertySpecHandle propertySpec;
57 };
58 
59 /// \class PcpPropertyIndex
60 ///
61 /// PcpPropertyIndex is an index of all sites in scene description that
62 /// contribute opinions to a specific property, under composition
63 /// semantics.
64 ///
66 {
67 public:
68  /// Construct an empty property index.
69  PCP_API
71 
72  /// Copy-construct a property index.
73  PCP_API
74  PcpPropertyIndex(const PcpPropertyIndex &rhs);
75 
76  /// Swap the contents of this property index with \p index.
77  PCP_API
78  void Swap(PcpPropertyIndex& index);
79 
80  /// Returns true if this property index contains no opinions, false
81  /// otherwise.
82  PCP_API
83  bool IsEmpty() const;
84 
85  /// Returns range of iterators that encompasses properties in this
86  /// index's property stack.
87  ///
88  /// By default, this returns a range encompassing all properties in the
89  /// index. If \p localOnly is specified, the range will only include
90  /// properties from local nodes in its owning prim's graph.
91  PCP_API
92  PcpPropertyRange GetPropertyRange(bool localOnly = false) const;
93 
94  /// Return the list of errors local to this property.
96  return _localErrors ? *_localErrors.get() : PcpErrorVector();
97  }
98 
99  /// Returns the number of local properties in this prim index.
100  PCP_API
101  size_t GetNumLocalSpecs() const;
102 
103 private:
104  friend class PcpPropertyIterator;
105  friend class Pcp_PropertyIndexer;
106 
107  // The property stack is a list of Pcp_PropertyInfo objects in
108  // strong-to-weak order.
109  std::vector<Pcp_PropertyInfo> _propertyStack;
110 
111  /// List of errors local to this property, encountered during computation.
112  /// NULL if no errors were found (the expected common case).
113  std::unique_ptr<PcpErrorVector> _localErrors;
114 };
115 
116 /// Builds a property index for the property at \p path,
117 /// internally computing and caching an owning prim index as necessary.
118 /// \p allErrors will contain any errors encountered.
119 PCP_API
120 void
121 PcpBuildPropertyIndex( const SdfPath& propertyPath,
122  PcpCache *cache,
123  PcpPropertyIndex *propertyIndex,
124  PcpErrorVector *allErrors );
125 
126 /// Builds a prim property index for the property at \p propertyPath.
127 /// \p allErrors will contain any errors encountered.
128 PCP_API
129 void
130 PcpBuildPrimPropertyIndex( const SdfPath& propertyPath,
131  const PcpCache& cache,
132  const PcpPrimIndex& owningPrimIndex,
133  PcpPropertyIndex *propertyIndex,
134  PcpErrorVector *allErrors );
135 
137 
138 #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:93
friend class Pcp_PropertyIndexer
PcpErrorVector GetLocalErrors() const
Return the list of errors local to this property.
Definition: propertyIndex.h:95
SdfPropertySpecHandle propertySpec
Definition: propertyIndex.h:55
PCP_API PcpPropertyRange GetPropertyRange(bool localOnly=false) const
PCP_API PcpPropertyIndex()
Construct an empty property index.
Definition: path.h:291
PCP_API size_t GetNumLocalSpecs() const
Returns the number of local properties in this prim index.
std::vector< PcpErrorBasePtr > PcpErrorVector
Definition: errors.h:78
PCP_API void PcpBuildPropertyIndex(const SdfPath &propertyPath, PcpCache *cache, PcpPropertyIndex *propertyIndex, PcpErrorVector *allErrors)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
GLuint index
Definition: glcorearb.h:786
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
Pcp_PropertyInfo(const SdfPropertySpecHandle &prop, const PcpNodeRef &node)
Definition: propertyIndex.h:52
PCP_API void Swap(PcpPropertyIndex &index)
Swap the contents of this property index with index.
#define PCP_API
Definition: api.h:40
PcpNodeRef originatingNode
Definition: propertyIndex.h:56