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 #include "pxr/usd/usd/schemaRegistry.h"
35 
36 #include "pxr/usd/sdf/schema.h"
37 #include "pxr/base/trace/trace.h"
38 
40 #include "pxr/base/tf/refBase.h"
41 #include "pxr/base/tf/token.h"
42 #include "pxr/base/tf/weakBase.h"
43 
44 #include "pxr/usd/sdf/path.h"
45 
46 #include <boost/iterator/iterator_adaptor.hpp>
47 #include <boost/range/iterator_range.hpp>
48 
49 #include <string>
50 #include <type_traits>
51 #include <vector>
52 
53 PXR_NAMESPACE_OPEN_SCOPE
54 
55 class UsdPrim;
56 class UsdPrimDefinition;
57 class UsdPrimRange;
58 class Usd_PrimData;
59 
60 class UsdAttribute;
61 class UsdEditTarget;
62 class UsdRelationship;
63 class UsdPayloads;
64 class UsdReferences;
65 class UsdResolveTarget;
66 class UsdSchemaBase;
67 class UsdAPISchemaBase;
68 class UsdInherits;
69 class UsdSpecializes;
70 class UsdVariantSets;
71 class UsdVariantSet;
72 
73 class SdfPayload;
74 
76 typedef boost::iterator_range<UsdPrimSiblingIterator> UsdPrimSiblingRange;
77 
79 typedef boost::iterator_range<UsdPrimSubtreeIterator> UsdPrimSubtreeRange;
80 
135 class UsdPrim : public UsdObject
136 {
137 public:
141 
145 
147  UsdPrim() : UsdObject(_Null<UsdPrim>()) {}
148 
160  return _Prim()->GetPrimTypeInfo();
161  }
162 
167  return _Prim()->GetPrimDefinition();
168  }
169 
171  SdfSpecifier GetSpecifier() const { return _Prim()->GetSpecifier(); };
172 
186  USD_API
187  SdfPrimSpecHandleVector GetPrimStack() const;
188 
201  USD_API
202  std::vector<std::pair<SdfPrimSpecHandle, SdfLayerOffset>>
204 
207  bool SetSpecifier(SdfSpecifier specifier) const {
208  return SetMetadata(SdfFieldKeys->Specifier, specifier);
209  }
210 
218  const TfToken &GetTypeName() const { return _Prim()->GetTypeName(); };
219 
221  bool SetTypeName(const TfToken & typeName) const {
222  return SetMetadata(SdfFieldKeys->TypeName, typeName);
223  }
224 
227  bool ClearTypeName() const {
228  return ClearMetadata(SdfFieldKeys->TypeName);
229  }
230 
232  bool HasAuthoredTypeName() const {
233  return HasAuthoredMetadata(SdfFieldKeys->TypeName);
234  }
235 
240  bool IsActive() const { return _Prim()->IsActive(); }
241 
246  bool SetActive(bool active) const {
247  return SetMetadata(SdfFieldKeys->Active, active);
248  }
249 
255  bool ClearActive() const {
256  return ClearMetadata(SdfFieldKeys->Active);
257  }
258 
263  bool HasAuthoredActive() const {
264  return HasAuthoredMetadata(SdfFieldKeys->Active);
265  }
266 
270  bool IsLoaded() const { return _Prim()->IsLoaded(); }
271 
274  bool IsModel() const { return _Prim()->IsModel(); }
275 
279  bool IsGroup() const { return _Prim()->IsGroup(); }
280 
282  bool IsAbstract() const { return _Prim()->IsAbstract(); }
283 
286  bool IsDefined() const { return _Prim()->IsDefined(); }
287 
290  bool HasDefiningSpecifier() const {
291  return _Prim()->HasDefiningSpecifier();
292  }
293 
300  USD_API
302 
305  using PropertyPredicateFunc =
306  std::function<bool (const TfToken &propertyName)>;
307 
319  USD_API
321  const PropertyPredicateFunc &predicate={}) const;
322 
336  USD_API
338  const PropertyPredicateFunc &predicate={}) const;
339 
383  USD_API
384  std::vector<UsdProperty> GetProperties(
385  const PropertyPredicateFunc &predicate={}) const;
386 
400  USD_API
401  std::vector<UsdProperty> GetAuthoredProperties(
402  const PropertyPredicateFunc &predicate={}) const;
403 
415  USD_API
416  std::vector<UsdProperty>
417  GetPropertiesInNamespace(const std::vector<std::string> &namespaces) const;
418 
423  USD_API
424  std::vector<UsdProperty>
425  GetPropertiesInNamespace(const std::string &namespaces) const;
426 
432  USD_API
433  std::vector<UsdProperty>
435  const std::vector<std::string> &namespaces) const;
436 
442  USD_API
443  std::vector<UsdProperty>
444  GetAuthoredPropertiesInNamespace(const std::string &namespaces) const;
445 
447  USD_API
449 
452  void SetPropertyOrder(const TfTokenVector &order) const {
453  SetMetadata(SdfFieldKeys->PropertyOrder, order);
454  }
455 
458  void ClearPropertyOrder() const {
459  ClearMetadata(SdfFieldKeys->PropertyOrder);
460  }
461 
470  USD_API
471  bool RemoveProperty(const TfToken &propName);
472 
485  USD_API
486  UsdProperty GetProperty(const TfToken &propName) const;
487 
490  USD_API
491  bool HasProperty(const TfToken &propName) const;
492 
493 private:
494  // Helper functions for the public schema query and API schema
495  // authoring functions. The public functions have overloads that take
496  // a type, an identifier, or a family which all are used to find the
497  // SchemaInfo from the schema registry.
498  USD_API
499  bool _IsA(const UsdSchemaRegistry::SchemaInfo *schemaInfo) const;
500 
501  USD_API
502  bool _HasAPI(const UsdSchemaRegistry::SchemaInfo *schemaInfo) const;
503 
504  USD_API
505  bool _HasAPIInstance(
506  const UsdSchemaRegistry::SchemaInfo *schemaInfo,
507  const TfToken &instanceName) const;
508 
509  USD_API
510  bool _CanApplySingleApplyAPI(
511  const UsdSchemaRegistry::SchemaInfo &schemaInfo,
512  std::string *whyNot) const;
513 
514  USD_API
515  bool _CanApplyMultipleApplyAPI(
516  const UsdSchemaRegistry::SchemaInfo &schemaInfo,
517  const TfToken& instanceName,
518  std::string *whyNot) const;
519 
520  USD_API
521  bool _ApplySingleApplyAPI(
522  const UsdSchemaRegistry::SchemaInfo &schemaInfo) const;
523 
524  USD_API
525  bool _ApplyMultipleApplyAPI(
526  const UsdSchemaRegistry::SchemaInfo &schemaInfo,
527  const TfToken &instanceName) const;
528 
529  USD_API
530  bool _RemoveSingleApplyAPI(
531  const UsdSchemaRegistry::SchemaInfo &schemaInfo) const;
532 
533  USD_API
534  bool _RemoveMultipleApplyAPI(
535  const UsdSchemaRegistry::SchemaInfo &schemaInfo,
536  const TfToken &instanceName) const;
537 
538 public:
542 
549  template <typename SchemaType>
550  bool IsA() const {
551  static_assert(std::is_base_of<UsdSchemaBase, SchemaType>::value,
552  "Provided type must derive UsdSchemaBase.");
553  return _IsA(UsdSchemaRegistry::FindSchemaInfo<SchemaType>());
554  };
555 
557  USD_API
558  bool IsA(const TfType& schemaType) const;
559 
562  USD_API
563  bool IsA(const TfToken& schemaIdentifier) const;
564 
567  USD_API
568  bool IsA(const TfToken& schemaFamily,
569  UsdSchemaVersion schemaVersion) const;
570 
572 
576 
579  USD_API
580  bool IsInFamily(const TfToken &schemaFamily) const;
581 
585  USD_API
586  bool IsInFamily(
587  const TfToken &schemaFamily,
588  UsdSchemaVersion schemaVersion,
589  UsdSchemaRegistry::VersionPolicy versionPolicy) const;
590 
595  template <typename SchemaType>
597  UsdSchemaRegistry::VersionPolicy versionPolicy) const {
598  static_assert(std::is_base_of<UsdSchemaBase, SchemaType>::value,
599  "Provided type must derive UsdSchemaBase.");
600  const UsdSchemaRegistry::SchemaInfo *schemaInfo =
601  UsdSchemaRegistry::FindSchemaInfo<SchemaType>();
602  if (!schemaInfo) {
603  TF_CODING_ERROR("Class '%s' is not correctly registered with the "
604  "UsdSchemaRegistry as a schema type. The schema may need to be "
605  "regenerated.",
606  TfType::Find<SchemaType>().GetTypeName().c_str());
607  return false;
608  }
609  return IsInFamily(schemaInfo->family, schemaInfo->version,
610  versionPolicy);
611  };
612 
617  USD_API
618  bool IsInFamily(
619  const TfType &schemaType,
620  UsdSchemaRegistry::VersionPolicy versionPolicy) const;
621 
630  USD_API
631  bool IsInFamily(
632  const TfToken &schemaIdentifier,
633  UsdSchemaRegistry::VersionPolicy versionPolicy) const;
634 
639  USD_API
641  const TfToken &schemaFamily,
642  UsdSchemaVersion *schemaVersion) const;
643 
645 
691 
698  template <typename SchemaType>
699  bool
700  HasAPI() const {
701  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
702  "Provided type must derive UsdAPISchemaBase.");
703  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
704  "Provided type must not be UsdAPISchemaBase.");
705  static_assert(
706  SchemaType::schemaKind == UsdSchemaKind::SingleApplyAPI ||
707  SchemaType::schemaKind == UsdSchemaKind::MultipleApplyAPI,
708  "Provided schema type must be an applied API schema.");
709 
710  return _HasAPI(UsdSchemaRegistry::FindSchemaInfo<SchemaType>());
711  }
712 
718  template <typename SchemaType>
719  bool
720  HasAPI(const TfToken &instanceName) const {
721  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
722  "Provided type must derive UsdAPISchemaBase.");
723  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
724  "Provided type must not be UsdAPISchemaBase.");
725  static_assert(SchemaType::schemaKind == UsdSchemaKind::MultipleApplyAPI,
726  "Provided schema type must be a multi apply API schema.");
727 
728  return _HasAPIInstance(
729  UsdSchemaRegistry::FindSchemaInfo<SchemaType>(), instanceName);
730  }
731 
733  USD_API
734  bool HasAPI(const TfType& schemaType) const;
735 
738  USD_API
739  bool HasAPI(const TfType& schemaType,
740  const TfToken& instanceName) const;
741 
744  USD_API
745  bool HasAPI(const TfToken& schemaIdentifier) const;
746 
750  USD_API
751  bool HasAPI(const TfToken& schemaIdentifier,
752  const TfToken& instanceName) const;
753 
756  USD_API
757  bool HasAPI(const TfToken& schemaFamily,
758  UsdSchemaVersion schemaVersion) const;
759 
763  USD_API
764  bool HasAPI(const TfToken& schemaFamily,
765  UsdSchemaVersion schemaVersion,
766  const TfToken& instanceName) const;
767 
769 
773 
780  USD_API
781  bool HasAPIInFamily(
782  const TfToken &schemaFamily) const;
783 
789  USD_API
790  bool HasAPIInFamily(
791  const TfToken &schemaFamily,
792  const TfToken &instanceName) const;
793 
802  USD_API
803  bool HasAPIInFamily(
804  const TfToken &schemaFamily,
805  UsdSchemaVersion schemaVersion,
806  UsdSchemaRegistry::VersionPolicy versionPolicy) const;
807 
814  USD_API
815  bool HasAPIInFamily(
816  const TfToken &schemaFamily,
817  UsdSchemaVersion schemaVersion,
818  UsdSchemaRegistry::VersionPolicy versionPolicy,
819  const TfToken &instanceName) const;
820 
825  template <typename SchemaType>
827  UsdSchemaRegistry::VersionPolicy versionPolicy) const {
828  static_assert(std::is_base_of<UsdSchemaBase, SchemaType>::value,
829  "Provided type must derive UsdSchemaBase.");
830  const UsdSchemaRegistry::SchemaInfo *schemaInfo =
831  UsdSchemaRegistry::FindSchemaInfo<SchemaType>();
832  if (!schemaInfo) {
833  TF_CODING_ERROR("Class '%s' is not correctly registered with the "
834  "UsdSchemaRegistry as a schema type. The schema may need to be "
835  "regenerated.",
836  TfType::Find<SchemaType>().GetTypeName().c_str());
837  return false;
838  }
839  return HasAPIInFamily(schemaInfo->family, schemaInfo->version,
840  versionPolicy);
841  };
842 
847  template <typename SchemaType>
849  UsdSchemaRegistry::VersionPolicy versionPolicy,
850  const TfToken &instanceName) const {
851  static_assert(std::is_base_of<UsdSchemaBase, SchemaType>::value,
852  "Provided type must derive UsdSchemaBase.");
853  const UsdSchemaRegistry::SchemaInfo *schemaInfo =
854  UsdSchemaRegistry::FindSchemaInfo<SchemaType>();
855  if (!schemaInfo) {
856  TF_CODING_ERROR("Class '%s' is not correctly registered with the "
857  "UsdSchemaRegistry as a schema type. The schema may need to be "
858  "regenerated.",
859  TfType::Find<SchemaType>().GetTypeName().c_str());
860  return false;
861  }
862  return HasAPIInFamily(schemaInfo->family, schemaInfo->version,
863  versionPolicy, instanceName);
864  };
865 
870  USD_API
871  bool HasAPIInFamily(
872  const TfType &schemaType,
873  UsdSchemaRegistry::VersionPolicy versionPolicy) const;
874 
879  USD_API
880  bool HasAPIInFamily(
881  const TfType &schemaType,
882  UsdSchemaRegistry::VersionPolicy versionPolicy,
883  const TfToken &instanceName) const;
884 
893  USD_API
894  bool HasAPIInFamily(
895  const TfToken &schemaIdentifier,
896  UsdSchemaRegistry::VersionPolicy versionPolicy) const;
897 
906  USD_API
907  bool HasAPIInFamily(
908  const TfToken &schemaIdentifier,
909  UsdSchemaRegistry::VersionPolicy versionPolicy,
910  const TfToken &instanceName) const;
911 
925  USD_API
926  bool
928  const TfToken &schemaFamily,
929  UsdSchemaVersion *schemaVersion) const;
930 
943  USD_API
944  bool
946  const TfToken &schemaFamily,
947  const TfToken &instanceName,
948  UsdSchemaVersion *schemaVersion) const;
949 
951 
955 
968  template <typename SchemaType>
969  bool CanApplyAPI(std::string *whyNot = nullptr) const {
970  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
971  "Provided type must derive UsdAPISchemaBase.");
972  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
973  "Provided type must not be UsdAPISchemaBase.");
974  static_assert(SchemaType::schemaKind == UsdSchemaKind::SingleApplyAPI,
975  "Provided schema type must be a single apply API schema.");
976 
977  const UsdSchemaRegistry::SchemaInfo *schemaInfo =
978  UsdSchemaRegistry::FindSchemaInfo<SchemaType>();
979  if (!schemaInfo) {
980  TF_CODING_ERROR("Class '%s' is not correctly registered with the "
981  "UsdSchemaRegistry as a schema type. The schema may need to be "
982  "regenerated.",
983  TfType::Find<SchemaType>().GetTypeName().c_str());
984  return false;
985  }
986  return _CanApplySingleApplyAPI(*schemaInfo, whyNot);
987  }
988 
1002  template <typename SchemaType>
1003  bool CanApplyAPI(const TfToken &instanceName,
1004  std::string *whyNot = nullptr) const {
1005  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
1006  "Provided type must derive UsdAPISchemaBase.");
1007  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
1008  "Provided type must not be UsdAPISchemaBase.");
1009  static_assert(SchemaType::schemaKind == UsdSchemaKind::MultipleApplyAPI,
1010  "Provided schema type must be a multiple apply API schema.");
1011 
1012  const UsdSchemaRegistry::SchemaInfo *schemaInfo =
1013  UsdSchemaRegistry::FindSchemaInfo<SchemaType>();
1014  if (!schemaInfo) {
1015  TF_CODING_ERROR("Class '%s' is not correctly registered with the "
1016  "UsdSchemaRegistry as a schema type. The schema may need to be "
1017  "regenerated.",
1018  TfType::Find<SchemaType>().GetTypeName().c_str());
1019  return false;
1020  }
1021  return _CanApplyMultipleApplyAPI(*schemaInfo, instanceName, whyNot);
1022  }
1023 
1026  USD_API
1027  bool CanApplyAPI(const TfType& schemaType,
1028  std::string *whyNot = nullptr) const;
1029 
1033  USD_API
1034  bool CanApplyAPI(const TfType& schemaType,
1035  const TfToken& instanceName,
1036  std::string *whyNot = nullptr) const;
1037 
1040  USD_API
1041  bool CanApplyAPI(const TfToken& schemaIdentifier,
1042  std::string *whyNot = nullptr) const;
1043 
1048  USD_API
1049  bool CanApplyAPI(const TfToken& schemaIdentifier,
1050  const TfToken& instanceName,
1051  std::string *whyNot = nullptr) const;
1052 
1055  USD_API
1056  bool CanApplyAPI(const TfToken& schemaFamily,
1057  UsdSchemaVersion schemaVersion,
1058  std::string *whyNot = nullptr) const;
1059 
1064  USD_API
1065  bool CanApplyAPI(const TfToken& schemaFamily,
1066  UsdSchemaVersion schemaVersion,
1067  const TfToken& instanceName,
1068  std::string *whyNot = nullptr) const;
1069 
1071 
1075 
1091  template <typename SchemaType>
1092  bool ApplyAPI() const {
1093  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
1094  "Provided type must derive UsdAPISchemaBase.");
1095  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
1096  "Provided type must not be UsdAPISchemaBase.");
1097  static_assert(SchemaType::schemaKind == UsdSchemaKind::SingleApplyAPI,
1098  "Provided schema type must be a single apply API schema.");
1099 
1100  const UsdSchemaRegistry::SchemaInfo *schemaInfo =
1101  UsdSchemaRegistry::FindSchemaInfo<SchemaType>();
1102  if (!schemaInfo) {
1103  TF_CODING_ERROR("Class '%s' is not correctly registered with the "
1104  "UsdSchemaRegistry as a schema type. The schema may need to be "
1105  "regenerated.",
1106  TfType::Find<SchemaType>().GetTypeName().c_str());
1107  return false;
1108  }
1109  return _ApplySingleApplyAPI(*schemaInfo);
1110  }
1111 
1132  template <typename SchemaType>
1133  bool ApplyAPI(const TfToken &instanceName) const {
1134  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
1135  "Provided type must derive UsdAPISchemaBase.");
1136  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
1137  "Provided type must not be UsdAPISchemaBase.");
1138  static_assert(SchemaType::schemaKind == UsdSchemaKind::MultipleApplyAPI,
1139  "Provided schema type must be a multiple apply API schema.");
1140 
1141  const UsdSchemaRegistry::SchemaInfo *schemaInfo =
1142  UsdSchemaRegistry::FindSchemaInfo<SchemaType>();
1143  if (!schemaInfo) {
1144  TF_CODING_ERROR("Class '%s' is not correctly registered with the "
1145  "UsdSchemaRegistry as a schema type. The schema may need to be "
1146  "regenerated.",
1147  TfType::Find<SchemaType>().GetTypeName().c_str());
1148  return false;
1149  }
1150  return _ApplyMultipleApplyAPI(*schemaInfo, instanceName);
1151  }
1152 
1154  USD_API
1155  bool ApplyAPI(const TfType& schemaType) const;
1156 
1159  USD_API
1160  bool ApplyAPI(const TfType& schemaType,
1161  const TfToken& instanceName) const;
1162 
1165  USD_API
1166  bool ApplyAPI(const TfToken& schemaIdentifier) const;
1167 
1171  USD_API
1172  bool ApplyAPI(const TfToken& schemaIdentifier,
1173  const TfToken& instanceName) const;
1174 
1177  USD_API
1178  bool ApplyAPI(const TfToken& schemaFamily,
1179  UsdSchemaVersion schemaVersion) const;
1180 
1184  USD_API
1185  bool ApplyAPI(const TfToken& schemaFamily,
1186  UsdSchemaVersion schemaVersion,
1187  const TfToken& instanceName) const;
1188 
1190 
1194 
1211  template <typename SchemaType>
1212  bool RemoveAPI() const {
1213  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
1214  "Provided type must derive UsdAPISchemaBase.");
1215  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
1216  "Provided type must not be UsdAPISchemaBase.");
1217  static_assert(SchemaType::schemaKind == UsdSchemaKind::SingleApplyAPI,
1218  "Provided schema type must be a single apply API schema.");
1219 
1220  const UsdSchemaRegistry::SchemaInfo *schemaInfo =
1221  UsdSchemaRegistry::FindSchemaInfo<SchemaType>();
1222  if (!schemaInfo) {
1223  TF_CODING_ERROR("Class '%s' is not correctly registered with the "
1224  "UsdSchemaRegistry as a schema type. The schema may need to be "
1225  "regenerated.",
1226  TfType::Find<SchemaType>().GetTypeName().c_str());
1227  return false;
1228  }
1229  return _RemoveSingleApplyAPI(*schemaInfo);
1230  }
1231 
1253  template <typename SchemaType>
1254  bool RemoveAPI(const TfToken &instanceName) const {
1255  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
1256  "Provided type must derive UsdAPISchemaBase.");
1257  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
1258  "Provided type must not be UsdAPISchemaBase.");
1259  static_assert(SchemaType::schemaKind == UsdSchemaKind::MultipleApplyAPI,
1260  "Provided schema type must be a multiple apply API schema.");
1261 
1262  const UsdSchemaRegistry::SchemaInfo *schemaInfo =
1263  UsdSchemaRegistry::FindSchemaInfo<SchemaType>();
1264  if (!schemaInfo) {
1265  TF_CODING_ERROR("Class '%s' is not correctly registered with the "
1266  "UsdSchemaRegistry as a schema type. The schema may need to be "
1267  "regenerated.",
1268  TfType::Find<SchemaType>().GetTypeName().c_str());
1269  return false;
1270  }
1271  return _RemoveMultipleApplyAPI(*schemaInfo, instanceName);
1272  }
1273 
1275  USD_API
1276  bool RemoveAPI(const TfType& schemaType) const;
1277 
1280  USD_API
1281  bool RemoveAPI(const TfType& schemaType,
1282  const TfToken& instanceName) const;
1283 
1286  USD_API
1287  bool RemoveAPI(const TfToken& schemaIdentifier) const;
1288 
1292  USD_API
1293  bool RemoveAPI(const TfToken& schemaIdentifier,
1294  const TfToken& instanceName) const;
1295 
1298  USD_API
1299  bool RemoveAPI(const TfToken& schemaFamily,
1300  UsdSchemaVersion schemaVersion) const;
1301 
1305  USD_API
1306  bool RemoveAPI(const TfToken& schemaFamily,
1307  UsdSchemaVersion schemaVersion,
1308  const TfToken& instanceName) const;
1309 
1311 
1335  USD_API
1336  bool AddAppliedSchema(const TfToken &appliedSchemaName) const;
1337 
1362  USD_API
1363  bool RemoveAppliedSchema(const TfToken &appliedSchemaName) const;
1364 
1365  // --------------------------------------------------------------------- //
1367  // --------------------------------------------------------------------- //
1368 
1374  USD_API
1375  UsdPrim GetChild(const TfToken &name) const;
1376 
1385  inline SiblingRange GetChildren() const;
1386 
1388  inline SiblingRange GetAllChildren() const;
1389 
1409  inline SiblingRange
1410  GetFilteredChildren(const Usd_PrimFlagsPredicate &predicate) const;
1411 
1414  USD_API
1416 
1419  USD_API
1421 
1424  USD_API
1426  const Usd_PrimFlagsPredicate &predicate) const;
1427 
1440  inline SubtreeRange GetDescendants() const;
1441 
1450  inline SubtreeRange GetAllDescendants() const;
1451 
1475  inline SubtreeRange
1476  GetFilteredDescendants(const Usd_PrimFlagsPredicate &predicate) const;
1477 
1483  USD_API
1485 
1488  void SetChildrenReorder(const TfTokenVector &order) const {
1489  SetMetadata(SdfFieldKeys->PrimOrder, order);
1490  }
1491 
1494  void ClearChildrenReorder() const {
1495  ClearMetadata(SdfFieldKeys->PrimOrder);
1496  }
1497 
1498 public:
1499  // --------------------------------------------------------------------- //
1501  // --------------------------------------------------------------------- //
1502 
1505  UsdPrim GetParent() const {
1506  Usd_PrimDataConstPtr prim = get_pointer(_Prim());
1507  SdfPath proxyPrimPath = _ProxyPrimPath();
1508  Usd_MoveToParent(prim, proxyPrimPath);
1509  return UsdPrim(prim, proxyPrimPath);
1510  }
1511 
1520  USD_API
1521  UsdPrim GetNextSibling() const;
1522 
1528  USD_API
1530  const Usd_PrimFlagsPredicate &predicate) const;
1531 
1538  USD_API
1539  bool IsPseudoRoot() const;
1540 
1544  USD_API UsdPrim GetPrimAtPath(const SdfPath& path) const;
1545 
1549  USD_API UsdObject GetObjectAtPath(const SdfPath& path) const;
1550 
1559  USD_API UsdProperty GetPropertyAtPath(const SdfPath& path) const;
1560 
1569  USD_API UsdAttribute GetAttributeAtPath(const SdfPath& path) const;
1570 
1579  USD_API UsdRelationship GetRelationshipAtPath(const SdfPath& path) const;
1580 
1581  // --------------------------------------------------------------------- //
1583  // --------------------------------------------------------------------- //
1584 
1590  USD_API
1592 
1600  USD_API
1601  UsdVariantSet GetVariantSet(const std::string& variantSetName) const;
1602 
1608  USD_API
1609  bool HasVariantSets() const;
1610 
1611  // --------------------------------------------------------------------- //
1613  // --------------------------------------------------------------------- //
1614 
1654  USD_API
1655  UsdAttribute
1656  CreateAttribute(const TfToken& name,
1657  const SdfValueTypeName &typeName,
1658  bool custom,
1659  SdfVariability variability = SdfVariabilityVarying) const;
1662  USD_API
1663  UsdAttribute
1664  CreateAttribute(const TfToken& name,
1665  const SdfValueTypeName &typeName,
1666  SdfVariability variability = SdfVariabilityVarying) const;
1667 
1672  USD_API
1674  const std::vector<std::string> &nameElts,
1675  const SdfValueTypeName &typeName,
1676  bool custom,
1677  SdfVariability variability = SdfVariabilityVarying) const;
1681  USD_API
1683  const std::vector<std::string> &nameElts,
1684  const SdfValueTypeName &typeName,
1685  SdfVariability variability = SdfVariabilityVarying) const;
1686 
1688  USD_API
1689  std::vector<UsdAttribute> GetAttributes() const;
1690 
1693  USD_API
1694  std::vector<UsdAttribute> GetAuthoredAttributes() const;
1695 
1708  USD_API
1709  UsdAttribute GetAttribute(const TfToken& attrName) const;
1710 
1713  USD_API
1714  bool HasAttribute(const TfToken& attrName) const;
1715 
1721  USD_API
1722  SdfPathVector
1724  std::function<bool (UsdAttribute const &)> const &pred = nullptr,
1725  bool recurseOnSources = false) const;
1726 
1727  // --------------------------------------------------------------------- //
1729  // --------------------------------------------------------------------- //
1730 
1767  USD_API
1769  bool custom=true) const;
1770 
1775  USD_API
1776  UsdRelationship CreateRelationship(const std::vector<std::string> &nameElts,
1777  bool custom=true)
1778  const;
1779 
1781  USD_API
1782  std::vector<UsdRelationship> GetRelationships() const;
1783 
1786  USD_API
1787  std::vector<UsdRelationship> GetAuthoredRelationships() const;
1788 
1801  USD_API
1802  UsdRelationship GetRelationship(const TfToken& relName) const;
1803 
1806  USD_API
1807  bool HasRelationship(const TfToken& relName) const;
1808 
1815  USD_API
1816  SdfPathVector
1818  std::function<bool (UsdRelationship const &)> const &pred = nullptr,
1819  bool recurseOnTargets = false) const;
1820 
1821  // --------------------------------------------------------------------- //
1828  // --------------------------------------------------------------------- //
1829 
1833  USD_API
1834  bool ClearPayload() const;
1835 
1840  USD_API
1841  bool HasPayload() const;
1842 
1848  USD_API
1849  bool SetPayload(const SdfPayload& payload) const;
1850 
1853  USD_API
1854  bool SetPayload(
1855  const std::string& assetPath, const SdfPath& primPath) const;
1856 
1860  USD_API
1861  bool SetPayload(const SdfLayerHandle& layer, const SdfPath& primPath) const;
1862 
1864 
1865  // --------------------------------------------------------------------- //
1867  // --------------------------------------------------------------------- //
1868 
1876  USD_API
1877  UsdPayloads GetPayloads() const;
1878 
1880  USD_API
1881  bool HasAuthoredPayloads() const;
1882 
1888  USD_API
1889  void Load(UsdLoadPolicy policy = UsdLoadWithDescendants) const;
1890 
1894  USD_API
1895  void Unload() const;
1896 
1897  // --------------------------------------------------------------------- //
1899  // --------------------------------------------------------------------- //
1900 
1910  USD_API
1911  UsdReferences GetReferences() const;
1912 
1914  USD_API
1915  bool HasAuthoredReferences() const;
1916 
1917  // --------------------------------------------------------------------- //
1919  // --------------------------------------------------------------------- //
1920 
1930  USD_API
1931  UsdInherits GetInherits() const;
1932 
1934  USD_API
1935  bool HasAuthoredInherits() const;
1936 
1937  // --------------------------------------------------------------------- //
1939  // --------------------------------------------------------------------- //
1940 
1948  USD_API
1950 
1952  USD_API
1953  bool HasAuthoredSpecializes() const;
1954 
1955  // --------------------------------------------------------------------- //
1959  // --------------------------------------------------------------------- //
1960 
1967  bool IsInstanceable() const {
1968  bool instanceable = false;
1969  return GetMetadata(SdfFieldKeys->Instanceable, &instanceable) &&
1970  instanceable;
1971  }
1972 
1975  bool SetInstanceable(bool instanceable) const {
1976  return SetMetadata(SdfFieldKeys->Instanceable, instanceable);
1977  }
1978 
1981  bool ClearInstanceable() const {
1982  return ClearMetadata(SdfFieldKeys->Instanceable);
1983  }
1984 
1988  return HasAuthoredMetadata(SdfFieldKeys->Instanceable);
1989  }
1990 
1996  bool IsInstance() const { return _Prim()->IsInstance(); }
1997 
2001  bool IsInstanceProxy() const {
2002  return Usd_IsInstanceProxy(_Prim(), _ProxyPrimPath());
2003  }
2004 
2012  USD_API
2013  static bool IsPrototypePath(const SdfPath& path);
2014 
2019  USD_API
2020  static bool IsPathInPrototype(const SdfPath& path);
2021 
2026  bool IsPrototype() const { return _Prim()->IsPrototype(); }
2027 
2032  bool IsInPrototype() const {
2033  return (IsInstanceProxy() ?
2034  IsPathInPrototype(GetPrimPath()) : _Prim()->IsInPrototype());
2035  }
2036 
2039  USD_API
2040  UsdPrim GetPrototype() const;
2041 
2046  if (IsInstanceProxy()) {
2047  return UsdPrim(_Prim(), SdfPath());
2048  }
2049  return UsdPrim();
2050  }
2051 
2057  USD_API
2058  std::vector<UsdPrim> GetInstances() const;
2060 
2061  // --------------------------------------------------------------------- //
2064  // --------------------------------------------------------------------- //
2065 
2088  const PcpPrimIndex &GetPrimIndex() const { return _Prim()->GetPrimIndex(); }
2089 
2110  USD_API
2112 
2120  USD_API
2122  const UsdEditTarget &editTarget) const;
2123 
2131  USD_API
2133  const UsdEditTarget &editTarget) const;
2134 
2136 
2137 private:
2138  friend class UsdObject;
2139  friend class UsdPrimSiblingIterator;
2140  friend class UsdPrimSubtreeIterator;
2141  friend class UsdProperty;
2142  friend class UsdSchemaBase;
2143  friend class UsdAPISchemaBase;
2144  friend class UsdStage;
2145  friend class UsdPrimRange;
2146  friend class Usd_PrimData;
2147  friend class Usd_PrimFlagsPredicate;
2148  friend struct UsdPrim_RelTargetFinder;
2149  friend struct UsdPrim_AttrConnectionFinder;
2150 
2151  // Prim constructor.
2152  UsdPrim(const Usd_PrimDataHandle &primData,
2153  const SdfPath &proxyPrimPath)
2154  : UsdObject(primData, proxyPrimPath) { }
2155 
2156  // General constructor.
2157  UsdPrim(UsdObjType objType,
2158  const Usd_PrimDataHandle &prim,
2159  const SdfPath &proxyPrimPath,
2160  const TfToken &propName)
2161  : UsdObject(objType, prim, proxyPrimPath, propName) {}
2162 
2163  // Helper to make a sibling range.
2164  inline SiblingRange
2165  _MakeSiblingRange(const Usd_PrimFlagsPredicate &pred) const;
2166 
2167  // Helper to make a range of descendants.
2168  inline SubtreeRange
2169  _MakeDescendantsRange(const Usd_PrimFlagsPredicate &pred) const;
2170 
2171  // Helper to make a vector of properties from names.
2172  std::vector<UsdProperty>
2173  _MakeProperties(const TfTokenVector &names) const;
2174 
2175  // Helper for Get{Authored}{PropertyNames,Properties}
2176  TfTokenVector _GetPropertyNames(
2177  bool onlyAuthored,
2178  bool applyOrder=true,
2179  const PropertyPredicateFunc &predicate={}) const;
2180 
2181  // Helper for Get(Authored)PropertiesInNamespace.
2182  std::vector<UsdProperty>
2183  _GetPropertiesInNamespace(const std::string &namespaces,
2184  bool onlyAuthored) const;
2185 
2186  // Helper for Get(Authored)Attributes.
2187  std::vector<UsdAttribute>
2188  _GetAttributes(bool onlyAuthored, bool applyOrder=false) const;
2189 
2190  // Helper for Get(Authored)Relationships.
2191  std::vector<UsdRelationship>
2192  _GetRelationships(bool onlyAuthored, bool applyOrder=false) const;
2193 
2194  friend const PcpPrimIndex &Usd_PrimGetSourcePrimIndex(const UsdPrim&);
2195  // Return a const reference to the source PcpPrimIndex for this prim.
2196  //
2197  // For all prims in prototypes (which includes the prototype prim itself),
2198  // this is the prim index for the instance that was chosen to serve
2199  // as the prototype for all other instances. This prim index will not
2200  // have the same path as the prim's path.
2201  //
2202  // This is a private helper but is also wrapped out to Python
2203  // for testing and debugging purposes.
2204  const PcpPrimIndex &_GetSourcePrimIndex() const
2205  { return _Prim()->GetSourcePrimIndex(); }
2206 
2207  // Helper function for MakeResolveTargetUpToEditTarget and
2208  // MakeResolveTargetStrongerThanEditTarget.
2210  _MakeResolveTargetFromEditTarget(
2211  const UsdEditTarget &editTarget,
2212  bool makeAsStrongerThan) const;
2213 };
2214 
2215 #ifdef doxygen
2216 
2220 public:
2226  typedef unspecified-integral-type difference_type;
2228  reference operator*() const;
2230  unspecified-type operator->() const;
2235 private:
2237  friend bool operator==(const UsdPrimSiblingIterator &lhs,
2238  const UsdPrimSiblingIterator &rhs);
2240  friend bool operator!=(const UsdPrimSiblingIterator &lhs,
2241  const UsdPrimSiblingIterator &rhs);
2242 };
2243 
2249 public:
2255  typedef unspecified-integral-type difference_type;
2260 
2264 
2266  template <class ForwardRange>
2267  UsdPrimSiblingRange(const ForwardRange &r);
2268 
2270  template <class ForwardRange>
2271  UsdPrimSiblingRange &operator=(const ForwardRange &r);
2272 
2274  iterator begin() const;
2275 
2277  iterator end() const;
2278 
2280  operator unspecified_bool_type() const;
2281 
2283  bool equal(const iterator_range&) const;
2284 
2286  reference front() const;
2287 
2289  iterator_range& advance_begin(difference_type n);
2290 
2292  iterator_range& advance_end(difference_type n);
2293 
2294  ;
2295  bool empty() const;
2296 
2297 private:
2299  friend bool operator==(const UsdPrimSiblingRange &lhs,
2300  const UsdPrimSiblingRange &rhs);
2302  friend bool operator!=(const UsdPrimSiblingRange &lhs,
2303  const UsdPrimSiblingRange &rhs);
2304 };
2305 
2306 #else
2307 
2308 // Sibling iterator class. Converts ref to weak and filters according to a
2309 // supplied predicate.
2310 class UsdPrimSiblingIterator : public boost::iterator_adaptor<
2311  UsdPrimSiblingIterator, // crtp base.
2312  const Usd_PrimData *, // base iterator.
2313  UsdPrim, // value type.
2314  boost::forward_traversal_tag, // traversal
2315  UsdPrim> // reference type.
2316 {
2317 public:
2318  // Default ctor.
2320 
2321 private:
2322  friend class UsdPrim;
2323 
2324  // Constructor used by Prim.
2325  UsdPrimSiblingIterator(const base_type &i, const SdfPath& proxyPrimPath,
2326  const Usd_PrimFlagsPredicate &predicate)
2327  : iterator_adaptor_(i)
2328  , _proxyPrimPath(proxyPrimPath)
2329  , _predicate(predicate) {
2330  // Need to advance iterator to first matching element.
2331  if (base() && !Usd_EvalPredicate(_predicate, base(), _proxyPrimPath))
2332  increment();
2333  }
2334 
2335  // Core implementation invoked by iterator_adaptor.
2336  friend class boost::iterator_core_access;
2337  bool equal(const UsdPrimSiblingIterator &other) const {
2338  return base() == other.base() &&
2339  _proxyPrimPath == other._proxyPrimPath &&
2340  _predicate == other._predicate;
2341  }
2342 
2343  void increment() {
2344  base_type &base = base_reference();
2345  if (Usd_MoveToNextSiblingOrParent(base, _proxyPrimPath, _predicate)) {
2346  base = nullptr;
2347  _proxyPrimPath = SdfPath();
2348  }
2349  }
2350 
2351  reference dereference() const {
2352  return UsdPrim(base(), _proxyPrimPath);
2353  }
2354 
2355  SdfPath _proxyPrimPath;
2356  Usd_PrimFlagsPredicate _predicate;
2357 };
2358 
2359 // Typedef iterator range.
2360 typedef boost::iterator_range<UsdPrimSiblingIterator> UsdPrimSiblingRange;
2361 
2362 // Inform TfIterator it should feel free to make copies of the range type.
2363 template <>
2364 struct Tf_ShouldIterateOverCopy<
2365  UsdPrimSiblingRange> : boost::true_type {};
2366 template <>
2367 struct Tf_ShouldIterateOverCopy<
2368  const UsdPrimSiblingRange> : boost::true_type {};
2369 
2370 #endif // doxygen
2371 
2372 
2374 UsdPrim::GetFilteredChildren(const Usd_PrimFlagsPredicate &pred) const
2375 {
2376  return _MakeSiblingRange(
2377  Usd_CreatePredicateForTraversal(_Prim(), _ProxyPrimPath(), pred));
2378 }
2379 
2382 {
2384 }
2385 
2388 {
2390 }
2391 
2392 // Helper to make a sibling range.
2394 UsdPrim::_MakeSiblingRange(const Usd_PrimFlagsPredicate &pred) const {
2395  Usd_PrimDataConstPtr firstChild = get_pointer(_Prim());
2396  SdfPath firstChildPath = _ProxyPrimPath();
2397  if (!Usd_MoveToChild(firstChild, firstChildPath, pred)) {
2398  firstChild = nullptr;
2399  firstChildPath = SdfPath();
2400  }
2401 
2402  return SiblingRange(
2403  SiblingIterator(firstChild, firstChildPath, pred),
2404  SiblingIterator(nullptr, SdfPath(), pred));
2405 }
2406 
2407 #ifdef doxygen
2408 
2412 public:
2418  typedef unspecified-integral-type difference_type;
2420  reference operator*() const;
2422  unspecified-type operator->() const;
2427 private:
2429  friend bool operator==(const UsdPrimSubtreeIterator &lhs,
2430  const UsdPrimSubtreeIterator &rhs);
2432  friend bool operator!=(const UsdPrimSubtreeIterator &lhs,
2433  const UsdPrimSubtreeIterator &rhs);
2434 };
2435 
2441 public:
2447  typedef unspecified-integral-type difference_type;
2452 
2456 
2458  template <class ForwardRange>
2459  UsdPrimSubtreeRange(const ForwardRange &r);
2460 
2462  template <class ForwardRange>
2463  UsdPrimSubtreeRange &operator=(const ForwardRange &r);
2464 
2466  iterator begin() const;
2467 
2469  iterator end() const;
2470 
2472  operator unspecified_bool_type() const;
2473 
2475  bool equal(const iterator_range&) const;
2476 
2478  reference front() const;
2479 
2481  iterator_range& advance_begin(difference_type n);
2482 
2484  iterator_range& advance_end(difference_type n);
2485 
2487  bool empty() const;
2488 
2489 private:
2491  friend bool operator==(const UsdPrimSubtreeRange &lhs,
2492  const UsdPrimSubtreeRange &rhs);
2494  friend bool operator!=(const UsdPrimSubtreeRange &lhs,
2495  const UsdPrimSubtreeRange &rhs);
2496 };
2497 
2498 #else
2499 
2500 // Subtree iterator class. Converts ref to weak and filters according to a
2501 // supplied predicate.
2502 class UsdPrimSubtreeIterator : public boost::iterator_adaptor<
2503  UsdPrimSubtreeIterator, // crtp base.
2504  const Usd_PrimData *, // base iterator.
2505  UsdPrim, // value type.
2506  boost::forward_traversal_tag, // traversal
2507  UsdPrim> // reference type.
2508 {
2509 public:
2510  // Default ctor.
2512 
2513 private:
2514  friend class UsdPrim;
2515 
2516  // Constructor used by Prim.
2517  UsdPrimSubtreeIterator(const base_type &i, const SdfPath &proxyPrimPath,
2518  const Usd_PrimFlagsPredicate &predicate)
2519  : iterator_adaptor_(i)
2520  , _proxyPrimPath(proxyPrimPath)
2521  , _predicate(predicate) {
2522  // Need to advance iterator to first matching element.
2523  base_type &base = base_reference();
2524  if (base && !Usd_EvalPredicate(_predicate, base, _proxyPrimPath)) {
2525  if (Usd_MoveToNextSiblingOrParent(base, _proxyPrimPath,
2526  _predicate)) {
2527  base = nullptr;
2528  _proxyPrimPath = SdfPath();
2529  }
2530  }
2531  }
2532 
2533  // Core implementation invoked by iterator_adaptor.
2534  friend class boost::iterator_core_access;
2535  bool equal(const UsdPrimSubtreeIterator &other) const {
2536  return base() == other.base() &&
2537  _proxyPrimPath == other._proxyPrimPath &&
2538  _predicate == other._predicate;
2539  }
2540 
2541  void increment() {
2542  base_type &base = base_reference();
2543  if (!Usd_MoveToChild(base, _proxyPrimPath, _predicate)) {
2544  while (Usd_MoveToNextSiblingOrParent(base, _proxyPrimPath,
2545  _predicate)) {}
2546  }
2547  }
2548 
2549  reference dereference() const {
2550  return UsdPrim(base(), _proxyPrimPath);
2551  }
2552 
2553  SdfPath _proxyPrimPath;
2554  Usd_PrimFlagsPredicate _predicate;
2555 };
2556 
2557 // Typedef iterator range.
2558 typedef boost::iterator_range<UsdPrimSubtreeIterator> UsdPrimSubtreeRange;
2559 
2560 // Inform TfIterator it should feel free to make copies of the range type.
2561 template <>
2562 struct Tf_ShouldIterateOverCopy<
2563  UsdPrimSubtreeRange> : boost::true_type {};
2564 template <>
2565 struct Tf_ShouldIterateOverCopy<
2566  const UsdPrimSubtreeRange> : boost::true_type {};
2567 
2568 #endif // doxygen
2569 
2571 UsdPrim::GetFilteredDescendants(const Usd_PrimFlagsPredicate &pred) const
2572 {
2573  return _MakeDescendantsRange(
2574  Usd_CreatePredicateForTraversal(_Prim(), _ProxyPrimPath(), pred));
2575 }
2576 
2579 {
2581 }
2582 
2585 {
2587 }
2588 
2589 // Helper to make a sibling range.
2591 UsdPrim::_MakeDescendantsRange(const Usd_PrimFlagsPredicate &pred) const {
2592  Usd_PrimDataConstPtr firstChild = get_pointer(_Prim());
2593  SdfPath firstChildPath = _ProxyPrimPath();
2594  Usd_PrimDataConstPtr endChild = firstChild;
2595  SdfPath endChildPath = firstChildPath;
2596  if (Usd_MoveToChild(firstChild, firstChildPath, pred)) {
2597  while (Usd_MoveToNextSiblingOrParent(endChild, endChildPath, pred)) {}
2598  }
2599 
2600  return SubtreeRange(
2601  SubtreeIterator(firstChild, firstChildPath, pred),
2602  SubtreeIterator(endChild, endChildPath, pred));
2603 }
2604 
2605 
2607 // UsdObject methods that require UsdPrim be a complete type.
2608 
2609 inline UsdPrim
2611 {
2612  return UsdPrim(_prim, _proxyPrimPath);
2613 }
2614 
2615 PXR_NAMESPACE_CLOSE_SCOPE
2616 
2617 #endif // PXR_USD_USD_PRIM_H
2618 
const UsdPrimTypeInfo & GetPrimTypeInfo() const
Return the prim's full type info composed from its type name, applied API schemas,...
Definition: prim.h:159
void ClearPropertyOrder() const
Remove the opinion for propertyOrder metadata on this prim at the current EditTarget.
Definition: prim.h:458
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:764
iterator::value_type value_type
Iterator value_type.
Definition: prim.h:2449
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:848
unspecified integral type difference_type
Iterator difference type.
Definition: prim.h:2418
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:51
bool SetSpecifier(SdfSpecifier specifier) const
Author an opinion for this Prim's specifier at the current edit target.
Definition: prim.h:207
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
Returns whether a single-apply API schema with the given C++ type SchemaType can be applied to this p...
Definition: prim.h:969
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:2571
value_type reference
Iterator reference type, in this case the same as value_type.
Definition: prim.h:2416
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 this...
Definition: prim.h:1003
bool IsGroup() const
Return true if this prim is a model group based on its kind metadata, false otherwise.
Definition: prim.h:279
SdfSpecifier GetSpecifier() const
Return this prim's composed specifier.
Definition: prim.h:171
UsdPrimSiblingIterator iterator
Iterator type.
Definition: prim.h:2251
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:1488
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:2222
bool IsActive() const
Return true if this prim is active, meaning neither it nor any of its ancestors have active=false.
Definition: prim.h:240
bool ClearInstanceable() const
Remove the authored 'instanceable' opinion at the current EditTarget.
Definition: prim.h:1981
bool HasAuthoredInstanceable() const
Return true if this prim has an authored opinion for 'instanceable', false otherwise.
Definition: prim.h:1987
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...
#define TF_CODING_ERROR(fmt, args)
Issue an internal programming error, but continue execution.
Definition: diagnostic.h:85
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:2584
The outermost container for scene description, which owns and presents composed prims as a scenegraph...
Definition: stage.h:152
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:1967
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.
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:826
unspecified integral type difference_type
Iterator difference type.
Definition: prim.h:2255
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.
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:596
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:1996
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.
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:2032
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:2248
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.
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:2443
iterator::value_type value_type
Iterator value_type.
Definition: prim.h:2257
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.
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:720
void SetPropertyOrder(const TfTokenVector &order) const
Author an opinion for propertyOrder metadata on this prim at the current EditTarget.
Definition: prim.h:452
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:1975
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:1212
reference operator *() const
Dereference.
unspecified integral type difference_type
Iterator difference type.
Definition: prim.h:2226
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:166
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.
const PcpPrimIndex & GetPrimIndex() const
Return the cached prim index containing all sites that can contribute opinions to this prim.
Definition: prim.h:2088
UsdPrimSubtreeIterator & operator++()
Postincrement.
bool IsAbstract() const
Return true if this prim or any of its ancestors is a class.
Definition: prim.h:282
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 edit...
Definition: prim.h:1092
Forward iterator range of sibling UsdPrim s.
Definition: prim.h:2440
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:1505
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:2374
SiblingRange GetChildren() const
Return this prim's active, loaded, defined, non-abstract children as an iterable range.
Definition: prim.h:2387
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:132
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:135
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 from the TfType of the schema class type Schema...
Definition: prim.h:550
SdfSpecifier
An enum that identifies the possible specifiers for an SdfPrimSpec.
Definition: types.h:122
UsdPrim value_type
Iterator value type.
Definition: prim.h:2414
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:2001
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:218
SubtreeRange GetAllDescendants() const
Return all this prim's descendants as an iterable range.
Definition: prim.h:2578
unspecified type operator->() const
Indirection.
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:700
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:756
iterator_range & advance_begin(difference_type n)
Advance this range's begin iterator.
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:2451
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:263
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:178
bool ClearTypeName() const
Clear the opinion for this Prim's typeName at the current edit target.
Definition: prim.h:227
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:2381
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:1254
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:2045
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:255
bool SetTypeName(const TfToken &typeName) const
Author this Prim's typeName at the current EditTarget.
Definition: prim.h:221
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:218
bool HasAuthoredTypeName() const
Return true if a typeName has been authored.
Definition: prim.h:232
void ClearChildrenReorder() const
Remove the opinion for the metadata used to reorder children of this prim at the current EditTarget.
Definition: prim.h:1494
bool IsModel() const
Return true if this prim is a model based on its kind metadata, false otherwise.
Definition: prim.h:274
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:270
unspecified integral type difference_type
Iterator difference type.
Definition: prim.h:2447
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:2026
Forward traversal iterator of sibling UsdPrim s.
Definition: prim.h:2411
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:147
std::function< bool(const TfToken &propertyName)> PropertyPredicateFunc
Alias for the "predicate" function parameter passed into the various Get{Authored}{PropertyNames,...
Definition: prim.h:306
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:143
bool IsDefined() const
Return true if this prim and all its ancestors have defining specifiers, false otherwise.
Definition: prim.h:286
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:139
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:2253
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:246
UsdPrimSubtreeIterator const_iterator
Const iterator type.
Definition: prim.h:2445
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:2259
Forward traversal iterator of sibling UsdPrim s.
Definition: prim.h:2219
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.
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:2610
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.
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:2224
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:1133
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:290
USD_API std::vector< UsdProperty > GetAuthoredProperties(const PropertyPredicateFunc &predicate={}) const
Return this prim's properties (attributes and relationships) that have authored scene description,...