prim.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_PRIM_H
25 #define PXR_USD_USD_PRIM_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usd/api.h"
31 #include "pxr/usd/usd/common.h"
32 #include "pxr/usd/usd/object.h"
33 #include "pxr/usd/usd/primFlags.h"
34 
35 #include "pxr/usd/sdf/schema.h"
36 #include "pxr/base/trace/trace.h"
37 
39 #include "pxr/base/tf/refBase.h"
40 #include "pxr/base/tf/token.h"
41 #include "pxr/base/tf/weakBase.h"
42 
43 #include "pxr/usd/sdf/path.h"
44 
45 #include <boost/iterator/iterator_adaptor.hpp>
46 #include <boost/range/iterator_range.hpp>
47 
48 #include <string>
49 #include <type_traits>
50 #include <vector>
51 
52 PXR_NAMESPACE_OPEN_SCOPE
53 
54 class UsdPrim;
55 class UsdPrimDefinition;
56 class UsdPrimRange;
57 class Usd_PrimData;
58 
59 class UsdAttribute;
60 class UsdEditTarget;
61 class UsdRelationship;
62 class UsdPayloads;
63 class UsdReferences;
64 class UsdResolveTarget;
65 class UsdSchemaBase;
66 class UsdAPISchemaBase;
67 class UsdInherits;
68 class UsdSpecializes;
69 class UsdVariantSets;
70 class UsdVariantSet;
71 
72 class SdfPayload;
73 
75 typedef boost::iterator_range<UsdPrimSiblingIterator> UsdPrimSiblingRange;
76 
78 typedef boost::iterator_range<UsdPrimSubtreeIterator> UsdPrimSubtreeRange;
79 
134 class UsdPrim : public UsdObject
135 {
136 public:
140 
144 
146  UsdPrim() : UsdObject(_Null<UsdPrim>()) {}
147 
159  return _Prim()->GetPrimTypeInfo();
160  }
161 
166  return _Prim()->GetPrimDefinition();
167  }
168 
170  SdfSpecifier GetSpecifier() const { return _Prim()->GetSpecifier(); };
171 
185  USD_API
186  SdfPrimSpecHandleVector GetPrimStack() const;
187 
200  USD_API
201  std::vector<std::pair<SdfPrimSpecHandle, SdfLayerOffset>>
203 
206  bool SetSpecifier(SdfSpecifier specifier) const {
207  return SetMetadata(SdfFieldKeys->Specifier, specifier);
208  }
209 
217  const TfToken &GetTypeName() const { return _Prim()->GetTypeName(); };
218 
220  bool SetTypeName(const TfToken & typeName) const {
221  return SetMetadata(SdfFieldKeys->TypeName, typeName);
222  }
223 
226  bool ClearTypeName() const {
227  return ClearMetadata(SdfFieldKeys->TypeName);
228  }
229 
231  bool HasAuthoredTypeName() const {
232  return HasAuthoredMetadata(SdfFieldKeys->TypeName);
233  }
234 
239  bool IsActive() const { return _Prim()->IsActive(); }
240 
245  bool SetActive(bool active) const {
246  return SetMetadata(SdfFieldKeys->Active, active);
247  }
248 
254  bool ClearActive() const {
255  return ClearMetadata(SdfFieldKeys->Active);
256  }
257 
262  bool HasAuthoredActive() const {
263  return HasAuthoredMetadata(SdfFieldKeys->Active);
264  }
265 
269  bool IsLoaded() const { return _Prim()->IsLoaded(); }
270 
273  bool IsModel() const { return _Prim()->IsModel(); }
274 
278  bool IsGroup() const { return _Prim()->IsGroup(); }
279 
281  bool IsAbstract() const { return _Prim()->IsAbstract(); }
282 
285  bool IsDefined() const { return _Prim()->IsDefined(); }
286 
289  bool HasDefiningSpecifier() const {
290  return _Prim()->HasDefiningSpecifier();
291  }
292 
299  USD_API
301 
304  using PropertyPredicateFunc =
305  std::function<bool (const TfToken &propertyName)>;
306 
318  USD_API
320  const PropertyPredicateFunc &predicate={}) const;
321 
335  USD_API
337  const PropertyPredicateFunc &predicate={}) const;
338 
382  USD_API
383  std::vector<UsdProperty> GetProperties(
384  const PropertyPredicateFunc &predicate={}) const;
385 
399  USD_API
400  std::vector<UsdProperty> GetAuthoredProperties(
401  const PropertyPredicateFunc &predicate={}) const;
402 
414  USD_API
415  std::vector<UsdProperty>
416  GetPropertiesInNamespace(const std::vector<std::string> &namespaces) const;
417 
422  USD_API
423  std::vector<UsdProperty>
424  GetPropertiesInNamespace(const std::string &namespaces) const;
425 
431  USD_API
432  std::vector<UsdProperty>
434  const std::vector<std::string> &namespaces) const;
435 
441  USD_API
442  std::vector<UsdProperty>
443  GetAuthoredPropertiesInNamespace(const std::string &namespaces) const;
444 
446  USD_API
448 
451  void SetPropertyOrder(const TfTokenVector &order) const {
452  SetMetadata(SdfFieldKeys->PropertyOrder, order);
453  }
454 
457  void ClearPropertyOrder() const {
458  ClearMetadata(SdfFieldKeys->PropertyOrder);
459  }
460 
469  USD_API
470  bool RemoveProperty(const TfToken &propName);
471 
484  USD_API
485  UsdProperty GetProperty(const TfToken &propName) const;
486 
489  USD_API
490  bool HasProperty(const TfToken &propName) const;
491 
492 private:
493  // The non-templated implementation of UsdPrim::IsA using the
494  // TfType system. \p validateSchemaType is provided for python clients
495  // because they can't use compile time assertions on the input type.
496  USD_API
497  bool _IsA(const TfType& schemaType, bool validateSchemaType) const;
498 
499  // Separate implementations for UsdPrim::HasAPI for single and multiple
500  // apply API schema TfTypes.
501  USD_API
502  bool _HasSingleApplyAPI(const TfType& schemaType) const;
503 
504  USD_API
505  bool _HasMultiApplyAPI(const TfType& schemaType,
506  const TfToken &instanceName) const;
507 
508  // Private implementation for all ApplyAPI, CanApplyAPI, and RemoveAPI
509  // methods for both single apply and multiple apply APIs. The multiple
510  // apply API methods validate that the instance name is non-empty, but
511  // otherwise all of these methods do no other input validation as the
512  // public methods are expected to have already done either compile time or
513  // runtime validation already.
514  USD_API
515  bool _CanApplyAPI(const TfType& schemaType,
516  std::string *whyNot) const;
517 
518  USD_API
519  bool _CanApplyAPI(const TfType& schemaType,
520  const TfToken& instanceName,
521  std::string *whyNot) const;
522 
523  USD_API
524  bool _ApplyAPI(const TfType& schemaType) const;
525 
526  USD_API
527  bool _ApplyAPI(const TfType& schemaType,
528  const TfToken& instanceName) const;
529 
530  USD_API
531  bool _RemoveAPI(const TfType& schemaType) const;
532 
533  USD_API
534  bool _RemoveAPI(const TfType& schemaType,
535  const TfToken& instanceName) const;
536 
537 public:
542  template <typename T>
543  bool IsA() const {
544  static_assert(std::is_base_of<UsdSchemaBase, T>::value,
545  "Provided type must derive UsdSchemaBase.");
546  return _IsA(TfType::Find<T>(), /*validateSchemaType=*/false);
547  };
548 
553  USD_API
554  bool IsA(const TfType& schemaType) const;
555 
584 
589  template <typename T>
590  typename std::enable_if<T::schemaKind != UsdSchemaKind::MultipleApplyAPI,
591  bool>::type
592  HasAPI() const {
593  static_assert(std::is_base_of<UsdAPISchemaBase, T>::value,
594  "Provided type must derive UsdAPISchemaBase.");
595  static_assert(!std::is_same<UsdAPISchemaBase, T>::value,
596  "Provided type must not be UsdAPISchemaBase.");
597  // Note that this function template is enabled for any schema kind,
598  // other than MultipleApplyAPI, but is only valid for SingleApplyAPI.
599  // This static assert provides better error information for calling
600  // HasAPI with an invalid template type than if we limited HasAPI
601  // substitution matching to just the two valid schema kinds.
602  static_assert(T::schemaKind == UsdSchemaKind::SingleApplyAPI,
603  "Provided schema type must be a single apply API schema.");
604 
605  return _HasSingleApplyAPI(TfType::Find<T>());
606  }
607 
616  template <typename T>
617  typename std::enable_if<T::schemaKind == UsdSchemaKind::MultipleApplyAPI,
618  bool>::type
619  HasAPI(const TfToken &instanceName = TfToken()) const {
620  static_assert(std::is_base_of<UsdAPISchemaBase, T>::value,
621  "Provided type must derive UsdAPISchemaBase.");
622  static_assert(!std::is_same<UsdAPISchemaBase, T>::value,
623  "Provided type must not be UsdAPISchemaBase.");
624  static_assert(T::schemaKind == UsdSchemaKind::MultipleApplyAPI,
625  "Provided schema type must be a multi apply API schema.");
626 
627  return _HasMultiApplyAPI(TfType::Find<T>(), instanceName);
628  }
629 
642  USD_API
643  bool HasAPI(const TfType& schemaType,
644  const TfToken& instanceName=TfToken()) const;
645 
647 
660  template <typename SchemaType>
661  bool CanApplyAPI(std::string *whyNot = nullptr) const {
662  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
663  "Provided type must derive UsdAPISchemaBase.");
664  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
665  "Provided type must not be UsdAPISchemaBase.");
666  static_assert(SchemaType::schemaKind == UsdSchemaKind::SingleApplyAPI,
667  "Provided schema type must be a single apply API schema.");
668 
669  static const TfType schemaType = TfType::Find<SchemaType>();
670  return _CanApplyAPI(schemaType, whyNot);
671  }
672 
679  USD_API
680  bool CanApplyAPI(const TfType& schemaType,
681  std::string *whyNot = nullptr) const;
682 
696  template <typename SchemaType>
697  bool CanApplyAPI(const TfToken &instanceName,
698  std::string *whyNot = nullptr) const {
699  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
700  "Provided type must derive UsdAPISchemaBase.");
701  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
702  "Provided type must not be UsdAPISchemaBase.");
703  static_assert(SchemaType::schemaKind == UsdSchemaKind::MultipleApplyAPI,
704  "Provided schema type must be a multiple apply API schema.");
705 
706  static const TfType schemaType = TfType::Find<SchemaType>();
707  return _CanApplyAPI(schemaType, instanceName, whyNot);
708  }
709 
716  USD_API
717  bool CanApplyAPI(const TfType& schemaType,
718  const TfToken& instanceName,
719  std::string *whyNot = nullptr) const;
720 
736  template <typename SchemaType>
737  bool ApplyAPI() const {
738  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
739  "Provided type must derive UsdAPISchemaBase.");
740  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
741  "Provided type must not be UsdAPISchemaBase.");
742  static_assert(SchemaType::schemaKind == UsdSchemaKind::SingleApplyAPI,
743  "Provided schema type must be a single apply API schema.");
744 
745  static const TfType schemaType = TfType::Find<SchemaType>();
746  return _ApplyAPI(schemaType);
747  }
748 
755  USD_API
756  bool ApplyAPI(const TfType& schemaType) const;
757 
778  template <typename SchemaType>
779  bool ApplyAPI(const TfToken &instanceName) const {
780  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
781  "Provided type must derive UsdAPISchemaBase.");
782  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
783  "Provided type must not be UsdAPISchemaBase.");
784  static_assert(SchemaType::schemaKind == UsdSchemaKind::MultipleApplyAPI,
785  "Provided schema type must be a multiple apply API schema.");
786 
787  static const TfType schemaType = TfType::Find<SchemaType>();
788  return _ApplyAPI(schemaType, instanceName);
789  }
790 
797  USD_API
798  bool ApplyAPI(const TfType& schemaType, const TfToken& instanceName) const;
799 
816  template <typename SchemaType>
817  bool RemoveAPI() const {
818  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
819  "Provided type must derive UsdAPISchemaBase.");
820  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
821  "Provided type must not be UsdAPISchemaBase.");
822  static_assert(SchemaType::schemaKind == UsdSchemaKind::SingleApplyAPI,
823  "Provided schema type must be a single apply API schema.");
824 
825  static const TfType schemaType = TfType::Find<SchemaType>();
826  return _RemoveAPI(schemaType);
827  }
828 
835  USD_API
836  bool RemoveAPI(const TfType& schemaType) const;
837 
859  template <typename SchemaType>
860  bool RemoveAPI(const TfToken &instanceName) const {
861  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
862  "Provided type must derive UsdAPISchemaBase.");
863  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
864  "Provided type must not be UsdAPISchemaBase.");
865  static_assert(SchemaType::schemaKind == UsdSchemaKind::MultipleApplyAPI,
866  "Provided schema type must be a multiple apply API schema.");
867 
868  static const TfType schemaType = TfType::Find<SchemaType>();
869  return _RemoveAPI(schemaType, instanceName);
870  }
871 
878  USD_API
879  bool RemoveAPI(const TfType& schemaType,
880  const TfToken& instanceName) const;
881 
905  USD_API
906  bool AddAppliedSchema(const TfToken &appliedSchemaName) const;
907 
932  USD_API
933  bool RemoveAppliedSchema(const TfToken &appliedSchemaName) const;
934 
935  // --------------------------------------------------------------------- //
937  // --------------------------------------------------------------------- //
938 
944  USD_API
945  UsdPrim GetChild(const TfToken &name) const;
946 
955  inline SiblingRange GetChildren() const;
956 
958  inline SiblingRange GetAllChildren() const;
959 
979  inline SiblingRange
980  GetFilteredChildren(const Usd_PrimFlagsPredicate &predicate) const;
981 
984  USD_API
986 
989  USD_API
991 
994  USD_API
996  const Usd_PrimFlagsPredicate &predicate) const;
997 
1010  inline SubtreeRange GetDescendants() const;
1011 
1020  inline SubtreeRange GetAllDescendants() const;
1021 
1045  inline SubtreeRange
1046  GetFilteredDescendants(const Usd_PrimFlagsPredicate &predicate) const;
1047 
1053  USD_API
1055 
1058  void SetChildrenReorder(const TfTokenVector &order) const {
1059  SetMetadata(SdfFieldKeys->PrimOrder, order);
1060  }
1061 
1064  void ClearChildrenReorder() const {
1065  ClearMetadata(SdfFieldKeys->PrimOrder);
1066  }
1067 
1068 public:
1069  // --------------------------------------------------------------------- //
1071  // --------------------------------------------------------------------- //
1072 
1075  UsdPrim GetParent() const {
1076  Usd_PrimDataConstPtr prim = get_pointer(_Prim());
1077  SdfPath proxyPrimPath = _ProxyPrimPath();
1078  Usd_MoveToParent(prim, proxyPrimPath);
1079  return UsdPrim(prim, proxyPrimPath);
1080  }
1081 
1090  USD_API
1091  UsdPrim GetNextSibling() const;
1092 
1098  USD_API
1100  const Usd_PrimFlagsPredicate &predicate) const;
1101 
1108  USD_API
1109  bool IsPseudoRoot() const;
1110 
1114  USD_API UsdPrim GetPrimAtPath(const SdfPath& path) const;
1115 
1119  USD_API UsdObject GetObjectAtPath(const SdfPath& path) const;
1120 
1129  USD_API UsdProperty GetPropertyAtPath(const SdfPath& path) const;
1130 
1139  USD_API UsdAttribute GetAttributeAtPath(const SdfPath& path) const;
1140 
1149  USD_API UsdRelationship GetRelationshipAtPath(const SdfPath& path) const;
1150 
1151  // --------------------------------------------------------------------- //
1153  // --------------------------------------------------------------------- //
1154 
1160  USD_API
1162 
1170  USD_API
1171  UsdVariantSet GetVariantSet(const std::string& variantSetName) const;
1172 
1178  USD_API
1179  bool HasVariantSets() const;
1180 
1181  // --------------------------------------------------------------------- //
1183  // --------------------------------------------------------------------- //
1184 
1224  USD_API
1225  UsdAttribute
1226  CreateAttribute(const TfToken& name,
1227  const SdfValueTypeName &typeName,
1228  bool custom,
1229  SdfVariability variability = SdfVariabilityVarying) const;
1232  USD_API
1233  UsdAttribute
1234  CreateAttribute(const TfToken& name,
1235  const SdfValueTypeName &typeName,
1236  SdfVariability variability = SdfVariabilityVarying) const;
1237 
1242  USD_API
1244  const std::vector<std::string> &nameElts,
1245  const SdfValueTypeName &typeName,
1246  bool custom,
1247  SdfVariability variability = SdfVariabilityVarying) const;
1251  USD_API
1253  const std::vector<std::string> &nameElts,
1254  const SdfValueTypeName &typeName,
1255  SdfVariability variability = SdfVariabilityVarying) const;
1256 
1258  USD_API
1259  std::vector<UsdAttribute> GetAttributes() const;
1260 
1263  USD_API
1264  std::vector<UsdAttribute> GetAuthoredAttributes() const;
1265 
1278  USD_API
1279  UsdAttribute GetAttribute(const TfToken& attrName) const;
1280 
1283  USD_API
1284  bool HasAttribute(const TfToken& attrName) const;
1285 
1291  USD_API
1292  SdfPathVector
1294  std::function<bool (UsdAttribute const &)> const &pred = nullptr,
1295  bool recurseOnSources = false) const;
1296 
1297  // --------------------------------------------------------------------- //
1299  // --------------------------------------------------------------------- //
1300 
1337  USD_API
1339  bool custom=true) const;
1340 
1345  USD_API
1346  UsdRelationship CreateRelationship(const std::vector<std::string> &nameElts,
1347  bool custom=true)
1348  const;
1349 
1351  USD_API
1352  std::vector<UsdRelationship> GetRelationships() const;
1353 
1356  USD_API
1357  std::vector<UsdRelationship> GetAuthoredRelationships() const;
1358 
1371  USD_API
1372  UsdRelationship GetRelationship(const TfToken& relName) const;
1373 
1376  USD_API
1377  bool HasRelationship(const TfToken& relName) const;
1378 
1385  USD_API
1386  SdfPathVector
1388  std::function<bool (UsdRelationship const &)> const &pred = nullptr,
1389  bool recurseOnTargets = false) const;
1390 
1391  // --------------------------------------------------------------------- //
1398  // --------------------------------------------------------------------- //
1399 
1403  USD_API
1404  bool ClearPayload() const;
1405 
1410  USD_API
1411  bool HasPayload() const;
1412 
1418  USD_API
1419  bool SetPayload(const SdfPayload& payload) const;
1420 
1423  USD_API
1424  bool SetPayload(
1425  const std::string& assetPath, const SdfPath& primPath) const;
1426 
1430  USD_API
1431  bool SetPayload(const SdfLayerHandle& layer, const SdfPath& primPath) const;
1432 
1434 
1435  // --------------------------------------------------------------------- //
1437  // --------------------------------------------------------------------- //
1438 
1446  USD_API
1447  UsdPayloads GetPayloads() const;
1448 
1450  USD_API
1451  bool HasAuthoredPayloads() const;
1452 
1458  USD_API
1459  void Load(UsdLoadPolicy policy = UsdLoadWithDescendants) const;
1460 
1464  USD_API
1465  void Unload() const;
1466 
1467  // --------------------------------------------------------------------- //
1469  // --------------------------------------------------------------------- //
1470 
1480  USD_API
1481  UsdReferences GetReferences() const;
1482 
1484  USD_API
1485  bool HasAuthoredReferences() const;
1486 
1487  // --------------------------------------------------------------------- //
1489  // --------------------------------------------------------------------- //
1490 
1500  USD_API
1501  UsdInherits GetInherits() const;
1502 
1504  USD_API
1505  bool HasAuthoredInherits() const;
1506 
1507  // --------------------------------------------------------------------- //
1509  // --------------------------------------------------------------------- //
1510 
1518  USD_API
1520 
1522  USD_API
1523  bool HasAuthoredSpecializes() const;
1524 
1525  // --------------------------------------------------------------------- //
1529  // --------------------------------------------------------------------- //
1530 
1537  bool IsInstanceable() const {
1538  bool instanceable = false;
1539  return GetMetadata(SdfFieldKeys->Instanceable, &instanceable) &&
1540  instanceable;
1541  }
1542 
1545  bool SetInstanceable(bool instanceable) const {
1546  return SetMetadata(SdfFieldKeys->Instanceable, instanceable);
1547  }
1548 
1551  bool ClearInstanceable() const {
1552  return ClearMetadata(SdfFieldKeys->Instanceable);
1553  }
1554 
1558  return HasAuthoredMetadata(SdfFieldKeys->Instanceable);
1559  }
1560 
1566  bool IsInstance() const { return _Prim()->IsInstance(); }
1567 
1571  bool IsInstanceProxy() const {
1572  return Usd_IsInstanceProxy(_Prim(), _ProxyPrimPath());
1573  }
1574 
1582  USD_API
1583  static bool IsPrototypePath(const SdfPath& path);
1584 
1589  USD_API
1590  static bool IsPathInPrototype(const SdfPath& path);
1591 
1596  bool IsPrototype() const { return _Prim()->IsPrototype(); }
1597 
1602  bool IsInPrototype() const {
1603  return (IsInstanceProxy() ?
1604  IsPathInPrototype(GetPrimPath()) : _Prim()->IsInPrototype());
1605  }
1606 
1609  USD_API
1610  UsdPrim GetPrototype() const;
1611 
1616  if (IsInstanceProxy()) {
1617  return UsdPrim(_Prim(), SdfPath());
1618  }
1619  return UsdPrim();
1620  }
1621 
1627  USD_API
1628  std::vector<UsdPrim> GetInstances() const;
1630 
1631  // --------------------------------------------------------------------- //
1634  // --------------------------------------------------------------------- //
1635 
1658  const PcpPrimIndex &GetPrimIndex() const { return _Prim()->GetPrimIndex(); }
1659 
1680  USD_API
1682 
1690  USD_API
1692  const UsdEditTarget &editTarget) const;
1693 
1701  USD_API
1703  const UsdEditTarget &editTarget) const;
1704 
1706 
1707 private:
1708  friend class UsdObject;
1709  friend class UsdPrimSiblingIterator;
1710  friend class UsdPrimSubtreeIterator;
1711  friend class UsdProperty;
1712  friend class UsdSchemaBase;
1713  friend class UsdAPISchemaBase;
1714  friend class UsdStage;
1715  friend class UsdPrimRange;
1716  friend class Usd_PrimData;
1717  friend class Usd_PrimFlagsPredicate;
1718  friend struct UsdPrim_RelTargetFinder;
1719  friend struct UsdPrim_AttrConnectionFinder;
1720 
1721  // Prim constructor.
1722  UsdPrim(const Usd_PrimDataHandle &primData,
1723  const SdfPath &proxyPrimPath)
1724  : UsdObject(primData, proxyPrimPath) { }
1725 
1726  // General constructor.
1727  UsdPrim(UsdObjType objType,
1728  const Usd_PrimDataHandle &prim,
1729  const SdfPath &proxyPrimPath,
1730  const TfToken &propName)
1731  : UsdObject(objType, prim, proxyPrimPath, propName) {}
1732 
1733  // Helper to make a sibling range.
1734  inline SiblingRange
1735  _MakeSiblingRange(const Usd_PrimFlagsPredicate &pred) const;
1736 
1737  // Helper to make a range of descendants.
1738  inline SubtreeRange
1739  _MakeDescendantsRange(const Usd_PrimFlagsPredicate &pred) const;
1740 
1741  // Helper to make a vector of properties from names.
1742  std::vector<UsdProperty>
1743  _MakeProperties(const TfTokenVector &names) const;
1744 
1745  // Helper for Get{Authored}{PropertyNames,Properties}
1746  TfTokenVector _GetPropertyNames(
1747  bool onlyAuthored,
1748  bool applyOrder=true,
1749  const PropertyPredicateFunc &predicate={}) const;
1750 
1751  // Helper for Get(Authored)PropertiesInNamespace.
1752  std::vector<UsdProperty>
1753  _GetPropertiesInNamespace(const std::string &namespaces,
1754  bool onlyAuthored) const;
1755 
1756  // Helper for Get(Authored)Attributes.
1757  std::vector<UsdAttribute>
1758  _GetAttributes(bool onlyAuthored, bool applyOrder=false) const;
1759 
1760  // Helper for Get(Authored)Relationships.
1761  std::vector<UsdRelationship>
1762  _GetRelationships(bool onlyAuthored, bool applyOrder=false) const;
1763 
1764  friend const PcpPrimIndex &Usd_PrimGetSourcePrimIndex(const UsdPrim&);
1765  // Return a const reference to the source PcpPrimIndex for this prim.
1766  //
1767  // For all prims in prototypes (which includes the prototype prim itself),
1768  // this is the prim index for the instance that was chosen to serve
1769  // as the prototype for all other instances. This prim index will not
1770  // have the same path as the prim's path.
1771  //
1772  // This is a private helper but is also wrapped out to Python
1773  // for testing and debugging purposes.
1774  const PcpPrimIndex &_GetSourcePrimIndex() const
1775  { return _Prim()->GetSourcePrimIndex(); }
1776 
1777  // Helper function for MakeResolveTargetUpToEditTarget and
1778  // MakeResolveTargetStrongerThanEditTarget.
1780  _MakeResolveTargetFromEditTarget(
1781  const UsdEditTarget &editTarget,
1782  bool makeAsStrongerThan) const;
1783 };
1784 
1785 #ifdef doxygen
1786 
1790 public:
1796  typedef unspecified-integral-type difference_type;
1798  reference operator*() const;
1800  unspecified-type operator->() const;
1805 private:
1807  friend bool operator==(const UsdPrimSiblingIterator &lhs,
1808  const UsdPrimSiblingIterator &rhs);
1810  friend bool operator!=(const UsdPrimSiblingIterator &lhs,
1811  const UsdPrimSiblingIterator &rhs);
1812 };
1813 
1819 public:
1825  typedef unspecified-integral-type difference_type;
1830 
1834 
1836  template <class ForwardRange>
1837  UsdPrimSiblingRange(const ForwardRange &r);
1838 
1840  template <class ForwardRange>
1841  UsdPrimSiblingRange &operator=(const ForwardRange &r);
1842 
1844  iterator begin() const;
1845 
1847  iterator end() const;
1848 
1850  operator unspecified_bool_type() const;
1851 
1853  bool equal(const iterator_range&) const;
1854 
1856  reference front() const;
1857 
1859  iterator_range& advance_begin(difference_type n);
1860 
1862  iterator_range& advance_end(difference_type n);
1863 
1864  ;
1865  bool empty() const;
1866 
1867 private:
1869  friend bool operator==(const UsdPrimSiblingRange &lhs,
1870  const UsdPrimSiblingRange &rhs);
1872  friend bool operator!=(const UsdPrimSiblingRange &lhs,
1873  const UsdPrimSiblingRange &rhs);
1874 };
1875 
1876 #else
1877 
1878 // Sibling iterator class. Converts ref to weak and filters according to a
1879 // supplied predicate.
1880 class UsdPrimSiblingIterator : public boost::iterator_adaptor<
1881  UsdPrimSiblingIterator, // crtp base.
1882  const Usd_PrimData *, // base iterator.
1883  UsdPrim, // value type.
1884  boost::forward_traversal_tag, // traversal
1885  UsdPrim> // reference type.
1886 {
1887 public:
1888  // Default ctor.
1890 
1891 private:
1892  friend class UsdPrim;
1893 
1894  // Constructor used by Prim.
1895  UsdPrimSiblingIterator(const base_type &i, const SdfPath& proxyPrimPath,
1896  const Usd_PrimFlagsPredicate &predicate)
1897  : iterator_adaptor_(i)
1898  , _proxyPrimPath(proxyPrimPath)
1899  , _predicate(predicate) {
1900  // Need to advance iterator to first matching element.
1901  if (base() && !Usd_EvalPredicate(_predicate, base(), _proxyPrimPath))
1902  increment();
1903  }
1904 
1905  // Core implementation invoked by iterator_adaptor.
1906  friend class boost::iterator_core_access;
1907  bool equal(const UsdPrimSiblingIterator &other) const {
1908  return base() == other.base() &&
1909  _proxyPrimPath == other._proxyPrimPath &&
1910  _predicate == other._predicate;
1911  }
1912 
1913  void increment() {
1914  base_type &base = base_reference();
1915  if (Usd_MoveToNextSiblingOrParent(base, _proxyPrimPath, _predicate)) {
1916  base = nullptr;
1917  _proxyPrimPath = SdfPath();
1918  }
1919  }
1920 
1921  reference dereference() const {
1922  return UsdPrim(base(), _proxyPrimPath);
1923  }
1924 
1925  SdfPath _proxyPrimPath;
1926  Usd_PrimFlagsPredicate _predicate;
1927 };
1928 
1929 // Typedef iterator range.
1930 typedef boost::iterator_range<UsdPrimSiblingIterator> UsdPrimSiblingRange;
1931 
1932 // Inform TfIterator it should feel free to make copies of the range type.
1933 template <>
1934 struct Tf_ShouldIterateOverCopy<
1935  UsdPrimSiblingRange> : boost::true_type {};
1936 template <>
1937 struct Tf_ShouldIterateOverCopy<
1938  const UsdPrimSiblingRange> : boost::true_type {};
1939 
1940 #endif // doxygen
1941 
1942 
1944 UsdPrim::GetFilteredChildren(const Usd_PrimFlagsPredicate &pred) const
1945 {
1946  return _MakeSiblingRange(
1947  Usd_CreatePredicateForTraversal(_Prim(), _ProxyPrimPath(), pred));
1948 }
1949 
1952 {
1954 }
1955 
1958 {
1960 }
1961 
1962 // Helper to make a sibling range.
1964 UsdPrim::_MakeSiblingRange(const Usd_PrimFlagsPredicate &pred) const {
1965  Usd_PrimDataConstPtr firstChild = get_pointer(_Prim());
1966  SdfPath firstChildPath = _ProxyPrimPath();
1967  if (!Usd_MoveToChild(firstChild, firstChildPath, pred)) {
1968  firstChild = nullptr;
1969  firstChildPath = SdfPath();
1970  }
1971 
1972  return SiblingRange(
1973  SiblingIterator(firstChild, firstChildPath, pred),
1974  SiblingIterator(nullptr, SdfPath(), pred));
1975 }
1976 
1977 #ifdef doxygen
1978 
1982 public:
1988  typedef unspecified-integral-type difference_type;
1990  reference operator*() const;
1992  unspecified-type operator->() const;
1997 private:
1999  friend bool operator==(const UsdPrimSubtreeIterator &lhs,
2000  const UsdPrimSubtreeIterator &rhs);
2002  friend bool operator!=(const UsdPrimSubtreeIterator &lhs,
2003  const UsdPrimSubtreeIterator &rhs);
2004 };
2005 
2011 public:
2017  typedef unspecified-integral-type difference_type;
2022 
2026 
2028  template <class ForwardRange>
2029  UsdPrimSubtreeRange(const ForwardRange &r);
2030 
2032  template <class ForwardRange>
2033  UsdPrimSubtreeRange &operator=(const ForwardRange &r);
2034 
2036  iterator begin() const;
2037 
2039  iterator end() const;
2040 
2042  operator unspecified_bool_type() const;
2043 
2045  bool equal(const iterator_range&) const;
2046 
2048  reference front() const;
2049 
2051  iterator_range& advance_begin(difference_type n);
2052 
2054  iterator_range& advance_end(difference_type n);
2055 
2057  bool empty() const;
2058 
2059 private:
2061  friend bool operator==(const UsdPrimSubtreeRange &lhs,
2062  const UsdPrimSubtreeRange &rhs);
2064  friend bool operator!=(const UsdPrimSubtreeRange &lhs,
2065  const UsdPrimSubtreeRange &rhs);
2066 };
2067 
2068 #else
2069 
2070 // Subtree iterator class. Converts ref to weak and filters according to a
2071 // supplied predicate.
2072 class UsdPrimSubtreeIterator : public boost::iterator_adaptor<
2073  UsdPrimSubtreeIterator, // crtp base.
2074  const Usd_PrimData *, // base iterator.
2075  UsdPrim, // value type.
2076  boost::forward_traversal_tag, // traversal
2077  UsdPrim> // reference type.
2078 {
2079 public:
2080  // Default ctor.
2082 
2083 private:
2084  friend class UsdPrim;
2085 
2086  // Constructor used by Prim.
2087  UsdPrimSubtreeIterator(const base_type &i, const SdfPath &proxyPrimPath,
2088  const Usd_PrimFlagsPredicate &predicate)
2089  : iterator_adaptor_(i)
2090  , _proxyPrimPath(proxyPrimPath)
2091  , _predicate(predicate) {
2092  // Need to advance iterator to first matching element.
2093  base_type &base = base_reference();
2094  if (base && !Usd_EvalPredicate(_predicate, base, _proxyPrimPath)) {
2095  if (Usd_MoveToNextSiblingOrParent(base, _proxyPrimPath,
2096  _predicate)) {
2097  base = nullptr;
2098  _proxyPrimPath = SdfPath();
2099  }
2100  }
2101  }
2102 
2103  // Core implementation invoked by iterator_adaptor.
2104  friend class boost::iterator_core_access;
2105  bool equal(const UsdPrimSubtreeIterator &other) const {
2106  return base() == other.base() &&
2107  _proxyPrimPath == other._proxyPrimPath &&
2108  _predicate == other._predicate;
2109  }
2110 
2111  void increment() {
2112  base_type &base = base_reference();
2113  if (!Usd_MoveToChild(base, _proxyPrimPath, _predicate)) {
2114  while (Usd_MoveToNextSiblingOrParent(base, _proxyPrimPath,
2115  _predicate)) {}
2116  }
2117  }
2118 
2119  reference dereference() const {
2120  return UsdPrim(base(), _proxyPrimPath);
2121  }
2122 
2123  SdfPath _proxyPrimPath;
2124  Usd_PrimFlagsPredicate _predicate;
2125 };
2126 
2127 // Typedef iterator range.
2128 typedef boost::iterator_range<UsdPrimSubtreeIterator> UsdPrimSubtreeRange;
2129 
2130 // Inform TfIterator it should feel free to make copies of the range type.
2131 template <>
2132 struct Tf_ShouldIterateOverCopy<
2133  UsdPrimSubtreeRange> : boost::true_type {};
2134 template <>
2135 struct Tf_ShouldIterateOverCopy<
2136  const UsdPrimSubtreeRange> : boost::true_type {};
2137 
2138 #endif // doxygen
2139 
2141 UsdPrim::GetFilteredDescendants(const Usd_PrimFlagsPredicate &pred) const
2142 {
2143  return _MakeDescendantsRange(
2144  Usd_CreatePredicateForTraversal(_Prim(), _ProxyPrimPath(), pred));
2145 }
2146 
2149 {
2151 }
2152 
2155 {
2157 }
2158 
2159 // Helper to make a sibling range.
2161 UsdPrim::_MakeDescendantsRange(const Usd_PrimFlagsPredicate &pred) const {
2162  Usd_PrimDataConstPtr firstChild = get_pointer(_Prim());
2163  SdfPath firstChildPath = _ProxyPrimPath();
2164  Usd_PrimDataConstPtr endChild = firstChild;
2165  SdfPath endChildPath = firstChildPath;
2166  if (Usd_MoveToChild(firstChild, firstChildPath, pred)) {
2167  while (Usd_MoveToNextSiblingOrParent(endChild, endChildPath, pred)) {}
2168  }
2169 
2170  return SubtreeRange(
2171  SubtreeIterator(firstChild, firstChildPath, pred),
2172  SubtreeIterator(endChild, endChildPath, pred));
2173 }
2174 
2175 
2177 // UsdObject methods that require UsdPrim be a complete type.
2178 
2179 inline UsdPrim
2181 {
2182  return UsdPrim(_prim, _proxyPrimPath);
2183 }
2184 
2185 PXR_NAMESPACE_CLOSE_SCOPE
2186 
2187 #endif // PXR_USD_USD_PRIM_H
2188 
const UsdPrimTypeInfo & GetPrimTypeInfo() const
Return the prim's full type info composed from its type name, applied API schemas,...
Definition: prim.h:158
void ClearPropertyOrder() const
Remove the opinion for propertyOrder metadata on this prim at the current EditTarget.
Definition: prim.h:457
A proxy class for applying listOp edits to the specializes list for a prim.
Definition: specializes.h:51
bool SetMetadata(const TfToken &key, const T &value) const
Set metadatum key's value to value.
Definition: object.h:731
iterator::value_type value_type
Iterator value_type.
Definition: prim.h:2019
USD_API std::vector< UsdRelationship > GetAuthoredRelationships() const
Like GetRelationships(), but exclude relationships without authored scene description from the result...
unspecified integral type difference_type
Iterator difference type.
Definition: prim.h:1988
USD_API bool HasAttribute(const TfToken &attrName) const
Return true if this prim has an attribute named attrName, false otherwise.
UsdObjType
Enum values to represent the various Usd object types.
Definition: object.h:49
bool SetSpecifier(SdfSpecifier specifier) const
Author an opinion for this Prim's specifier at the current edit target.
Definition: prim.h:206
USD_API bool HasAuthoredPayloads() const
Return true if this prim has any authored payloads.
USD_API bool AddAppliedSchema(const TfToken &appliedSchemaName) const
Adds the applied API schema name token appliedSchemaName to the apiSchemas metadata for this prim at ...
bool empty() const
Return begin() == end().
PcpPrimIndex is an index of the all sites of scene description that contribute opinions to a specific...
Definition: primIndex.h:76
bool CanApplyAPI(std::string *whyNot=nullptr) const
}@
Definition: prim.h:661
unspecified UsdPrimDefaultPredicate
The default predicate used for prim traversals in methods like UsdPrim::GetChildren,...
USD_API UsdInherits GetInherits() const
Return a UsdInherits object that allows one to add, remove, or mutate inherits at the currently set U...
Standard pointer typedefs.
friend bool operator!=(const UsdPrimSubtreeIterator &lhs, const UsdPrimSubtreeIterator &rhs)
Inequality.
iterator end() const
Past-the-end iterator.
SubtreeRange GetFilteredDescendants(const Usd_PrimFlagsPredicate &predicate) const
Return a subset of all of this prim's descendants filtered by predicate as an iterable range.
Definition: prim.h:2141
value_type reference
Iterator reference type, in this case the same as value_type.
Definition: prim.h:1986
friend bool operator==(const UsdPrimSiblingIterator &lhs, const UsdPrimSiblingIterator &rhs)
Equality.
bool CanApplyAPI(const TfToken &instanceName, std::string *whyNot=nullptr) const
Returns whether a multiple-apply API schema with the given C++ type 'SchemaType' can be applied to th...
Definition: prim.h:697
bool IsGroup() const
Return true if this prim is a model group based on its kind metadata, false otherwise.
Definition: prim.h:278
SdfSpecifier GetSpecifier() const
Return this prim's composed specifier.
Definition: prim.h:170
UsdPrimSiblingIterator iterator
Iterator type.
Definition: prim.h:1821
void SetChildrenReorder(const TfTokenVector &order) const
Author an opinion for the metadata used to reorder children of this prim at the current EditTarget.
Definition: prim.h:1058
friend bool operator!=(const UsdPrimSiblingRange &lhs, const UsdPrimSiblingRange &rhs)
Inequality comparison.
USD_API UsdProperty GetProperty(const TfToken &propName) const
Return a UsdProperty with the name propName.
USD_API std::vector< UsdAttribute > GetAttributes() const
Like GetProperties(), but exclude all relationships from the result.
USD_API UsdAttribute CreateAttribute(const TfToken &name, const SdfValueTypeName &typeName, bool custom, SdfVariability variability=SdfVariabilityVarying) const
Author scene description for the attribute named attrName at the current EditTarget if none already e...
UsdPrim value_type
Iterator value type.
Definition: prim.h:1792
bool IsActive() const
Return true if this prim is active, meaning neither it nor any of its ancestors have active=false.
Definition: prim.h:239
bool ClearInstanceable() const
Remove the authored 'instanceable' opinion at the current EditTarget.
Definition: prim.h:1551
bool HasAuthoredInstanceable() const
Return true if this prim has an authored opinion for 'instanceable', false otherwise.
Definition: prim.h:1557
friend bool operator!=(const UsdPrimSiblingIterator &lhs, const UsdPrimSiblingIterator &rhs)
Inequality.
USD_API UsdReferences GetReferences() const
Return a UsdReferences object that allows one to add, remove, or mutate references at the currently s...
USD_API std::vector< UsdProperty > GetProperties(const PropertyPredicateFunc &predicate={}) const
Return all of this prim's properties (attributes and relationships), including all builtin properties...
bool empty() const
Return begin() == end().
SubtreeRange GetDescendants() const
Return this prim's active, loaded, defined, non-abstract descendants as an iterable range.
Definition: prim.h:2154
The outermost container for scene description, which owns and presents composed prims as a scenegraph...
Definition: stage.h:147
friend bool operator==(const UsdPrimSiblingRange &lhs, const UsdPrimSiblingRange &rhs)
Equality comparison.
Represents a value type name, i.e.
Definition: valueTypeName.h:87
Load a prim plus all its descendants.
Definition: common.h:118
bool IsInstanceable() const
Return true if this prim has been marked as instanceable.
Definition: prim.h:1537
A proxy class for applying listOp edits to the inherit paths list for a prim.
Definition: inherits.h:51
friend bool operator!=(const UsdPrimSubtreeRange &lhs, const UsdPrimSubtreeRange &rhs)
Inequality comparison.
static USD_API bool IsPathInPrototype(const SdfPath &path)
Return true if the given path identifies a prototype prim or a prim or property descendant of a proto...
UsdPrimSiblingIterator & operator++()
Postincrement.
unspecified integral type difference_type
Iterator difference type.
Definition: prim.h:1825
USD_API TfTokenVector GetChildrenNames() const
Return the names of the child prims in the order they appear when iterating over GetChildren.
USD_API bool HasAuthoredInherits() const
Return true if this prim has any authored inherits.
USD_API UsdPrim GetFilteredNextSibling(const Usd_PrimFlagsPredicate &predicate) const
Return this prim's next sibling that matches predicate if it has one, otherwise return the invalid Us...
USD_API std::vector< UsdProperty > GetAuthoredPropertiesInNamespace(const std::vector< std::string > &namespaces) const
Like GetPropertiesInNamespace(), but exclude properties that do not have authored scene description f...
The base class for all API schemas.
USD_API UsdVariantSet GetVariantSet(const std::string &variantSetName) const
Retrieve a specifically named VariantSet for editing or constructing a UsdEditTarget.
Scenegraph object for authoring and retrieving numeric, string, and array valued data,...
Definition: attribute.h:176
USD_API UsdPrim GetChild(const TfToken &name) const
Return this prim's direct child named name if it has one, otherwise return an invalid UsdPrim.
USD_API bool RemoveProperty(const TfToken &propName)
Remove all scene description for the property with the given propName in the current UsdEditTarget.
bool IsInstance() const
Return true if this prim is an instance of a prototype, false otherwise.
Definition: prim.h:1566
USD_API void Load(UsdLoadPolicy policy=UsdLoadWithDescendants) const
Load this prim, all its ancestors, and by default all its descendants.
USD_API bool HasAuthoredSpecializes() const
Returns true if this prim has any authored specializes.
bool IsInPrototype() const
Return true if this prim is a prototype prim or a descendant of a prototype prim, false otherwise.
Definition: prim.h:1602
bool equal(const iterator_range &) const
Equality compare.
USD_API TfTokenVector GetPropertyOrder() const
Return the strongest propertyOrder metadata value authored on this prim.
USD_API bool IsPseudoRoot() const
Returns true if the prim is the pseudo root.
Forward iterator range of sibling UsdPrim s.
Definition: prim.h:1818
UsdReferences provides an interface to authoring and introspecting references in Usd.
Definition: references.h:214
USD_API UsdAttribute GetAttribute(const TfToken &attrName) const
Return a UsdAttribute with the name attrName.
USD_API bool HasAuthoredReferences() const
Return true if this prim has any authored references.
UsdPrimSubtreeIterator iterator
Iterator type.
Definition: prim.h:2013
iterator::value_type value_type
Iterator value_type.
Definition: prim.h:1827
USD_API bool HasRelationship(const TfToken &relName) const
Return true if this prim has a relationship named relName, false otherwise.
USD_API SdfPathVector FindAllRelationshipTargetPaths(std::function< bool(UsdRelationship const &)> const &pred=nullptr, bool recurseOnTargets=false) const
Search the prim subtree rooted at this prim for relationships for which predicate returns true,...
Single Apply API schema.
reference front() const
Return *begin(). This range must not be empty.
void SetPropertyOrder(const TfTokenVector &order) const
Author an opinion for propertyOrder metadata on this prim at the current EditTarget.
Definition: prim.h:451
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
bool SetInstanceable(bool instanceable) const
Author 'instanceable' metadata for this prim at the current EditTarget.
Definition: prim.h:1545
USD_API PcpPrimIndex ComputeExpandedPrimIndex() const
Compute the prim index containing all sites that could contribute opinions to this prim.
bool RemoveAPI() const
Removes a single-apply API schema with the given C++ type 'SchemaType' from this prim in the current ...
Definition: prim.h:817
std::enable_if< T::schemaKind==UsdSchemaKind::MultipleApplyAPI, bool >::type HasAPI(const TfToken &instanceName=TfToken()) const
Return true if the UsdPrim has had a multiple-apply API schema represented by the C++ class type T ap...
Definition: prim.h:619
reference operator *() const
Dereference.
unspecified integral type difference_type
Iterator difference type.
Definition: prim.h:1796
iterator_range & advance_end(difference_type n)
Advance this range's end iterator.
USD_API bool ClearMetadata(const TfToken &key) const
Clears the authored key's value at the current EditTarget, returning false on error.
iterator begin() const
First iterator.
const UsdPrimDefinition & GetPrimDefinition() const
Return this prim's definition based on the prim's type if the type is a registered prim type.
Definition: prim.h:165
UsdPrimSiblingRange(UsdPrimSiblingIterator begin, UsdPrimSiblingIterator end)
Construct with a pair of iterators.
const PcpPrimIndex & GetPrimIndex() const
Return the cached prim index containing all sites that can contribute opinions to this prim.
Definition: prim.h:1658
UsdPrimSubtreeIterator & operator++()
Postincrement.
bool IsAbstract() const
Return true if this prim or any of its ancestors is a class.
Definition: prim.h:281
USD_API TfTokenVector GetAuthoredPropertyNames(const PropertyPredicateFunc &predicate={}) const
Return this prim's property names (attributes and relationships) that have authored scene description...
USD_API bool HasProperty(const TfToken &propName) const
Return true if this prim has an property named propName, false otherwise.
USD_API bool SetPayload(const SdfPayload &payload) const
USD_API std::vector< UsdProperty > GetPropertiesInNamespace(const std::vector< std::string > &namespaces) const
Return this prim's properties that are inside the given property namespace ordered according to the s...
A UsdVariantSet represents a single VariantSet in USD (e.g.
Definition: variantSets.h:56
bool ApplyAPI() const
Applies a single-apply API schema with the given C++ type 'SchemaType' to this prim in the current ed...
Definition: prim.h:737
Forward iterator range of sibling UsdPrim s.
Definition: prim.h:2010
USD_API TfTokenVector GetAllChildrenNames() const
Return the names of the child prims in the order they appear when iterating over GetAllChildren.
USD_API UsdPrim GetPrototype() const
If this prim is an instance, return the UsdPrim for the corresponding prototype.
UsdPrim GetParent() const
Return this prim's parent prim.
Definition: prim.h:1075
SiblingRange GetFilteredChildren(const Usd_PrimFlagsPredicate &predicate) const
Return a subset of all of this prim's children filtered by predicate as an iterable range.
Definition: prim.h:1944
SiblingRange GetChildren() const
Return this prim's active, loaded, defined, non-abstract children as an iterable range.
Definition: prim.h:1957
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
Represents a payload and all its meta data.
Definition: payload.h:60
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:134
UsdPrimSiblingRange & operator=(const ForwardRange &r)
Assign from another compatible range type.
bool IsA() const
Return true if the prim's schema type, is or inherits schema type T.
Definition: prim.h:543
SdfSpecifier
An enum that identifies the possible specifiers for an SdfPrimSpec.
Definition: types.h:123
UsdPrim value_type
Iterator value type.
Definition: prim.h:1984
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
friend bool operator==(const UsdPrimSubtreeRange &lhs, const UsdPrimSubtreeRange &rhs)
Equality comparison.
bool IsInstanceProxy() const
Return true if this prim is an instance proxy, false otherwise.
Definition: prim.h:1571
UsdPrimSubtreeRange & operator=(const ForwardRange &r)
Assign from another compatible range type.
const TfToken & GetTypeName() const
Return this prim's composed type name.
Definition: prim.h:217
SubtreeRange GetAllDescendants() const
Return all this prim's descendants as an iterable range.
Definition: prim.h:2148
unspecified type operator->() const
Indirection.
USD_API bool HasVariantSets() const
Return true if this prim has any authored VariantSets.
USD_API UsdVariantSets GetVariantSets() const
Return a UsdVariantSets object representing all the VariantSets present on this prim.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
USD_API UsdResolveTarget MakeResolveTargetUpToEditTarget(const UsdEditTarget &editTarget) const
Creates and returns a resolve target that, when passed to a UsdAttributeQuery for one of this prim's ...
USD_API bool ClearPayload() const
bool GetMetadata(const TfToken &key, T *value) const
Resolve the requested metadatum named key into value, returning true on success.
Definition: object.h:723
iterator_range & advance_begin(difference_type n)
Advance this range's begin iterator.
iterator::reference reference
Iterator reference_type.
Definition: prim.h:2021
USD_API bool HasPayload() const
USD_API UsdResolveTarget MakeResolveTargetStrongerThanEditTarget(const UsdEditTarget &editTarget) const
Creates and returns a resolve target that, when passed to a UsdAttributeQuery for one of this prim's ...
UsdPayloads provides an interface to authoring and introspecting payloads.
Definition: payloads.h:43
bool HasAuthoredActive() const
Return true if this prim has an authored opinion for 'active', false otherwise.
Definition: prim.h:262
A UsdRelationship creates dependencies between scenegraph objects by allowing a prim to target other ...
Definition: relationship.h:128
USD_API TfTokenVector GetPropertyNames(const PropertyPredicateFunc &predicate={}) const
Return all of this prim's property names (attributes and relationships), including all builtin proper...
USD_API SdfPathVector FindAllAttributeConnectionPaths(std::function< bool(UsdAttribute const &)> const &pred=nullptr, bool recurseOnSources=false) const
Search the prim subtree rooted at this prim for attributes for which predicate returns true,...
USD_API UsdRelationship GetRelationshipAtPath(const SdfPath &path) const
Returns the relationship at path on the same stage as this prim.
unspecified type operator->() const
Indirection.
USD_API void Unload() const
Unloads this prim and all its descendants.
SdfVariability
An enum that identifies variability types for attributes.
Definition: types.h:179
bool ClearTypeName() const
Clear the opinion for this Prim's typeName at the current edit target.
Definition: prim.h:226
Class that holds the full type information for a prim.
Definition: primTypeInfo.h:47
SiblingRange GetAllChildren() const
Return all this prim's children as an iterable range.
Definition: prim.h:1951
bool RemoveAPI(const TfToken &instanceName) const
Removes a multiple-apply API schema with the given C++ type 'SchemaType' and instance name instanceNa...
Definition: prim.h:860
USD_API std::vector< UsdPrim > GetInstances() const
If this prim is a prototype prim, returns all prims that are instances of this prototype.
friend bool operator==(const UsdPrimSubtreeIterator &lhs, const UsdPrimSubtreeIterator &rhs)
Equality.
UsdLoadPolicy
Controls UsdStage::Load() and UsdPrim::Load() behavior regarding whether or not descendant prims are ...
Definition: common.h:116
Multiple Apply API Schema.
UsdPrim GetPrimInPrototype() const
If this prim is an instance proxy, return the UsdPrim for the corresponding prim in the instance's pr...
Definition: prim.h:1615
Base class for UsdAttribute and UsdRelationship scenegraph objects.
Definition: property.h:55
USD_API std::vector< std::pair< SdfPrimSpecHandle, SdfLayerOffset > > GetPrimStackWithLayerOffsets() const
Return all the authored SdfPrimSpecs that may contain opinions for this prim in order from strong to ...
bool ClearActive() const
Remove the authored 'active' opinion at the current EditTarget.
Definition: prim.h:254
bool SetTypeName(const TfToken &typeName) const
Author this Prim's typeName at the current EditTarget.
Definition: prim.h:220
An forward-iterable range that traverses a subtree of prims rooted at a given prim in depth-first ord...
Definition: primRange.h:118
const SdfPath & GetPrimPath() const
Return this object's path if this object is a prim, otherwise this object's nearest owning prim's pat...
Definition: object.h:209
bool HasAuthoredTypeName() const
Return true if a typeName has been authored.
Definition: prim.h:231
void ClearChildrenReorder() const
Remove the opinion for the metadata used to reorder children of this prim at the current EditTarget.
Definition: prim.h:1064
bool IsModel() const
Return true if this prim is a model based on its kind metadata, false otherwise.
Definition: prim.h:273
bool IsLoaded() const
Return true if this prim is active, and either it is loadable and it is loaded, or its nearest loadab...
Definition: prim.h:269
unspecified integral type difference_type
Iterator difference type.
Definition: prim.h:2017
Class representing the builtin definition of a prim given the schemas registered in the schema regist...
reference operator *() const
Dereference.
bool IsPrototype() const
Return true if this prim is an instancing prototype prim, false otherwise.
Definition: prim.h:1596
Forward traversal iterator of sibling UsdPrim s.
Definition: prim.h:1981
unspecified UsdPrimAllPrimsPredicate
Predicate that includes all prims.
iterator begin() const
First iterator.
USD_API bool RemoveAppliedSchema(const TfToken &appliedSchemaName) const
Removes the applied API schema name token appliedSchemaName from the apiSchemas metadata for this pri...
UsdPrim()
Construct an invalid prim.
Definition: prim.h:146
std::function< bool(const TfToken &propertyName)> PropertyPredicateFunc
Alias for the "predicate" function parameter passed into the various Get{Authored}{PropertyNames,...
Definition: prim.h:305
reference front() const
Return *begin(). This range must not be empty.
TfType represents a dynamic runtime type.
Definition: type.h:64
UsdPrimSubtreeIterator SubtreeIterator
Convenience typedefs.
Definition: prim.h:142
bool IsDefined() const
Return true if this prim and all its ancestors have defining specifiers, false otherwise.
Definition: prim.h:285
USD_API SdfPrimSpecHandleVector GetPrimStack() const
Return all the authored SdfPrimSpecs that may contain opinions for this prim in order from strong to ...
bool equal(const iterator_range &) const
Equality compare.
USD_API TfTokenVector GetAppliedSchemas() const
Return a vector containing the names of API schemas which have been applied to this prim.
UsdPrimSiblingIterator SiblingIterator
Convenience typedefs.
Definition: prim.h:138
USD_API UsdSpecializes GetSpecializes() const
Return a UsdSpecializes object that allows one to add, remove, or mutate specializes at the currently...
USD_API UsdPrim GetPrimAtPath(const SdfPath &path) const
Returns the prim at path on the same stage as this prim.
UsdPrimSiblingIterator const_iterator
Const iterator type.
Definition: prim.h:1823
USD_API UsdObject GetObjectAtPath(const SdfPath &path) const
Returns the object at path on the same stage as this prim.
UsdVariantSets represents the collection of VariantSets that are present on a UsdPrim.
Definition: variantSets.h:222
iterator end() const
Past-the-end iterator.
bool SetActive(bool active) const
Author 'active' metadata for this prim at the current EditTarget.
Definition: prim.h:245
UsdPrimSubtreeIterator const_iterator
Const iterator type.
Definition: prim.h:2015
The base class for all schema types in Usd.
Definition: schemaBase.h:56
USD_API UsdRelationship GetRelationship(const TfToken &relName) const
Return a UsdRelationship with the name relName.
iterator::reference reference
Iterator reference_type.
Definition: prim.h:1829
Forward traversal iterator of sibling UsdPrim s.
Definition: prim.h:1789
USD_API UsdAttribute GetAttributeAtPath(const SdfPath &path) const
Returns the attribute at path on the same stage as this prim.
USD_API UsdPrim GetNextSibling() const
Return this prim's next active, loaded, defined, non-abstract sibling if it has one,...
USD_API UsdProperty GetPropertyAtPath(const SdfPath &path) const
Returns the property at path on the same stage as this prim.
USD_API TfTokenVector GetFilteredChildrenNames(const Usd_PrimFlagsPredicate &predicate) const
Return the names of the child prims in the order they appear when iterating over GetFilteredChildren(...
USD_API UsdPayloads GetPayloads() const
Return a UsdPayloads object that allows one to add, remove, or mutate payloads at the currently set U...
iterator_range & advance_end(difference_type n)
Advance this range's end iterator.
UsdPrim GetPrim() const
Return this object if it is a prim, otherwise return this object's nearest owning prim.
Definition: prim.h:2180
std::enable_if< T::schemaKind !=UsdSchemaKind::MultipleApplyAPI, bool >::type HasAPI() const
Using HasAPI in C++
Definition: prim.h:592
USD_API TfTokenVector GetChildrenReorder() const
Return the strongest opinion for the metadata used to reorder children of this prim.
UsdPrimSubtreeRange(UsdPrimSubtreeIterator begin, UsdPrimSubtreeIterator end)
Construct with a pair of iterators.
static USD_API bool IsPrototypePath(const SdfPath &path)
Return true if the given path identifies a prototype prim, false otherwise.
USD_API bool HasAuthoredMetadata(const TfToken &key) const
Returns true if the key has an authored value, false if no value was authored or the only value avail...
USD_API UsdRelationship CreateRelationship(const TfToken &relName, bool custom=true) const
Author scene description for the relationship named relName at the current EditTarget if none already...
value_type reference
Iterator reference type, in this case the same as value_type.
Definition: prim.h:1794
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
USD_API std::vector< UsdRelationship > GetRelationships() const
Like GetProperties(), but exclude all attributes from the result.
bool ApplyAPI(const TfToken &instanceName) const
Applies a multiple-apply API schema with the given C++ type 'SchemaType' and instance name instanceNa...
Definition: prim.h:779
USD_API std::vector< UsdAttribute > GetAuthoredAttributes() const
Like GetAttributes(), but exclude attributes without authored scene description from the result.
iterator_range & advance_begin(difference_type n)
Advance this range's begin iterator.
Defines a subrange of nodes and layers within a prim's prim index to consider when performing value r...
Definition: resolveTarget.h:73
bool HasDefiningSpecifier() const
Return true if this prim has a specifier of type SdfSpecifierDef or SdfSpecifierClass.
Definition: prim.h:289
USD_API std::vector< UsdProperty > GetAuthoredProperties(const PropertyPredicateFunc &predicate={}) const
Return this prim's properties (attributes and relationships) that have authored scene description,...