prim.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_USD_PRIM_H
8 #define PXR_USD_USD_PRIM_H
9 
11 
12 #include "pxr/pxr.h"
13 #include "pxr/usd/usd/api.h"
14 #include "pxr/usd/usd/common.h"
15 #include "pxr/usd/usd/object.h"
16 #include "pxr/usd/usd/primFlags.h"
17 #include "pxr/usd/usd/schemaRegistry.h"
18 
19 #include "pxr/usd/sdf/schema.h"
20 #include "pxr/base/trace/trace.h"
21 
23 #include "pxr/base/tf/refBase.h"
24 #include "pxr/base/tf/token.h"
25 #include "pxr/base/tf/weakBase.h"
26 
27 #include "pxr/usd/sdf/path.h"
28 
29 #include <iterator>
30 #include <string>
31 #include <type_traits>
32 #include <vector>
33 
34 PXR_NAMESPACE_OPEN_SCOPE
35 
36 class UsdPrim;
37 class UsdPrimDefinition;
38 class UsdPrimRange;
39 class Usd_PrimData;
40 
41 class UsdAttribute;
42 class UsdEditTarget;
43 class UsdRelationship;
44 class UsdPayloads;
45 class UsdReferences;
46 class UsdResolveTarget;
47 class UsdSchemaBase;
48 class UsdAPISchemaBase;
49 class UsdInherits;
50 class UsdSpecializes;
51 class UsdVariantSets;
52 class UsdVariantSet;
53 
54 class SdfPayload;
55 
58 
61 
116 class UsdPrim : public UsdObject
117 {
118 public:
122 
126 
128  UsdPrim() : UsdObject(_Null<UsdPrim>()) {}
129 
141  return _Prim()->GetPrimTypeInfo();
142  }
143 
148  return _Prim()->GetPrimDefinition();
149  }
150 
152  SdfSpecifier GetSpecifier() const { return _Prim()->GetSpecifier(); };
153 
167  USD_API
168  SdfPrimSpecHandleVector GetPrimStack() const;
169 
182  USD_API
183  std::vector<std::pair<SdfPrimSpecHandle, SdfLayerOffset>>
185 
188  bool SetSpecifier(SdfSpecifier specifier) const {
189  return SetMetadata(SdfFieldKeys->Specifier, specifier);
190  }
191 
199  const TfToken &GetTypeName() const { return _Prim()->GetTypeName(); };
200 
202  bool SetTypeName(const TfToken & typeName) const {
203  return SetMetadata(SdfFieldKeys->TypeName, typeName);
204  }
205 
208  bool ClearTypeName() const {
209  return ClearMetadata(SdfFieldKeys->TypeName);
210  }
211 
213  bool HasAuthoredTypeName() const {
214  return HasAuthoredMetadata(SdfFieldKeys->TypeName);
215  }
216 
221  bool IsActive() const { return _Prim()->IsActive(); }
222 
227  bool SetActive(bool active) const {
228  return SetMetadata(SdfFieldKeys->Active, active);
229  }
230 
236  bool ClearActive() const {
237  return ClearMetadata(SdfFieldKeys->Active);
238  }
239 
244  bool HasAuthoredActive() const {
245  return HasAuthoredMetadata(SdfFieldKeys->Active);
246  }
247 
251  bool IsLoaded() const { return _Prim()->IsLoaded(); }
252 
255  bool IsModel() const { return _Prim()->IsModel(); }
256 
263  bool IsGroup() const { return _Prim()->IsGroup(); }
264 
268  bool IsComponent() const { return _Prim()->IsComponent(); }
269 
276  USD_API
277  bool IsSubComponent() const { return _Prim()->IsSubComponent(); }
278 
280  bool IsAbstract() const { return _Prim()->IsAbstract(); }
281 
284  bool IsDefined() const { return _Prim()->IsDefined(); }
285 
287  bool HasClassSpecifier() const {
288  return _Prim()->HasClassSpecifier();
289  }
290 
293  bool HasDefiningSpecifier() const {
294  return _Prim()->HasDefiningSpecifier();
295  }
296 
306  USD_API
307  const TfTokenVector &GetAppliedSchemas() const;
308 
311  using PropertyPredicateFunc =
312  std::function<bool (const TfToken &propertyName)>;
313 
325  USD_API
327  const PropertyPredicateFunc &predicate={}) const;
328 
342  USD_API
344  const PropertyPredicateFunc &predicate={}) const;
345 
389  USD_API
390  std::vector<UsdProperty> GetProperties(
391  const PropertyPredicateFunc &predicate={}) const;
392 
406  USD_API
407  std::vector<UsdProperty> GetAuthoredProperties(
408  const PropertyPredicateFunc &predicate={}) const;
409 
421  USD_API
422  std::vector<UsdProperty>
423  GetPropertiesInNamespace(const std::vector<std::string> &namespaces) const;
424 
429  USD_API
430  std::vector<UsdProperty>
431  GetPropertiesInNamespace(const std::string &namespaces) const;
432 
438  USD_API
439  std::vector<UsdProperty>
441  const std::vector<std::string> &namespaces) const;
442 
448  USD_API
449  std::vector<UsdProperty>
450  GetAuthoredPropertiesInNamespace(const std::string &namespaces) const;
451 
453  USD_API
455 
458  void SetPropertyOrder(const TfTokenVector &order) const {
459  SetMetadata(SdfFieldKeys->PropertyOrder, order);
460  }
461 
466  USD_API
467  static void
468  ApplyPropertyOrder(const TfTokenVector &order, TfTokenVector *names);
469 
472  void ClearPropertyOrder() const {
473  ClearMetadata(SdfFieldKeys->PropertyOrder);
474  }
475 
487  USD_API
488  bool RemoveProperty(const TfToken &propName);
489 
502  USD_API
503  UsdProperty GetProperty(const TfToken &propName) const;
504 
507  USD_API
508  bool HasProperty(const TfToken &propName) const;
509 
528  USD_API
529  bool GetKind(TfToken *kind) const;
530 
533  USD_API
534  bool SetKind(const TfToken &kind) const;
535 
536 private:
537  // Helper functions for the public schema query and API schema
538  // authoring functions. The public functions have overloads that take
539  // a type, an identifier, or a family which all are used to find the
540  // SchemaInfo from the schema registry.
541  USD_API
542  bool _IsA(const UsdSchemaRegistry::SchemaInfo *schemaInfo) const;
543 
544  USD_API
545  bool _HasAPI(const UsdSchemaRegistry::SchemaInfo *schemaInfo) const;
546 
547  USD_API
548  bool _HasAPIInstance(
549  const UsdSchemaRegistry::SchemaInfo *schemaInfo,
550  const TfToken &instanceName) const;
551 
552  USD_API
553  bool _CanApplySingleApplyAPI(
554  const UsdSchemaRegistry::SchemaInfo &schemaInfo,
555  std::string *whyNot) const;
556 
557  USD_API
558  bool _CanApplyMultipleApplyAPI(
559  const UsdSchemaRegistry::SchemaInfo &schemaInfo,
560  const TfToken& instanceName,
561  std::string *whyNot) const;
562 
563  USD_API
564  bool _ApplySingleApplyAPI(
565  const UsdSchemaRegistry::SchemaInfo &schemaInfo) const;
566 
567  USD_API
568  bool _ApplyMultipleApplyAPI(
569  const UsdSchemaRegistry::SchemaInfo &schemaInfo,
570  const TfToken &instanceName) const;
571 
572  USD_API
573  bool _RemoveSingleApplyAPI(
574  const UsdSchemaRegistry::SchemaInfo &schemaInfo) const;
575 
576  USD_API
577  bool _RemoveMultipleApplyAPI(
578  const UsdSchemaRegistry::SchemaInfo &schemaInfo,
579  const TfToken &instanceName) const;
580 
581 public:
585 
592  template <typename SchemaType>
593  bool IsA() const {
594  static_assert(std::is_base_of<UsdSchemaBase, SchemaType>::value,
595  "Provided type must derive UsdSchemaBase.");
596  return _IsA(UsdSchemaRegistry::FindSchemaInfo<SchemaType>());
597  };
598 
600  USD_API
601  bool IsA(const TfType& schemaType) const;
602 
605  USD_API
606  bool IsA(const TfToken& schemaIdentifier) const;
607 
610  USD_API
611  bool IsA(const TfToken& schemaFamily,
612  UsdSchemaVersion schemaVersion) const;
613 
615 
619 
622  USD_API
623  bool IsInFamily(const TfToken &schemaFamily) const;
624 
628  USD_API
629  bool IsInFamily(
630  const TfToken &schemaFamily,
631  UsdSchemaVersion schemaVersion,
632  UsdSchemaRegistry::VersionPolicy versionPolicy) const;
633 
638  template <typename SchemaType>
640  UsdSchemaRegistry::VersionPolicy versionPolicy) const {
641  static_assert(std::is_base_of<UsdSchemaBase, SchemaType>::value,
642  "Provided type must derive UsdSchemaBase.");
643  const UsdSchemaRegistry::SchemaInfo *schemaInfo =
644  UsdSchemaRegistry::FindSchemaInfo<SchemaType>();
645  if (!schemaInfo) {
646  TF_CODING_ERROR("Class '%s' is not correctly registered with the "
647  "UsdSchemaRegistry as a schema type. The schema may need to be "
648  "regenerated.",
649  TfType::Find<SchemaType>().GetTypeName().c_str());
650  return false;
651  }
652  return IsInFamily(schemaInfo->family, schemaInfo->version,
653  versionPolicy);
654  };
655 
660  USD_API
661  bool IsInFamily(
662  const TfType &schemaType,
663  UsdSchemaRegistry::VersionPolicy versionPolicy) const;
664 
673  USD_API
674  bool IsInFamily(
675  const TfToken &schemaIdentifier,
676  UsdSchemaRegistry::VersionPolicy versionPolicy) const;
677 
682  USD_API
684  const TfToken &schemaFamily,
685  UsdSchemaVersion *schemaVersion) const;
686 
688 
734 
741  template <typename SchemaType>
742  bool
743  HasAPI() const {
744  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
745  "Provided type must derive UsdAPISchemaBase.");
746  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
747  "Provided type must not be UsdAPISchemaBase.");
748  static_assert(
749  SchemaType::schemaKind == UsdSchemaKind::SingleApplyAPI ||
750  SchemaType::schemaKind == UsdSchemaKind::MultipleApplyAPI,
751  "Provided schema type must be an applied API schema.");
752 
753  return _HasAPI(UsdSchemaRegistry::FindSchemaInfo<SchemaType>());
754  }
755 
761  template <typename SchemaType>
762  bool
763  HasAPI(const TfToken &instanceName) const {
764  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
765  "Provided type must derive UsdAPISchemaBase.");
766  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
767  "Provided type must not be UsdAPISchemaBase.");
768  static_assert(SchemaType::schemaKind == UsdSchemaKind::MultipleApplyAPI,
769  "Provided schema type must be a multi apply API schema.");
770 
771  return _HasAPIInstance(
772  UsdSchemaRegistry::FindSchemaInfo<SchemaType>(), instanceName);
773  }
774 
776  USD_API
777  bool HasAPI(const TfType& schemaType) const;
778 
781  USD_API
782  bool HasAPI(const TfType& schemaType,
783  const TfToken& instanceName) const;
784 
787  USD_API
788  bool HasAPI(const TfToken& schemaIdentifier) const;
789 
793  USD_API
794  bool HasAPI(const TfToken& schemaIdentifier,
795  const TfToken& instanceName) const;
796 
799  USD_API
800  bool HasAPI(const TfToken& schemaFamily,
801  UsdSchemaVersion schemaVersion) const;
802 
806  USD_API
807  bool HasAPI(const TfToken& schemaFamily,
808  UsdSchemaVersion schemaVersion,
809  const TfToken& instanceName) const;
810 
812 
816 
823  USD_API
824  bool HasAPIInFamily(
825  const TfToken &schemaFamily) const;
826 
832  USD_API
833  bool HasAPIInFamily(
834  const TfToken &schemaFamily,
835  const TfToken &instanceName) const;
836 
845  USD_API
846  bool HasAPIInFamily(
847  const TfToken &schemaFamily,
848  UsdSchemaVersion schemaVersion,
849  UsdSchemaRegistry::VersionPolicy versionPolicy) const;
850 
857  USD_API
858  bool HasAPIInFamily(
859  const TfToken &schemaFamily,
860  UsdSchemaVersion schemaVersion,
861  UsdSchemaRegistry::VersionPolicy versionPolicy,
862  const TfToken &instanceName) const;
863 
868  template <typename SchemaType>
870  UsdSchemaRegistry::VersionPolicy versionPolicy) const {
871  static_assert(std::is_base_of<UsdSchemaBase, SchemaType>::value,
872  "Provided type must derive UsdSchemaBase.");
873  const UsdSchemaRegistry::SchemaInfo *schemaInfo =
874  UsdSchemaRegistry::FindSchemaInfo<SchemaType>();
875  if (!schemaInfo) {
876  TF_CODING_ERROR("Class '%s' is not correctly registered with the "
877  "UsdSchemaRegistry as a schema type. The schema may need to be "
878  "regenerated.",
879  TfType::Find<SchemaType>().GetTypeName().c_str());
880  return false;
881  }
882  return HasAPIInFamily(schemaInfo->family, schemaInfo->version,
883  versionPolicy);
884  };
885 
890  template <typename SchemaType>
892  UsdSchemaRegistry::VersionPolicy versionPolicy,
893  const TfToken &instanceName) const {
894  static_assert(std::is_base_of<UsdSchemaBase, SchemaType>::value,
895  "Provided type must derive UsdSchemaBase.");
896  const UsdSchemaRegistry::SchemaInfo *schemaInfo =
897  UsdSchemaRegistry::FindSchemaInfo<SchemaType>();
898  if (!schemaInfo) {
899  TF_CODING_ERROR("Class '%s' is not correctly registered with the "
900  "UsdSchemaRegistry as a schema type. The schema may need to be "
901  "regenerated.",
902  TfType::Find<SchemaType>().GetTypeName().c_str());
903  return false;
904  }
905  return HasAPIInFamily(schemaInfo->family, schemaInfo->version,
906  versionPolicy, instanceName);
907  };
908 
913  USD_API
914  bool HasAPIInFamily(
915  const TfType &schemaType,
916  UsdSchemaRegistry::VersionPolicy versionPolicy) const;
917 
922  USD_API
923  bool HasAPIInFamily(
924  const TfType &schemaType,
925  UsdSchemaRegistry::VersionPolicy versionPolicy,
926  const TfToken &instanceName) const;
927 
936  USD_API
937  bool HasAPIInFamily(
938  const TfToken &schemaIdentifier,
939  UsdSchemaRegistry::VersionPolicy versionPolicy) const;
940 
949  USD_API
950  bool HasAPIInFamily(
951  const TfToken &schemaIdentifier,
952  UsdSchemaRegistry::VersionPolicy versionPolicy,
953  const TfToken &instanceName) const;
954 
968  USD_API
969  bool
971  const TfToken &schemaFamily,
972  UsdSchemaVersion *schemaVersion) const;
973 
986  USD_API
987  bool
989  const TfToken &schemaFamily,
990  const TfToken &instanceName,
991  UsdSchemaVersion *schemaVersion) const;
992 
994 
998 
1011  template <typename SchemaType>
1012  bool CanApplyAPI(std::string *whyNot = nullptr) const {
1013  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
1014  "Provided type must derive UsdAPISchemaBase.");
1015  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
1016  "Provided type must not be UsdAPISchemaBase.");
1017  static_assert(SchemaType::schemaKind == UsdSchemaKind::SingleApplyAPI,
1018  "Provided schema type must be a single apply API schema.");
1019 
1020  const UsdSchemaRegistry::SchemaInfo *schemaInfo =
1021  UsdSchemaRegistry::FindSchemaInfo<SchemaType>();
1022  if (!schemaInfo) {
1023  TF_CODING_ERROR("Class '%s' is not correctly registered with the "
1024  "UsdSchemaRegistry as a schema type. The schema may need to be "
1025  "regenerated.",
1026  TfType::Find<SchemaType>().GetTypeName().c_str());
1027  return false;
1028  }
1029  return _CanApplySingleApplyAPI(*schemaInfo, whyNot);
1030  }
1031 
1045  template <typename SchemaType>
1046  bool CanApplyAPI(const TfToken &instanceName,
1047  std::string *whyNot = nullptr) const {
1048  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
1049  "Provided type must derive UsdAPISchemaBase.");
1050  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
1051  "Provided type must not be UsdAPISchemaBase.");
1052  static_assert(SchemaType::schemaKind == UsdSchemaKind::MultipleApplyAPI,
1053  "Provided schema type must be a multiple apply API schema.");
1054 
1055  const UsdSchemaRegistry::SchemaInfo *schemaInfo =
1056  UsdSchemaRegistry::FindSchemaInfo<SchemaType>();
1057  if (!schemaInfo) {
1058  TF_CODING_ERROR("Class '%s' is not correctly registered with the "
1059  "UsdSchemaRegistry as a schema type. The schema may need to be "
1060  "regenerated.",
1061  TfType::Find<SchemaType>().GetTypeName().c_str());
1062  return false;
1063  }
1064  return _CanApplyMultipleApplyAPI(*schemaInfo, instanceName, whyNot);
1065  }
1066 
1069  USD_API
1070  bool CanApplyAPI(const TfType& schemaType,
1071  std::string *whyNot = nullptr) const;
1072 
1076  USD_API
1077  bool CanApplyAPI(const TfType& schemaType,
1078  const TfToken& instanceName,
1079  std::string *whyNot = nullptr) const;
1080 
1083  USD_API
1084  bool CanApplyAPI(const TfToken& schemaIdentifier,
1085  std::string *whyNot = nullptr) const;
1086 
1091  USD_API
1092  bool CanApplyAPI(const TfToken& schemaIdentifier,
1093  const TfToken& instanceName,
1094  std::string *whyNot = nullptr) const;
1095 
1098  USD_API
1099  bool CanApplyAPI(const TfToken& schemaFamily,
1100  UsdSchemaVersion schemaVersion,
1101  std::string *whyNot = nullptr) const;
1102 
1107  USD_API
1108  bool CanApplyAPI(const TfToken& schemaFamily,
1109  UsdSchemaVersion schemaVersion,
1110  const TfToken& instanceName,
1111  std::string *whyNot = nullptr) const;
1112 
1114 
1118 
1134  template <typename SchemaType>
1135  bool ApplyAPI() const {
1136  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
1137  "Provided type must derive UsdAPISchemaBase.");
1138  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
1139  "Provided type must not be UsdAPISchemaBase.");
1140  static_assert(SchemaType::schemaKind == UsdSchemaKind::SingleApplyAPI,
1141  "Provided schema type must be a single apply API schema.");
1142 
1143  const UsdSchemaRegistry::SchemaInfo *schemaInfo =
1144  UsdSchemaRegistry::FindSchemaInfo<SchemaType>();
1145  if (!schemaInfo) {
1146  TF_CODING_ERROR("Class '%s' is not correctly registered with the "
1147  "UsdSchemaRegistry as a schema type. The schema may need to be "
1148  "regenerated.",
1149  TfType::Find<SchemaType>().GetTypeName().c_str());
1150  return false;
1151  }
1152  return _ApplySingleApplyAPI(*schemaInfo);
1153  }
1154 
1175  template <typename SchemaType>
1176  bool ApplyAPI(const TfToken &instanceName) const {
1177  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
1178  "Provided type must derive UsdAPISchemaBase.");
1179  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
1180  "Provided type must not be UsdAPISchemaBase.");
1181  static_assert(SchemaType::schemaKind == UsdSchemaKind::MultipleApplyAPI,
1182  "Provided schema type must be a multiple apply API schema.");
1183 
1184  const UsdSchemaRegistry::SchemaInfo *schemaInfo =
1185  UsdSchemaRegistry::FindSchemaInfo<SchemaType>();
1186  if (!schemaInfo) {
1187  TF_CODING_ERROR("Class '%s' is not correctly registered with the "
1188  "UsdSchemaRegistry as a schema type. The schema may need to be "
1189  "regenerated.",
1190  TfType::Find<SchemaType>().GetTypeName().c_str());
1191  return false;
1192  }
1193  return _ApplyMultipleApplyAPI(*schemaInfo, instanceName);
1194  }
1195 
1197  USD_API
1198  bool ApplyAPI(const TfType& schemaType) const;
1199 
1202  USD_API
1203  bool ApplyAPI(const TfType& schemaType,
1204  const TfToken& instanceName) const;
1205 
1208  USD_API
1209  bool ApplyAPI(const TfToken& schemaIdentifier) const;
1210 
1214  USD_API
1215  bool ApplyAPI(const TfToken& schemaIdentifier,
1216  const TfToken& instanceName) const;
1217 
1220  USD_API
1221  bool ApplyAPI(const TfToken& schemaFamily,
1222  UsdSchemaVersion schemaVersion) const;
1223 
1227  USD_API
1228  bool ApplyAPI(const TfToken& schemaFamily,
1229  UsdSchemaVersion schemaVersion,
1230  const TfToken& instanceName) const;
1231 
1233 
1237 
1254  template <typename SchemaType>
1255  bool RemoveAPI() const {
1256  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
1257  "Provided type must derive UsdAPISchemaBase.");
1258  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
1259  "Provided type must not be UsdAPISchemaBase.");
1260  static_assert(SchemaType::schemaKind == UsdSchemaKind::SingleApplyAPI,
1261  "Provided schema type must be a single apply API schema.");
1262 
1263  const UsdSchemaRegistry::SchemaInfo *schemaInfo =
1264  UsdSchemaRegistry::FindSchemaInfo<SchemaType>();
1265  if (!schemaInfo) {
1266  TF_CODING_ERROR("Class '%s' is not correctly registered with the "
1267  "UsdSchemaRegistry as a schema type. The schema may need to be "
1268  "regenerated.",
1269  TfType::Find<SchemaType>().GetTypeName().c_str());
1270  return false;
1271  }
1272  return _RemoveSingleApplyAPI(*schemaInfo);
1273  }
1274 
1296  template <typename SchemaType>
1297  bool RemoveAPI(const TfToken &instanceName) const {
1298  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
1299  "Provided type must derive UsdAPISchemaBase.");
1300  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
1301  "Provided type must not be UsdAPISchemaBase.");
1302  static_assert(SchemaType::schemaKind == UsdSchemaKind::MultipleApplyAPI,
1303  "Provided schema type must be a multiple apply API schema.");
1304 
1305  const UsdSchemaRegistry::SchemaInfo *schemaInfo =
1306  UsdSchemaRegistry::FindSchemaInfo<SchemaType>();
1307  if (!schemaInfo) {
1308  TF_CODING_ERROR("Class '%s' is not correctly registered with the "
1309  "UsdSchemaRegistry as a schema type. The schema may need to be "
1310  "regenerated.",
1311  TfType::Find<SchemaType>().GetTypeName().c_str());
1312  return false;
1313  }
1314  return _RemoveMultipleApplyAPI(*schemaInfo, instanceName);
1315  }
1316 
1318  USD_API
1319  bool RemoveAPI(const TfType& schemaType) const;
1320 
1323  USD_API
1324  bool RemoveAPI(const TfType& schemaType,
1325  const TfToken& instanceName) const;
1326 
1329  USD_API
1330  bool RemoveAPI(const TfToken& schemaIdentifier) const;
1331 
1335  USD_API
1336  bool RemoveAPI(const TfToken& schemaIdentifier,
1337  const TfToken& instanceName) const;
1338 
1341  USD_API
1342  bool RemoveAPI(const TfToken& schemaFamily,
1343  UsdSchemaVersion schemaVersion) const;
1344 
1348  USD_API
1349  bool RemoveAPI(const TfToken& schemaFamily,
1350  UsdSchemaVersion schemaVersion,
1351  const TfToken& instanceName) const;
1352 
1354 
1378  USD_API
1379  bool AddAppliedSchema(const TfToken &appliedSchemaName) const;
1380 
1405  USD_API
1406  bool RemoveAppliedSchema(const TfToken &appliedSchemaName) const;
1407 
1408  // --------------------------------------------------------------------- //
1410  // --------------------------------------------------------------------- //
1411 
1417  USD_API
1418  UsdPrim GetChild(const TfToken &name) const;
1419 
1428  inline SiblingRange GetChildren() const;
1429 
1431  inline SiblingRange GetAllChildren() const;
1432 
1452  inline SiblingRange
1453  GetFilteredChildren(const Usd_PrimFlagsPredicate &predicate) const;
1454 
1457  USD_API
1459 
1462  USD_API
1464 
1467  USD_API
1469  const Usd_PrimFlagsPredicate &predicate) const;
1470 
1483  inline SubtreeRange GetDescendants() const;
1484 
1493  inline SubtreeRange GetAllDescendants() const;
1494 
1518  inline SubtreeRange
1519  GetFilteredDescendants(const Usd_PrimFlagsPredicate &predicate) const;
1520 
1526  USD_API
1528 
1531  void SetChildrenReorder(const TfTokenVector &order) const {
1532  SetMetadata(SdfFieldKeys->PrimOrder, order);
1533  }
1534 
1537  void ClearChildrenReorder() const {
1538  ClearMetadata(SdfFieldKeys->PrimOrder);
1539  }
1540 
1541 public:
1542  // --------------------------------------------------------------------- //
1544  // --------------------------------------------------------------------- //
1545 
1548  UsdPrim GetParent() const {
1549  Usd_PrimDataConstPtr prim = get_pointer(_Prim());
1550  SdfPath proxyPrimPath = _ProxyPrimPath();
1551  Usd_MoveToParent(prim, proxyPrimPath);
1552  return UsdPrim(prim, proxyPrimPath);
1553  }
1554 
1563  USD_API
1564  UsdPrim GetNextSibling() const;
1565 
1571  USD_API
1573  const Usd_PrimFlagsPredicate &predicate) const;
1574 
1581  USD_API
1582  bool IsPseudoRoot() const;
1583 
1587  USD_API UsdPrim GetPrimAtPath(const SdfPath& path) const;
1588 
1592  USD_API UsdObject GetObjectAtPath(const SdfPath& path) const;
1593 
1602  USD_API UsdProperty GetPropertyAtPath(const SdfPath& path) const;
1603 
1612  USD_API UsdAttribute GetAttributeAtPath(const SdfPath& path) const;
1613 
1622  USD_API UsdRelationship GetRelationshipAtPath(const SdfPath& path) const;
1623 
1624  // --------------------------------------------------------------------- //
1626  // --------------------------------------------------------------------- //
1627 
1633  USD_API
1635 
1643  USD_API
1644  UsdVariantSet GetVariantSet(const std::string& variantSetName) const;
1645 
1651  USD_API
1652  bool HasVariantSets() const;
1653 
1654  // --------------------------------------------------------------------- //
1656  // --------------------------------------------------------------------- //
1657 
1697  USD_API
1698  UsdAttribute
1699  CreateAttribute(const TfToken& name,
1700  const SdfValueTypeName &typeName,
1701  bool custom,
1702  SdfVariability variability = SdfVariabilityVarying) const;
1705  USD_API
1706  UsdAttribute
1707  CreateAttribute(const TfToken& name,
1708  const SdfValueTypeName &typeName,
1709  SdfVariability variability = SdfVariabilityVarying) const;
1710 
1715  USD_API
1717  const std::vector<std::string> &nameElts,
1718  const SdfValueTypeName &typeName,
1719  bool custom,
1720  SdfVariability variability = SdfVariabilityVarying) const;
1724  USD_API
1726  const std::vector<std::string> &nameElts,
1727  const SdfValueTypeName &typeName,
1728  SdfVariability variability = SdfVariabilityVarying) const;
1729 
1731  USD_API
1732  std::vector<UsdAttribute> GetAttributes() const;
1733 
1736  USD_API
1737  std::vector<UsdAttribute> GetAuthoredAttributes() const;
1738 
1751  USD_API
1752  UsdAttribute GetAttribute(const TfToken& attrName) const;
1753 
1756  USD_API
1757  bool HasAttribute(const TfToken& attrName) const;
1758 
1765  USD_API
1766  SdfPathVector
1768  Usd_PrimFlagsPredicate const &traversalPredicate,
1769  std::function<bool (UsdAttribute const &)> const &pred = nullptr,
1770  bool recurseOnSources = false) const;
1771 
1775  USD_API
1776  SdfPathVector
1778  std::function<bool (UsdAttribute const &)> const &pred = nullptr,
1779  bool recurseOnSources = false) const;
1780 
1781  // --------------------------------------------------------------------- //
1783  // --------------------------------------------------------------------- //
1784 
1821  USD_API
1823  bool custom=true) const;
1824 
1829  USD_API
1830  UsdRelationship CreateRelationship(const std::vector<std::string> &nameElts,
1831  bool custom=true)
1832  const;
1833 
1835  USD_API
1836  std::vector<UsdRelationship> GetRelationships() const;
1837 
1840  USD_API
1841  std::vector<UsdRelationship> GetAuthoredRelationships() const;
1842 
1855  USD_API
1856  UsdRelationship GetRelationship(const TfToken& relName) const;
1857 
1860  USD_API
1861  bool HasRelationship(const TfToken& relName) const;
1862 
1869  USD_API
1870  SdfPathVector
1872  Usd_PrimFlagsPredicate const &traversalPredicate,
1873  std::function<bool (UsdRelationship const &)> const &pred = nullptr,
1874  bool recurseOnTargets = false) const;
1875 
1879  USD_API
1880  SdfPathVector
1882  std::function<bool (UsdRelationship const &)> const &pred = nullptr,
1883  bool recurseOnTargets = false) const;
1884 
1885  // --------------------------------------------------------------------- //
1892  // --------------------------------------------------------------------- //
1893 
1897  USD_API
1898  bool ClearPayload() const;
1899 
1904  USD_API
1905  bool HasPayload() const;
1906 
1912  USD_API
1913  bool SetPayload(const SdfPayload& payload) const;
1914 
1917  USD_API
1918  bool SetPayload(
1919  const std::string& assetPath, const SdfPath& primPath) const;
1920 
1924  USD_API
1925  bool SetPayload(const SdfLayerHandle& layer, const SdfPath& primPath) const;
1926 
1928 
1929  // --------------------------------------------------------------------- //
1931  // --------------------------------------------------------------------- //
1932 
1940  USD_API
1941  UsdPayloads GetPayloads() const;
1942 
1944  USD_API
1945  bool HasAuthoredPayloads() const;
1946 
1952  USD_API
1953  void Load(UsdLoadPolicy policy = UsdLoadWithDescendants) const;
1954 
1958  USD_API
1959  void Unload() const;
1960 
1961  // --------------------------------------------------------------------- //
1963  // --------------------------------------------------------------------- //
1964 
1974  USD_API
1975  UsdReferences GetReferences() const;
1976 
1978  USD_API
1979  bool HasAuthoredReferences() const;
1980 
1981  // --------------------------------------------------------------------- //
1983  // --------------------------------------------------------------------- //
1984 
1994  USD_API
1995  UsdInherits GetInherits() const;
1996 
1998  USD_API
1999  bool HasAuthoredInherits() const;
2000 
2001  // --------------------------------------------------------------------- //
2003  // --------------------------------------------------------------------- //
2004 
2012  USD_API
2014 
2016  USD_API
2017  bool HasAuthoredSpecializes() const;
2018 
2019  // --------------------------------------------------------------------- //
2023  // --------------------------------------------------------------------- //
2024 
2031  bool IsInstanceable() const {
2032  bool instanceable = false;
2033  return GetMetadata(SdfFieldKeys->Instanceable, &instanceable) &&
2034  instanceable;
2035  }
2036 
2039  bool SetInstanceable(bool instanceable) const {
2040  return SetMetadata(SdfFieldKeys->Instanceable, instanceable);
2041  }
2042 
2045  bool ClearInstanceable() const {
2046  return ClearMetadata(SdfFieldKeys->Instanceable);
2047  }
2048 
2052  return HasAuthoredMetadata(SdfFieldKeys->Instanceable);
2053  }
2054 
2060  bool IsInstance() const { return _Prim()->IsInstance(); }
2061 
2065  bool IsInstanceProxy() const {
2066  return Usd_IsInstanceProxy(_Prim(), _ProxyPrimPath());
2067  }
2068 
2076  USD_API
2077  static bool IsPrototypePath(const SdfPath& path);
2078 
2083  USD_API
2084  static bool IsPathInPrototype(const SdfPath& path);
2085 
2090  bool IsPrototype() const { return _Prim()->IsPrototype(); }
2091 
2096  bool IsInPrototype() const {
2097  return (IsInstanceProxy() ?
2098  IsPathInPrototype(GetPrimPath()) : _Prim()->IsInPrototype());
2099  }
2100 
2103  USD_API
2104  UsdPrim GetPrototype() const;
2105 
2110  if (IsInstanceProxy()) {
2111  return UsdPrim(_Prim(), SdfPath());
2112  }
2113  return UsdPrim();
2114  }
2115 
2121  USD_API
2122  std::vector<UsdPrim> GetInstances() const;
2124 
2125  // --------------------------------------------------------------------- //
2128  // --------------------------------------------------------------------- //
2129 
2152  const PcpPrimIndex &GetPrimIndex() const { return _Prim()->GetPrimIndex(); }
2153 
2174  USD_API
2176 
2184  USD_API
2186  const UsdEditTarget &editTarget) const;
2187 
2195  USD_API
2197  const UsdEditTarget &editTarget) const;
2198 
2200 
2201 private:
2202  class _ProtoToInstancePathMap {
2203  friend class UsdPrim;
2204  public:
2205  using _Map = std::vector<std::pair<SdfPath, SdfPath>>;
2206  SdfPath MapProtoToInstance(SdfPath const &protoPath) const;
2207  private:
2208  _Map _map;
2209  };
2210 
2211  friend class UsdObject;
2212  friend class UsdPrimSiblingIterator;
2213  friend class UsdPrimSubtreeIterator;
2214  friend class UsdProperty;
2215  friend class UsdSchemaBase;
2216  friend class UsdAPISchemaBase;
2217  friend class UsdStage;
2218  friend class UsdPrimRange;
2219  friend class Usd_PrimData;
2220  friend class Usd_PrimFlagsPredicate;
2221  friend struct Usd_StageImplAccess;
2222  friend struct UsdPrim_RelTargetFinder;
2223  friend struct UsdPrim_AttrConnectionFinder;
2224 
2225  // Prim constructor.
2226  UsdPrim(const Usd_PrimDataHandle &primData,
2227  const SdfPath &proxyPrimPath)
2228  : UsdObject(primData, proxyPrimPath) { }
2229 
2230  // General constructor.
2231  UsdPrim(UsdObjType objType,
2232  const Usd_PrimDataHandle &prim,
2233  const SdfPath &proxyPrimPath,
2234  const TfToken &propName)
2235  : UsdObject(objType, prim, proxyPrimPath, propName) {}
2236 
2237  // Helper to make a sibling range.
2238  inline SiblingRange
2239  _MakeSiblingRange(const Usd_PrimFlagsPredicate &pred) const;
2240 
2241  // Helper to make a range of descendants.
2242  inline SubtreeRange
2243  _MakeDescendantsRange(const Usd_PrimFlagsPredicate &pred) const;
2244 
2245  // Helper to make a vector of properties from names.
2246  std::vector<UsdProperty>
2247  _MakeProperties(const TfTokenVector &names) const;
2248 
2249  // Helper for Get{Authored}{PropertyNames,Properties}
2250  TfTokenVector _GetPropertyNames(
2251  bool onlyAuthored,
2252  bool applyOrder=true,
2253  const PropertyPredicateFunc &predicate={}) const;
2254 
2255  // Helper for Get(Authored)PropertiesInNamespace.
2256  std::vector<UsdProperty>
2257  _GetPropertiesInNamespace(const std::string &namespaces,
2258  bool onlyAuthored) const;
2259 
2260  // Helper for Get(Authored)Attributes.
2261  std::vector<UsdAttribute>
2262  _GetAttributes(bool onlyAuthored, bool applyOrder=false) const;
2263 
2264  // Helper for Get(Authored)Relationships.
2265  std::vector<UsdRelationship>
2266  _GetRelationships(bool onlyAuthored, bool applyOrder=false) const;
2267 
2268  friend const PcpPrimIndex &Usd_PrimGetSourcePrimIndex(const UsdPrim&);
2269  // Return a const reference to the source PcpPrimIndex for this prim.
2270  //
2271  // For all prims in prototypes (which includes the prototype prim itself),
2272  // this is the prim index for the instance that was chosen to serve
2273  // as the prototype for all other instances. This prim index will not
2274  // have the same path as the prim's path.
2275  //
2276  // This is a private helper but is also wrapped out to Python
2277  // for testing and debugging purposes.
2278  const PcpPrimIndex &_GetSourcePrimIndex() const
2279  { return _Prim()->GetSourcePrimIndex(); }
2280 
2281  // Helper function for MakeResolveTargetUpToEditTarget and
2282  // MakeResolveTargetStrongerThanEditTarget.
2284  _MakeResolveTargetFromEditTarget(
2285  const UsdEditTarget &editTarget,
2286  bool makeAsStrongerThan) const;
2287 
2288  _ProtoToInstancePathMap _GetProtoToInstancePathMap() const;
2289 };
2290 
2295  using _UnderlyingIterator = const Usd_PrimData*;
2296  class _PtrProxy {
2297  public:
2298  UsdPrim* operator->() { return &_prim; }
2299  private:
2300  friend class UsdPrimSiblingIterator;
2301  explicit _PtrProxy(const UsdPrim& prim) : _prim(prim) {}
2302  UsdPrim _prim;
2303  };
2304 public:
2305  using iterator_category = std::forward_iterator_tag;
2306  using value_type = UsdPrim;
2307  using reference = UsdPrim;
2308  using pointer = _PtrProxy;
2309  using difference_type = std::ptrdiff_t;
2310 
2311  // Default ctor.
2312  UsdPrimSiblingIterator() = default;
2313 
2315  reference operator*() const { return dereference(); }
2316 
2318  pointer operator->() const { return pointer(dereference()); }
2319 
2322  increment();
2323  return *this;
2324  }
2325 
2328  UsdPrimSiblingIterator result = *this;
2329  increment();
2330  return result;
2331  }
2332 
2333  bool operator==(const UsdPrimSiblingIterator& other) const {
2334  return equal(other);
2335  }
2336 
2337  bool operator!=(const UsdPrimSiblingIterator& other) const {
2338  return !equal(other);
2339  }
2340 
2341 private:
2342  friend class UsdPrim;
2343 
2344  // Constructor used by Prim.
2345  UsdPrimSiblingIterator(const _UnderlyingIterator &i,
2346  const SdfPath& proxyPrimPath,
2347  const Usd_PrimFlagsPredicate &predicate)
2348  : _underlyingIterator(i)
2349  , _proxyPrimPath(proxyPrimPath)
2350  , _predicate(predicate) {
2351  // Need to advance iterator to first matching element.
2352  if (_underlyingIterator &&
2353  !Usd_EvalPredicate(_predicate, _underlyingIterator,
2354  _proxyPrimPath))
2355  increment();
2356  }
2357 
2358  bool equal(const UsdPrimSiblingIterator &other) const {
2359  return _underlyingIterator == other._underlyingIterator &&
2360  _proxyPrimPath == other._proxyPrimPath &&
2361  _predicate == other._predicate;
2362  }
2363 
2364  void increment() {
2365  if (Usd_MoveToNextSiblingOrParent(_underlyingIterator, _proxyPrimPath,
2366  _predicate)) {
2367  _underlyingIterator = nullptr;
2368  _proxyPrimPath = SdfPath();
2369  }
2370  }
2371 
2372  reference dereference() const {
2373  return UsdPrim(_underlyingIterator, _proxyPrimPath);
2374  }
2375 
2376  _UnderlyingIterator _underlyingIterator = nullptr;
2377  SdfPath _proxyPrimPath;
2378  Usd_PrimFlagsPredicate _predicate;
2379 };
2380 
2386 public:
2392  typedef std::ptrdiff_t difference_type;
2397 
2398  UsdPrimSiblingRange() = default;
2399 
2402  UsdPrimSiblingIterator end) : _begin(begin),
2403  _end(end) {}
2404 
2406  iterator begin() const { return _begin; }
2407 
2409  const_iterator cbegin() const { return _begin; }
2410 
2412  iterator end() const { return _end; }
2413 
2415  const_iterator cend() const { return _end; }
2416 
2418  explicit operator bool() const { return !empty(); }
2419 
2421  bool equal(const UsdPrimSiblingRange& other) const {
2422  return _begin == other._begin && _end == other._end;
2423  }
2424 
2426  reference front() const {
2427  TF_DEV_AXIOM(!empty());
2428  return *begin();
2429  }
2430 
2433  std::advance(_begin, n);
2434  return *this;
2435  }
2436 
2439  std::advance(_end, n);
2440  return *this;
2441  }
2442 
2444  bool empty() const { return begin() == end(); }
2445 
2446 private:
2448  friend bool operator==(const UsdPrimSiblingRange &lhs,
2449  const UsdPrimSiblingRange &rhs) {
2450  return lhs.equal(rhs);
2451  }
2452 
2454  template <class ForwardRange>
2455  friend bool operator==(const UsdPrimSiblingRange& lhs,
2456  const ForwardRange& rhs) {
2457  static_assert(
2458  std::is_same<typename decltype(std::cbegin(rhs))::iterator_category,
2459  std::forward_iterator_tag>::value,
2460  "rhs must be a forward iterator."
2461  );
2462  return (std::distance(std::cbegin(lhs), std::cend(lhs)) ==
2463  std::distance(std::cbegin(rhs), std::cend(rhs))) &&
2464  std::equal(std::cbegin(lhs), std::cend(lhs), std::cbegin(rhs));
2465  }
2466 
2468  template <class ForwardRange>
2469  friend bool operator==(const ForwardRange& lhs,
2470  const UsdPrimSiblingRange& rhs) {
2471  return rhs == lhs;
2472  }
2473 
2475  friend bool operator!=(const UsdPrimSiblingRange &lhs,
2476  const UsdPrimSiblingRange &rhs) {
2477  return !lhs.equal(rhs);
2478  }
2479 
2481  template <class ForwardRange>
2482  friend bool operator!=(const ForwardRange& lhs,
2483  const UsdPrimSiblingRange& rhs) {
2484  return !(lhs == rhs);
2485  }
2486 
2488  template <class ForwardRange>
2489  friend bool operator!=(const UsdPrimSiblingRange& lhs,
2490  const ForwardRange& rhs) {
2491  return !(lhs == rhs);
2492  }
2493 
2494  iterator _begin;
2495  iterator _end;
2496 };
2497 
2498 // Inform TfIterator it should feel free to make copies of the range type.
2499 template <>
2500 struct Tf_ShouldIterateOverCopy<
2501  UsdPrimSiblingRange> : std::true_type {};
2502 template <>
2503 struct Tf_ShouldIterateOverCopy<
2504  const UsdPrimSiblingRange> : std::true_type {};
2505 
2507 UsdPrim::GetFilteredChildren(const Usd_PrimFlagsPredicate &pred) const
2508 {
2509  return _MakeSiblingRange(
2510  Usd_CreatePredicateForTraversal(_Prim(), _ProxyPrimPath(), pred));
2511 }
2512 
2515 {
2517 }
2518 
2521 {
2523 }
2524 
2525 // Helper to make a sibling range.
2527 UsdPrim::_MakeSiblingRange(const Usd_PrimFlagsPredicate &pred) const {
2528  Usd_PrimDataConstPtr firstChild = get_pointer(_Prim());
2529  SdfPath firstChildPath = _ProxyPrimPath();
2530  if (!Usd_MoveToChild(firstChild, firstChildPath, pred)) {
2531  firstChild = nullptr;
2532  firstChildPath = SdfPath();
2533  }
2534 
2535  return SiblingRange(
2536  SiblingIterator(firstChild, firstChildPath, pred),
2537  SiblingIterator(nullptr, SdfPath(), pred));
2538 }
2539 
2544  using _UnderlyingIterator = Usd_PrimDataConstPtr;
2545  class _PtrProxy {
2546  public:
2547  UsdPrim* operator->() { return &_prim; }
2548  private:
2549  friend class UsdPrimSubtreeIterator;
2550  explicit _PtrProxy(const UsdPrim& prim) : _prim(prim) {}
2551  UsdPrim _prim;
2552  };
2553 public:
2554  using iterator_category = std::forward_iterator_tag;
2555  using value_type = UsdPrim;
2556  using reference = UsdPrim;
2557  using pointer = _PtrProxy;
2558  using difference_type = std::ptrdiff_t;
2559 
2560  // Default ctor.
2561  UsdPrimSubtreeIterator() = default;
2562 
2564  reference operator*() const { return dereference(); }
2566  pointer operator->() const { return pointer(dereference()); }
2567 
2570  increment();
2571  return *this;
2572  }
2573 
2576  UsdPrimSubtreeIterator result;
2577  increment();
2578  return result;
2579  }
2580 
2582  bool operator==(const UsdPrimSubtreeIterator &other) const {
2583  return equal(other);
2584  }
2585 
2587  bool operator!=(const UsdPrimSubtreeIterator &other) const {
2588  return !equal(other);
2589  }
2590 
2591 
2592 private:
2593  friend class UsdPrim;
2594 
2595  // Constructor used by Prim.
2596  UsdPrimSubtreeIterator(const _UnderlyingIterator &i,
2597  const SdfPath &proxyPrimPath,
2598  const Usd_PrimFlagsPredicate &predicate)
2599  : _underlyingIterator(i)
2600  , _proxyPrimPath(proxyPrimPath)
2601  , _predicate(predicate) {
2602  // Need to advance iterator to first matching element.
2603  if (_underlyingIterator &&
2604  !Usd_EvalPredicate(_predicate, _underlyingIterator,
2605  _proxyPrimPath)) {
2606  if (Usd_MoveToNextSiblingOrParent(_underlyingIterator,
2607  _proxyPrimPath, _predicate)) {
2608  _underlyingIterator = nullptr;
2609  _proxyPrimPath = SdfPath();
2610  }
2611  }
2612  }
2613 
2614  bool equal(const UsdPrimSubtreeIterator &other) const {
2615  return _underlyingIterator == other._underlyingIterator &&
2616  _proxyPrimPath == other._proxyPrimPath &&
2617  _predicate == other._predicate;
2618  }
2619 
2620  void increment() {
2621  if (!Usd_MoveToChild(_underlyingIterator, _proxyPrimPath,
2622  _predicate)) {
2623  while (Usd_MoveToNextSiblingOrParent(_underlyingIterator,
2624  _proxyPrimPath,
2625  _predicate)) {}
2626  }
2627  }
2628 
2629  reference dereference() const {
2630  return UsdPrim(_underlyingIterator, _proxyPrimPath);
2631  }
2632 
2633  _UnderlyingIterator _underlyingIterator = nullptr;
2634  SdfPath _proxyPrimPath;
2635  Usd_PrimFlagsPredicate _predicate;
2636 };
2637 
2643 public:
2649  typedef std::ptrdiff_t difference_type;
2654 
2655  UsdPrimSubtreeRange() = default;
2656 
2659  UsdPrimSubtreeIterator end) : _begin(begin),
2660  _end(end) {}
2661 
2663  iterator begin() const { return _begin; }
2664 
2666  const_iterator cbegin() const { return _begin; }
2667 
2669  iterator end() const { return _end; }
2670 
2672  const_iterator cend() const { return _end; }
2673 
2675  explicit operator bool() const {
2676  return !empty();
2677  }
2678 
2680  bool equal(const UsdPrimSubtreeRange& other) const {
2681  return _begin == other._begin && _end == other._end;
2682  }
2683 
2685  reference front() const {
2686  TF_DEV_AXIOM(!empty());
2687  return *begin();
2688  }
2689 
2692  std::advance(_begin, n);
2693  return *this;
2694  }
2695 
2698  std::advance(_end, n);
2699  return *this;
2700  }
2701 
2703  bool empty() const { return begin() == end(); }
2704 
2705 private:
2707  friend bool operator==(const UsdPrimSubtreeRange &lhs,
2708  const UsdPrimSubtreeRange &rhs) {
2709  return lhs.equal(rhs);
2710  }
2711 
2713  template <class ForwardRange>
2714  friend bool operator==(const UsdPrimSubtreeRange& lhs,
2715  const ForwardRange& rhs) {
2716  static_assert(
2717  std::is_convertible<
2718  typename decltype(std::cbegin(rhs))::iterator_category,
2719  std::forward_iterator_tag>::value,
2720  "rhs must be a forward iterator."
2721  );
2722  return (std::distance(std::cbegin(lhs), std::cend(lhs)) ==
2723  std::distance(std::cbegin(rhs), std::cend(rhs))) &&
2724  std::equal(std::cbegin(lhs), std::cend(lhs), std::cbegin(rhs));
2725  }
2726 
2728  template <class ForwardRange>
2729  friend bool operator==(const ForwardRange& lhs,
2730  const UsdPrimSubtreeRange& rhs) {
2731  return rhs == lhs;
2732  }
2733 
2735  friend bool operator!=(const UsdPrimSubtreeRange &lhs,
2736  const UsdPrimSubtreeRange &rhs) {
2737  return !lhs.equal(rhs);
2738  }
2739 
2741  template <class ForwardRange>
2742  friend bool operator!=(const ForwardRange& lhs,
2743  const UsdPrimSubtreeRange& rhs) {
2744  return !(lhs == rhs);
2745  }
2746 
2748  template <class ForwardRange>
2749  friend bool operator!=(const UsdPrimSubtreeRange& lhs,
2750  const ForwardRange& rhs) {
2751  return !(lhs == rhs);
2752  }
2753 
2754  iterator _begin;
2755  iterator _end;
2756 };
2757 
2758 // Inform TfIterator it should feel free to make copies of the range type.
2759 template <>
2760 struct Tf_ShouldIterateOverCopy<
2761  UsdPrimSubtreeRange> : std::true_type {};
2762 template <>
2763 struct Tf_ShouldIterateOverCopy<
2764  const UsdPrimSubtreeRange> : std::true_type {};
2765 
2767 UsdPrim::GetFilteredDescendants(const Usd_PrimFlagsPredicate &pred) const
2768 {
2769  return _MakeDescendantsRange(
2770  Usd_CreatePredicateForTraversal(_Prim(), _ProxyPrimPath(), pred));
2771 }
2772 
2775 {
2777 }
2778 
2781 {
2783 }
2784 
2785 // Helper to make a sibling range.
2787 UsdPrim::_MakeDescendantsRange(const Usd_PrimFlagsPredicate &pred) const {
2788  Usd_PrimDataConstPtr firstChild = get_pointer(_Prim());
2789  SdfPath firstChildPath = _ProxyPrimPath();
2790  Usd_PrimDataConstPtr endChild = firstChild;
2791  SdfPath endChildPath = firstChildPath;
2792  if (Usd_MoveToChild(firstChild, firstChildPath, pred)) {
2793  while (Usd_MoveToNextSiblingOrParent(endChild, endChildPath, pred)) {}
2794  }
2795 
2796  return SubtreeRange(
2797  SubtreeIterator(firstChild, firstChildPath, pred),
2798  SubtreeIterator(endChild, endChildPath, pred));
2799 }
2800 
2801 
2803 // UsdObject methods that require UsdPrim be a complete type.
2804 
2805 inline UsdPrim
2807 {
2808  return UsdPrim(_prim, _proxyPrimPath);
2809 }
2810 
2811 PXR_NAMESPACE_CLOSE_SCOPE
2812 
2813 #endif // PXR_USD_USD_PRIM_H
2814 
const UsdPrimTypeInfo & GetPrimTypeInfo() const
Return the prim's full type info composed from its type name, applied API schemas,...
Definition: prim.h:140
#define TF_DEV_AXIOM(cond)
The same as TF_AXIOM, but compiled only in dev builds.
Definition: diagnostic.h:206
void ClearPropertyOrder() const
Remove the opinion for propertyOrder metadata on this prim at the current EditTarget.
Definition: prim.h:472
pointer operator->() const
Indirection.
Definition: prim.h:2566
A proxy class for applying listOp edits to the specializes list for a prim.
Definition: specializes.h:34
iterator::value_type value_type
Iterator value_type.
Definition: prim.h:2651
USD_API std::vector< UsdRelationship > GetAuthoredRelationships() const
Like GetRelationships(), but exclude relationships without authored scene description from the result...
bool HasAPIInFamily(UsdSchemaRegistry::VersionPolicy versionPolicy, const TfToken &instanceName) const
Overload for convenience of HasAPIInFamily that finds a registered schema for the C++ schema class Sc...
Definition: prim.h:891
bool equal(const UsdPrimSiblingRange &other) const
Equality compare.
Definition: prim.h:2421
USD_API bool HasAttribute(const TfToken &attrName) const
Return true if this prim has an attribute named attrName, false otherwise.
bool SetSpecifier(SdfSpecifier specifier) const
Author an opinion for this Prim's specifier at the current edit target.
Definition: prim.h:188
UsdPrimSubtreeRange & advance_end(difference_type n)
Advance this range's end iterator.
Definition: prim.h:2697
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().
Definition: prim.h:2444
PcpPrimIndex is an index of the all sites of scene description that contribute opinions to a specific...
Definition: primIndex.h:61
bool CanApplyAPI(std::string *whyNot=nullptr) const
Returns whether a single-apply API schema with the given C++ type SchemaType can be applied to this p...
Definition: prim.h:1012
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.
iterator end() const
Past-the-end iterator.
Definition: prim.h:2669
std::ptrdiff_t difference_type
Iterator difference type.
Definition: prim.h:2392
friend bool operator==(const UsdPrimSiblingRange &lhs, const ForwardRange &rhs)
Equality comparison.
Definition: prim.h:2455
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:2767
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 this...
Definition: prim.h:1046
bool IsGroup() const
Return true if this prim is a model group based on its kind metadata, false otherwise.
Definition: prim.h:263
SdfSpecifier GetSpecifier() const
Return this prim's composed specifier.
Definition: prim.h:152
UsdPrimSiblingIterator iterator
Iterator type.
Definition: prim.h:2388
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:1531
friend bool operator!=(const UsdPrimSiblingRange &lhs, const UsdPrimSiblingRange &rhs)
Inequality comparison.
Definition: prim.h:2475
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...
std::ptrdiff_t difference_type
Iterator difference type.
Definition: prim.h:2649
bool IsActive() const
Return true if this prim is active, meaning neither it nor any of its ancestors have active=false.
Definition: prim.h:221
bool ClearInstanceable() const
Remove the authored 'instanceable' opinion at the current EditTarget.
Definition: prim.h:2045
const_iterator cbegin() const
First iterator.
Definition: prim.h:2409
UsdPrimSubtreeRange & advance_begin(difference_type n)
Advance this range's begin iterator.
Definition: prim.h:2691
bool HasAuthoredInstanceable() const
Return true if this prim has an authored opinion for 'instanceable', false otherwise.
Definition: prim.h:2051
USD_API UsdReferences GetReferences() const
Return a UsdReferences object that allows one to add, remove, or mutate references at the currently s...
const_iterator cbegin() const
First iterator.
Definition: prim.h:2666
#define TF_CODING_ERROR(fmt, args)
Issue an internal programming error, but continue execution.
Definition: diagnostic.h:69
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().
Definition: prim.h:2703
friend bool operator==(const UsdPrimSubtreeRange &lhs, const ForwardRange &rhs)
Equality comparison.
Definition: prim.h:2714
SubtreeRange GetDescendants() const
Return this prim's active, loaded, defined, non-abstract descendants as an iterable range.
Definition: prim.h:2780
The outermost container for scene description, which owns and presents composed prims as a scenegraph...
Definition: stage.h:135
friend bool operator==(const UsdPrimSiblingRange &lhs, const UsdPrimSiblingRange &rhs)
Equality comparison.
Definition: prim.h:2448
Represents a value type name, i.e.
Definition: valueTypeName.h:71
UsdObjType
Enum values to represent the various Usd object types.
Definition: object.h:35
Load a prim plus all its descendants.
Definition: common.h:101
bool IsInstanceable() const
Return true if this prim has been marked as instanceable.
Definition: prim.h:2031
A proxy class for applying listOp edits to the inherit paths list for a prim.
Definition: inherits.h:34
friend bool operator!=(const UsdPrimSubtreeRange &lhs, const UsdPrimSubtreeRange &rhs)
Inequality comparison.
Definition: prim.h:2735
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++()
Preincrement.
Definition: prim.h:2321
bool HasAPIInFamily(UsdSchemaRegistry::VersionPolicy versionPolicy) const
Overload for convenience of HasAPIInFamily that finds a registered schema for the C++ schema class Sc...
Definition: prim.h:869
bool operator==(const UsdPrimSubtreeIterator &other) const
Equality.
Definition: prim.h:2582
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.
Definition: apiSchemaBase.h:94
USD_API bool GetKind(TfToken *kind) const
Retrieve the authored kind for this prim.
USD_API UsdVariantSet GetVariantSet(const std::string &variantSetName) const
Retrieve a specifically named VariantSet for editing or constructing a UsdEditTarget.
bool IsInFamily(UsdSchemaRegistry::VersionPolicy versionPolicy) const
Overload for convenience of IsInFamily that finds a registered schema for the C++ schema class Schema...
Definition: prim.h:639
Scenegraph object for authoring and retrieving numeric, string, and array valued data,...
Definition: attribute.h:183
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:2060
USD_API bool GetVersionIfHasAPIInFamily(const TfToken &schemaFamily, UsdSchemaVersion *schemaVersion) const
Return true if the prim has an applied API schema that is any version the schemas in the given schema...
USD_API void Load(UsdLoadPolicy policy=UsdLoadWithDescendants) const
Load this prim, all its ancestors, and by default all its descendants.
const_iterator cend() const
Past-the-end iterator.
Definition: prim.h:2672
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:2096
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:2385
UsdPrimSiblingIterator operator++(int)
Postincrement.
Definition: prim.h:2327
UsdReferences provides an interface to authoring and introspecting references in Usd.
Definition: references.h:197
bool IsComponent() const
Return true if this prim is a component model based on its kind metadata, false otherwise.
Definition: prim.h:268
USD_API UsdAttribute GetAttribute(const TfToken &attrName) const
Return a UsdAttribute with the name attrName.
UsdSchemaVersion version
The version number of the schema within its schema family.
USD_API bool HasAuthoredReferences() const
Return true if this prim has any authored references.
UsdPrimSubtreeIterator iterator
Iterator type.
Definition: prim.h:2645
iterator::value_type value_type
Iterator value_type.
Definition: prim.h:2394
USD_API bool HasRelationship(const TfToken &relName) const
Return true if this prim has a relationship named relName, false otherwise.
friend bool operator!=(const UsdPrimSubtreeRange &lhs, const ForwardRange &rhs)
Inequality comparison.
Definition: prim.h:2749
Single Apply API schema.
reference front() const
Return *begin(). This range must not be empty.
Definition: prim.h:2426
bool HasAPI(const TfToken &instanceName) const
Return true if the UsdPrim has the specific instance, instanceName, of the multiple-apply API schema ...
Definition: prim.h:763
void SetPropertyOrder(const TfTokenVector &order) const
Author an opinion for propertyOrder metadata on this prim at the current EditTarget.
Definition: prim.h:458
friend bool operator!=(const ForwardRange &lhs, const UsdPrimSiblingRange &rhs)
Inequality comparison.
Definition: prim.h:2482
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:80
bool SetInstanceable(bool instanceable) const
Author 'instanceable' metadata for this prim at the current EditTarget.
Definition: prim.h:2039
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 ed...
Definition: prim.h:1255
reference operator *() const
Dereference.
Definition: prim.h:2564
friend bool operator!=(const UsdPrimSiblingRange &lhs, const ForwardRange &rhs)
Inequality comparison.
Definition: prim.h:2489
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.
Definition: prim.h:2663
USD_API SdfPathVector FindAllRelationshipTargetPaths(Usd_PrimFlagsPredicate const &traversalPredicate, std::function< bool(UsdRelationship const &)> const &pred=nullptr, bool recurseOnTargets=false) const
Search the prim subtree rooted at this prim according to traversalPredicate for relationships for whi...
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:147
TfToken family
The name of the family of schema's which the schema is a version of.
UsdPrimSiblingRange(UsdPrimSiblingIterator begin, UsdPrimSiblingIterator end)
Construct with a pair of iterators.
Definition: prim.h:2401
USD_API bool IsSubComponent() const
Return true if this prim is a subcomponent based on its kind metadata, false otherwise.
Definition: prim.h:277
const PcpPrimIndex & GetPrimIndex() const
Return the cached prim index containing all sites that can contribute opinions to this prim.
Definition: prim.h:2152
UsdPrimSubtreeIterator & operator++()
Preincrement.
Definition: prim.h:2569
bool IsAbstract() const
Return true if this prim or any of its ancestors is a class.
Definition: prim.h:280
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 bool SetMetadata(const TfToken &key, VtValueRef value) const
Set metadatum key's value to value.
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:39
bool ApplyAPI() const
Applies a single-apply API schema with the given C++ type SchemaType to this prim in the current edit...
Definition: prim.h:1135
Forward iterator range of sibling UsdPrim s.
Definition: prim.h:2642
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:1548
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:2507
SiblingRange GetChildren() const
Return this prim's active, loaded, defined, non-abstract children as an iterable range.
Definition: prim.h:2520
USD_API bool IsInFamily(const TfToken &schemaFamily) const
Return true if the prim's schema type is or inherits from the schema type of any version of the schem...
Base class for Usd scenegraph objects, providing common API.
Definition: object.h:116
Defines a mapping from scene graph paths to Sdf spec paths in a SdfLayer where edits should be direct...
Definition: editTarget.h:63
Represents a payload and all its meta data.
Definition: payload.h:41
bool HasClassSpecifier() const
Return true if this prim has the specifier SdfSpecifierClass.
Definition: prim.h:287
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:116
bool IsA() const
Return true if the prim's schema type, is or inherits from the TfType of the schema class type Schema...
Definition: prim.h:593
SdfSpecifier
An enum that identifies the possible specifiers for an SdfPrimSpec.
Definition: types.h:105
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:489
friend bool operator==(const ForwardRange &lhs, const UsdPrimSubtreeRange &rhs)
Equality comparison.
Definition: prim.h:2729
friend bool operator==(const UsdPrimSubtreeRange &lhs, const UsdPrimSubtreeRange &rhs)
Equality comparison.
Definition: prim.h:2707
bool IsInstanceProxy() const
Return true if this prim is an instance proxy, false otherwise.
Definition: prim.h:2065
const TfToken & GetTypeName() const
Return this prim's composed type name.
Definition: prim.h:199
SubtreeRange GetAllDescendants() const
Return all this prim's descendants as an iterable range.
Definition: prim.h:2774
friend bool operator==(const ForwardRange &lhs, const UsdPrimSiblingRange &rhs)
Equality comparison.
Definition: prim.h:2469
bool operator!=(const UsdPrimSubtreeIterator &other) const
Inequality.
Definition: prim.h:2587
USD_API bool HasVariantSets() const
Return true if this prim has any authored VariantSets.
bool HasAPI() const
Return true if the UsdPrim has had an applied API schema represented by the C++ class type SchemaType...
Definition: prim.h:743
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:280
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 ...
bool equal(const UsdPrimSubtreeRange &other) const
Equality compare.
Definition: prim.h:2680
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:743
USD_API const TfTokenVector & GetAppliedSchemas() const
Return a vector containing the names of API schemas which have been applied to this prim.
VersionPolicy
A policy for filtering by schema version when querying for schemas in a particular schema family.
iterator::reference reference
Iterator reference_type.
Definition: prim.h:2653
USD_API bool HasPayload() const
UsdPrimSiblingRange & advance_end(difference_type n)
Advance this range's end iterator.
Definition: prim.h:2438
static USD_API void ApplyPropertyOrder(const TfTokenVector &order, TfTokenVector *names)
Change the order of items in 'names' so that all the things in 'order' that are also in 'names' are a...
const_iterator cend() const
Past-the-end iterator.
Definition: prim.h:2415
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:26
bool HasAuthoredActive() const
Return true if this prim has an authored opinion for 'active', false otherwise.
Definition: prim.h:244
A UsdRelationship creates dependencies between scenegraph objects by allowing a prim to target other ...
Definition: relationship.h:111
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 UsdRelationship GetRelationshipAtPath(const SdfPath &path) const
Returns the relationship at path on the same stage as this prim.
USD_API void Unload() const
Unloads this prim and all its descendants.
SdfVariability
An enum that identifies variability types for attributes.
Definition: types.h:161
bool ClearTypeName() const
Clear the opinion for this Prim's typeName at the current edit target.
Definition: prim.h:208
Class that holds the full type information for a prim.
Definition: primTypeInfo.h:30
UsdPrimSubtreeIterator operator++(int)
Postincrement.
Definition: prim.h:2575
SiblingRange GetAllChildren() const
Return all this prim's children as an iterable range.
Definition: prim.h:2514
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:1297
USD_API std::vector< UsdPrim > GetInstances() const
If this prim is a prototype prim, returns all prims that are instances of this prototype.
UsdLoadPolicy
Controls UsdStage::Load() and UsdPrim::Load() behavior regarding whether or not descendant prims are ...
Definition: common.h:99
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:2109
Base class for UsdAttribute and UsdRelationship scenegraph objects.
Definition: property.h:38
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:236
bool SetTypeName(const TfToken &typeName) const
Author this Prim's typeName at the current EditTarget.
Definition: prim.h:202
An forward-iterable range that traverses a subtree of prims rooted at a given prim in depth-first ord...
Definition: primRange.h:101
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:202
bool HasAuthoredTypeName() const
Return true if a typeName has been authored.
Definition: prim.h:213
void ClearChildrenReorder() const
Remove the opinion for the metadata used to reorder children of this prim at the current EditTarget.
Definition: prim.h:1537
bool IsModel() const
Return true if this prim is a model based on its kind metadata, false otherwise.
Definition: prim.h:255
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:251
Class representing the builtin definition of a prim given the schemas registered in the schema regist...
reference operator *() const
Dereference.
Definition: prim.h:2315
bool IsPrototype() const
Return true if this prim is an instancing prototype prim, false otherwise.
Definition: prim.h:2090
UsdPrimSiblingRange & advance_begin(difference_type n)
Advance this range's begin iterator.
Definition: prim.h:2432
Forward traversal iterator of sibling UsdPrim s.
Definition: prim.h:2543
unspecified UsdPrimAllPrimsPredicate
Predicate that includes all prims.
USD_API SdfPathVector FindAllAttributeConnectionPaths(Usd_PrimFlagsPredicate const &traversalPredicate, std::function< bool(UsdAttribute const &)> const &pred=nullptr, bool recurseOnSources=false) const
Search the prim subtree rooted at this prim according to traversalPredicate for attributes for which ...
iterator begin() const
First iterator.
Definition: prim.h:2406
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:128
std::function< bool(const TfToken &propertyName)> PropertyPredicateFunc
Alias for the "predicate" function parameter passed into the various Get{Authored}{PropertyNames,...
Definition: prim.h:312
reference front() const
Return *begin(). This range must not be empty.
Definition: prim.h:2685
TfType represents a dynamic runtime type.
Definition: type.h:47
UsdPrimSubtreeIterator SubtreeIterator
Convenience typedefs.
Definition: prim.h:124
bool IsDefined() const
Return true if this prim and all its ancestors have defining specifiers, false otherwise.
Definition: prim.h:284
USD_API SdfPrimSpecHandleVector GetPrimStack() const
Return all the authored SdfPrimSpecs that may contain opinions for this prim in order from strong to ...
UsdPrimSiblingIterator SiblingIterator
Convenience typedefs.
Definition: prim.h:120
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:2390
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:205
iterator end() const
Past-the-end iterator.
Definition: prim.h:2412
friend bool operator!=(const ForwardRange &lhs, const UsdPrimSubtreeRange &rhs)
Inequality comparison.
Definition: prim.h:2742
bool SetActive(bool active) const
Author 'active' metadata for this prim at the current EditTarget.
Definition: prim.h:227
UsdPrimSubtreeIterator const_iterator
Const iterator type.
Definition: prim.h:2647
The base class for all schema types in Usd.
Definition: schemaBase.h:39
USD_API UsdRelationship GetRelationship(const TfToken &relName) const
Return a UsdRelationship with the name relName.
iterator::reference reference
Iterator reference_type.
Definition: prim.h:2396
Forward traversal iterator of sibling UsdPrim s.
Definition: prim.h:2294
USD_API bool SetKind(const TfToken &kind) const
Author a kind for this prim, at the current UsdEditTarget.
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...
Structure that holds the information about a schema that is registered with the schema registry.
UsdPrim GetPrim() const
Return this object if it is a prim, otherwise return this object's nearest owning prim.
Definition: prim.h:2806
USD_API bool GetVersionIfIsInFamily(const TfToken &schemaFamily, UsdSchemaVersion *schemaVersion) const
Return true if the prim's schema type, is or inherits from the schema type of any version the schema ...
USD_API bool HasAPIInFamily(const TfToken &schemaFamily) const
Return true if the prim has an applied API schema that is any version of the schemas in the given sch...
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.
Definition: prim.h:2658
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...
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 instanceName...
Definition: prim.h:1176
USD_API std::vector< UsdAttribute > GetAuthoredAttributes() const
Like GetAttributes(), but exclude attributes without authored scene description from the result.
Defines a subrange of nodes and layers within a prim's prim index to consider when performing value r...
Definition: resolveTarget.h:56
bool HasDefiningSpecifier() const
Return true if this prim has the specifier SdfSpecifierDef or SdfSpecifierClass.
Definition: prim.h:293
pointer operator->() const
Indirection.
Definition: prim.h:2318
USD_API std::vector< UsdProperty > GetAuthoredProperties(const PropertyPredicateFunc &predicate={}) const
Return this prim's properties (attributes and relationships) that have authored scene description,...