property.h
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_PROPERTY_H
25 #define PXR_USD_USD_PROPERTY_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/usd/usd/api.h"
29 #include "pxr/usd/usd/common.h"
30 #include "pxr/usd/usd/object.h"
31 #include "pxr/usd/usd/prim.h"
32 
33 #include "pxr/usd/sdf/path.h"
35 #include "pxr/base/vt/value.h"
36 
37 PXR_NAMESPACE_OPEN_SCOPE
38 
39 
40 class UsdProperty;
41 
55 class UsdProperty : public UsdObject {
56 public:
59 
60  // --------------------------------------------------------------------- //
62  // --------------------------------------------------------------------- //
63 
65 
85  USD_API
86  SdfPropertySpecHandleVector GetPropertyStack(
87  UsdTimeCode time = UsdTimeCode::Default()) const;
88 
102  USD_API
103  std::vector<std::pair<SdfPropertySpecHandle, SdfLayerOffset>>
105  UsdTimeCode time = UsdTimeCode::Default()) const;
106 
114  USD_API
115  TfToken GetBaseName() const;
116 
122  USD_API
123  TfToken GetNamespace() const;
124 
127  USD_API
128  std::vector<std::string> SplitName() const;
129 
133 
137  USD_API
138  std::string GetDisplayGroup() const;
139 
147  USD_API
148  bool SetDisplayGroup(const std::string& displayGroup) const;
149 
152  USD_API
153  bool ClearDisplayGroup() const;
154 
157  USD_API
158  bool HasAuthoredDisplayGroup() const;
159 
162  USD_API
163  std::vector<std::string> GetNestedDisplayGroups() const;
164 
172  USD_API
174  const std::vector<std::string>& nestedGroups) const;
175 
179  USD_API
180  std::string GetDisplayName() const;
181 
187  USD_API
188  bool SetDisplayName(const std::string& name) const;
189 
192  USD_API
193  bool ClearDisplayName() const;
194 
197  USD_API
198  bool HasAuthoredDisplayName() const;
199 
207  USD_API
208  bool IsCustom() const;
209 
216  USD_API
217  bool SetCustom(bool isCustom) const;
218 
222 
233  USD_API
234  bool IsDefined() const;
235 
238  USD_API
239  bool IsAuthored() const;
240 
246  USD_API
247  bool IsAuthoredAt(const class UsdEditTarget &editTarget) const;
248 
250 
251  // --------------------------------------------------------------------- //
253  // --------------------------------------------------------------------- //
254 
275  USD_API
276  UsdProperty FlattenTo(const UsdPrim &parent) const;
277 
285  USD_API
286  UsdProperty FlattenTo(const UsdPrim &parent,
287  const TfToken &propName) const;
288 
295  USD_API
296  UsdProperty FlattenTo(const UsdProperty &property) const;
297 
298 protected:
299  template <class Derived>
300  UsdProperty(_Null<Derived>) : UsdObject(_Null<Derived>()) {}
301 
302  // Gets the targets of the given spec type. Returns true if an authored
303  // opinion is found and no composition errors occured. If foundErrors is
304  // provided, it will be set to true only if errors are encountered.
305  bool _GetTargets(SdfSpecType specType, SdfPathVector *out,
306  bool *foundErrors = nullptr) const;
307 
308 private:
309  friend class UsdAttribute;
310  friend class UsdObject;
311  friend class UsdPrim;
312  friend class UsdRelationship;
313  friend class Usd_PrimData;
314 
315  UsdProperty(UsdObjType objType,
316  const Usd_PrimDataHandle &prim,
317  const SdfPath &proxyPrimPath,
318  const TfToken &propName)
319  : UsdObject(objType, prim, proxyPrimPath, propName) {}
320 
321 };
322 
323 
324 PXR_NAMESPACE_CLOSE_SCOPE
325 
326 #endif // PXR_USD_USD_PROPERTY_H
USD_API bool IsCustom() const
Return true if this is a custom property (i.e., not part of a prim schema).
USD_API SdfPropertySpecHandleVector GetPropertyStack(UsdTimeCode time=UsdTimeCode::Default()) const
Returns a strength-ordered list of property specs that provide opinions for this property.
UsdObjType
Enum values to represent the various Usd object types.
Definition: object.h:49
USD_API bool ClearDisplayGroup() const
Clears this property's display group (metadata) in the current EditTarget (only).
USD_API std::vector< std::pair< SdfPropertySpecHandle, SdfLayerOffset > > GetPropertyStackWithLayerOffsets(UsdTimeCode time=UsdTimeCode::Default()) const
Returns a strength-ordered list of property specs that provide opinions for this property paired with...
USD_API UsdProperty FlattenTo(const UsdPrim &parent) const
Flattens this property to a property spec with the same name beneath the given parent prim in the edi...
USD_API bool SetCustom(bool isCustom) const
Set the value for custom at the current EditTarget, return true on success, false if the value can no...
USD_API std::vector< std::string > GetNestedDisplayGroups() const
Return this property's displayGroup as a sequence of groups to be nested, or an empty vector if displ...
USD_API bool SetDisplayName(const std::string &name) const
Sets this property's display name (metadata).
USD_API bool HasAuthoredDisplayName() const
Returns true if displayName was explicitly authored and GetMetadata() will return a meaningful value ...
Scenegraph object for authoring and retrieving numeric, string, and array valued data,...
Definition: attribute.h:176
USD_API bool HasAuthoredDisplayGroup() const
Returns true if displayGroup was explicitly authored and GetMetadata() will return a meaningful value...
USD_API bool ClearDisplayName() const
Clears this property's display name (metadata) in the current EditTarget (only).
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdT...
Definition: timeCode.h:85
USD_API std::vector< std::string > SplitName() const
Return this property's name elements including namespaces and its base name as the final element.
Base class for Usd scenegraph objects, providing common API.
Definition: object.h:130
Defines a mapping from scene graph paths to Sdf spec paths in a SdfLayer where edits should be direct...
Definition: editTarget.h:78
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:134
USD_API bool SetNestedDisplayGroups(const std::vector< std::string > &nestedGroups) const
Sets this property's display group (metadata) to the nested sequence.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
USD_API std::string GetDisplayName() const
Return this property's display name (metadata).
UsdProperty()
Construct an invalid property.
Definition: property.h:58
A UsdRelationship creates dependencies between scenegraph objects by allowing a prim to target other ...
Definition: relationship.h:128
USD_API bool IsDefined() const
Return true if this is a builtin property or if the strongest authored SdfPropertySpec for this prope...
USD_API std::string GetDisplayGroup() const
Return this property's display group (metadata).
USD_API bool IsAuthoredAt(const class UsdEditTarget &editTarget) const
Return true if there is an SdfPropertySpec authored for this property at the given editTarget,...
USD_API bool SetDisplayGroup(const std::string &displayGroup) const
Sets this property's display group (metadata).
Base class for UsdAttribute and UsdRelationship scenegraph objects.
Definition: property.h:55
static constexpr UsdTimeCode Default()
Produce a UsdTimeCode representing the sentinel value for 'default'.
Definition: timeCode.h:113
USD_API bool IsAuthored() const
Return true if there are any authored opinions for this property in any layer that contributes to thi...
SdfSpecType
An enum that specifies the type of an object.
Definition: types.h:91
USD_API TfToken GetBaseName() const
Return this property's name with all namespace prefixes removed, i.e.
USD_API TfToken GetNamespace() const
Return this property's complete namespace prefix.