HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
resolveInfo.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_USD_RESOLVE_INFO_H
25 #define PXR_USD_USD_RESOLVE_INFO_H
26 
27 /// \file usd/resolveInfo.h
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usd/api.h"
31 #include "pxr/usd/usd/stage.h"
33 #include "pxr/usd/sdf/path.h"
34 #include "pxr/usd/pcp/node.h"
35 
37 
38 #include <limits>
39 
41 
42 
44 
45 /// \enum UsdResolveInfoSource
46 ///
47 /// Describes the various sources of attribute values.
48 ///
49 /// For more details, see \ref Usd_ValueResolution.
50 ///
52 {
53  UsdResolveInfoSourceNone, ///< No value
54 
55  UsdResolveInfoSourceFallback, ///< Built-in fallback value
56  UsdResolveInfoSourceDefault, ///< Attribute default value
57  UsdResolveInfoSourceTimeSamples, ///< Attribute time samples
59 };
60 
61 /// \class UsdResolveInfo
62 ///
63 /// Container for information about the source of an attribute's value, i.e.
64 /// the 'resolved' location of the attribute.
65 ///
66 /// For more details, see \ref Usd_ValueResolution.
67 ///
69 {
70 public:
72  : _source(UsdResolveInfoSourceNone)
73  , _valueIsBlocked(false)
74  {
75  }
76 
77  /// Return the source of the associated attribute's value.
79  return _source;
80  }
81 
82  /// Return true if this UsdResolveInfo represents an attribute that has an
83  /// authored value opinion. This will return `true` if there is *any*
84  /// authored value opinion, including a \ref Usd_AttributeBlocking "block"
85  ///
86  /// This is equivalent to `HasAuthoredValue() || ValueIsBlocked()`
87  bool HasAuthoredValueOpinion() const {
88  return
89  _source == UsdResolveInfoSourceDefault ||
91  _source == UsdResolveInfoSourceValueClips ||
92  _valueIsBlocked;
93  }
94 
95  /// Return true if this UsdResolveInfo represents an attribute that has an
96  /// authored value that is not \ref Usd_AttributeBlocking "blocked"
97  bool HasAuthoredValue() const {
98  return
99  _source == UsdResolveInfoSourceDefault ||
100  _source == UsdResolveInfoSourceTimeSamples ||
102  }
103 
104  /// Return the node within the containing PcpPrimIndex that provided
105  /// the resolved value opinion.
106  PcpNodeRef GetNode() const {
107  return _node;
108  }
109 
110  /// Return true if this UsdResolveInfo represents an attribute whose
111  /// value is blocked.
112  ///
113  /// \see UsdAttribute::Block()
114  bool ValueIsBlocked() const {
115  return _valueIsBlocked;
116  }
117 
118 private:
119  /// The LayerStack that provides the strongest value opinion.
120  ///
121  /// If \p source is either \p UsdResolveInfoSourceDefault
122  /// or \p UsdResolveInfoTimeSamples, the source will be a layer
123  /// in this LayerStack (\sa _layer).
124  ///
125  /// If \p source is UsdResolveInfoSourceValueClips, the source clips
126  /// will have been introduced in this LayerStack.
127  ///
128  /// Otherwise, this LayerStack will be invalid.
129  PcpLayerStackPtr _layerStack;
130 
131  /// The layer in \p layerStack that provides the strongest time sample or
132  /// default opinion.
133  ///
134  /// This is valid only if \p source is either
135  /// \p UsdResolveInfoSourceDefault or \p UsdResolveInfoTimeSamples.
136  SdfLayerHandle _layer;
137 
138  /// The node within the containing PcpPrimIndex that provided
139  /// the strongest value opinion.
140  PcpNodeRef _node;
141 
142  /// If \p source is \p UsdResolveInfoTimeSamples, the time
143  /// offset that maps time in the strongest resolved layer
144  /// to the stage.
145  /// If no offset applies, this will be the identity offset.
146  SdfLayerOffset _layerToStageOffset;
147 
148  /// The path to the prim that owns the attribute to query in
149  /// \p layerStack to retrieve the strongest value opinion.
150  ///
151  /// If \p source is either \p UsdResolveInfoSourceDefault or
152  /// \p UsdResolveInfoTimeSamples, this is the path to the prim
153  /// specs in \p layerStack that own the attribute spec containing
154  /// strongest value opinion.
155  ///
156  /// If \p source is UsdResolveInfoSourceValueClips, this is the
157  /// path to the prim that should be used to query clips for attribute
158  /// values.
159  SdfPath _primPathInLayerStack;
160 
161  /// The source of the associated attribute's value.
162  UsdResolveInfoSource _source;
163 
164  /// If \p source is \p UsdResolveInfoSourceNone or
165  /// \p UsdResolveInfoSourceFallback, this indicates whether or not
166  /// this due to the value being blocked.
167  bool _valueIsBlocked;
168 
169  friend class UsdAttribute;
170  friend class UsdStage;
172  friend class UsdAttributeQuery;
173 };
174 
175 
177 
178 #endif // PXR_USD_USD_RESOLVE_INFO_H
Built-in fallback value.
Definition: resolveInfo.h:55
UsdResolveInfoSource
Definition: resolveInfo.h:51
PXR_NAMESPACE_OPEN_SCOPE TF_DECLARE_WEAK_PTRS(PcpLayerStack)
Definition: path.h:291
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1441
Attribute time samples.
Definition: resolveInfo.h:57
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
bool HasAuthoredValue() const
Definition: resolveInfo.h:97
bool ValueIsBlocked() const
Definition: resolveInfo.h:114
UsdResolveInfoSource GetSource() const
Return the source of the associated attribute's value.
Definition: resolveInfo.h:78
friend class UsdStage_ResolveInfoAccess
Definition: resolveInfo.h:171
PcpNodeRef GetNode() const
Definition: resolveInfo.h:106
bool HasAuthoredValueOpinion() const
Definition: resolveInfo.h:87
Attribute default value.
Definition: resolveInfo.h:56