Loading...
Searching...
No Matches
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"
34#include "pxr/usd/usd/schemaRegistry.h"
35
36#include "pxr/usd/sdf/schema.h"
38
40#include "pxr/base/tf/refBase.h"
41#include "pxr/base/tf/token.h"
43
44#include "pxr/usd/sdf/path.h"
45
46#include <iterator>
47#include <string>
48#include <type_traits>
49#include <vector>
50
51PXR_NAMESPACE_OPEN_SCOPE
52
53class UsdPrim;
55class UsdPrimRange;
56class Usd_PrimData;
57
58class UsdAttribute;
59class UsdEditTarget;
60class UsdRelationship;
61class UsdPayloads;
62class UsdReferences;
64class UsdSchemaBase;
66class UsdInherits;
67class UsdSpecializes;
68class UsdVariantSets;
69class UsdVariantSet;
70
71class SdfPayload;
72
75
78
133class UsdPrim : public UsdObject
134{
135public:
139
143
145 UsdPrim() : UsdObject(_Null<UsdPrim>()) {}
146
158 return _Prim()->GetPrimTypeInfo();
159 }
160
165 return _Prim()->GetPrimDefinition();
166 }
167
169 SdfSpecifier GetSpecifier() const { return _Prim()->GetSpecifier(); };
170
184 USD_API
185 SdfPrimSpecHandleVector GetPrimStack() const;
186
199 USD_API
200 std::vector<std::pair<SdfPrimSpecHandle, SdfLayerOffset>>
202
205 bool SetSpecifier(SdfSpecifier specifier) const {
206 return SetMetadata(SdfFieldKeys->Specifier, specifier);
207 }
208
216 const TfToken &GetTypeName() const { return _Prim()->GetTypeName(); };
217
219 bool SetTypeName(const TfToken & typeName) const {
220 return SetMetadata(SdfFieldKeys->TypeName, typeName);
221 }
222
225 bool ClearTypeName() const {
226 return ClearMetadata(SdfFieldKeys->TypeName);
227 }
228
230 bool HasAuthoredTypeName() const {
231 return HasAuthoredMetadata(SdfFieldKeys->TypeName);
232 }
233
238 bool IsActive() const { return _Prim()->IsActive(); }
239
244 bool SetActive(bool active) const {
245 return SetMetadata(SdfFieldKeys->Active, active);
246 }
247
253 bool ClearActive() const {
254 return ClearMetadata(SdfFieldKeys->Active);
255 }
256
261 bool HasAuthoredActive() const {
262 return HasAuthoredMetadata(SdfFieldKeys->Active);
263 }
264
268 bool IsLoaded() const { return _Prim()->IsLoaded(); }
269
272 bool IsModel() const { return _Prim()->IsModel(); }
273
280 bool IsGroup() const { return _Prim()->IsGroup(); }
281
285 bool IsComponent() const { return _Prim()->IsComponent(); }
286
293 USD_API
294 bool IsSubComponent() const { return _Prim()->IsSubComponent(); }
295
297 bool IsAbstract() const { return _Prim()->IsAbstract(); }
298
301 bool IsDefined() const { return _Prim()->IsDefined(); }
302
305 bool HasDefiningSpecifier() const {
306 return _Prim()->HasDefiningSpecifier();
307 }
308
315 USD_API
317
321 std::function<bool (const TfToken &propertyName)>;
322
334 USD_API
336 const PropertyPredicateFunc &predicate={}) const;
337
351 USD_API
353 const PropertyPredicateFunc &predicate={}) const;
354
398 USD_API
399 std::vector<UsdProperty> GetProperties(
400 const PropertyPredicateFunc &predicate={}) const;
401
415 USD_API
416 std::vector<UsdProperty> GetAuthoredProperties(
417 const PropertyPredicateFunc &predicate={}) const;
418
430 USD_API
431 std::vector<UsdProperty>
432 GetPropertiesInNamespace(const std::vector<std::string> &namespaces) const;
433
438 USD_API
439 std::vector<UsdProperty>
440 GetPropertiesInNamespace(const std::string &namespaces) const;
441
447 USD_API
448 std::vector<UsdProperty>
450 const std::vector<std::string> &namespaces) const;
451
457 USD_API
458 std::vector<UsdProperty>
459 GetAuthoredPropertiesInNamespace(const std::string &namespaces) const;
460
462 USD_API
464
467 void SetPropertyOrder(const TfTokenVector &order) const {
468 SetMetadata(SdfFieldKeys->PropertyOrder, order);
469 }
470
473 void ClearPropertyOrder() const {
474 ClearMetadata(SdfFieldKeys->PropertyOrder);
475 }
476
485 USD_API
486 bool RemoveProperty(const TfToken &propName);
487
500 USD_API
501 UsdProperty GetProperty(const TfToken &propName) const;
502
505 USD_API
506 bool HasProperty(const TfToken &propName) const;
507
526 USD_API
527 bool GetKind(TfToken *kind) const;
528
531 USD_API
532 bool SetKind(const TfToken &kind) const;
533
534private:
535 // Helper functions for the public schema query and API schema
536 // authoring functions. The public functions have overloads that take
537 // a type, an identifier, or a family which all are used to find the
538 // SchemaInfo from the schema registry.
539 USD_API
540 bool _IsA(const UsdSchemaRegistry::SchemaInfo *schemaInfo) const;
541
542 USD_API
543 bool _HasAPI(const UsdSchemaRegistry::SchemaInfo *schemaInfo) const;
544
545 USD_API
546 bool _HasAPIInstance(
547 const UsdSchemaRegistry::SchemaInfo *schemaInfo,
548 const TfToken &instanceName) const;
549
550 USD_API
551 bool _CanApplySingleApplyAPI(
552 const UsdSchemaRegistry::SchemaInfo &schemaInfo,
553 std::string *whyNot) const;
554
555 USD_API
556 bool _CanApplyMultipleApplyAPI(
557 const UsdSchemaRegistry::SchemaInfo &schemaInfo,
558 const TfToken& instanceName,
559 std::string *whyNot) const;
560
561 USD_API
562 bool _ApplySingleApplyAPI(
563 const UsdSchemaRegistry::SchemaInfo &schemaInfo) const;
564
565 USD_API
566 bool _ApplyMultipleApplyAPI(
567 const UsdSchemaRegistry::SchemaInfo &schemaInfo,
568 const TfToken &instanceName) const;
569
570 USD_API
571 bool _RemoveSingleApplyAPI(
572 const UsdSchemaRegistry::SchemaInfo &schemaInfo) const;
573
574 USD_API
575 bool _RemoveMultipleApplyAPI(
576 const UsdSchemaRegistry::SchemaInfo &schemaInfo,
577 const TfToken &instanceName) const;
578
579public:
583
590 template <typename SchemaType>
591 bool IsA() const {
592 static_assert(std::is_base_of<UsdSchemaBase, SchemaType>::value,
593 "Provided type must derive UsdSchemaBase.");
594 return _IsA(UsdSchemaRegistry::FindSchemaInfo<SchemaType>());
595 };
596
598 USD_API
599 bool IsA(const TfType& schemaType) const;
600
603 USD_API
604 bool IsA(const TfToken& schemaIdentifier) const;
605
608 USD_API
609 bool IsA(const TfToken& schemaFamily,
610 UsdSchemaVersion schemaVersion) const;
611
613
617
620 USD_API
621 bool IsInFamily(const TfToken &schemaFamily) const;
622
626 USD_API
628 const TfToken &schemaFamily,
629 UsdSchemaVersion schemaVersion,
630 UsdSchemaRegistry::VersionPolicy versionPolicy) const;
631
636 template <typename SchemaType>
638 UsdSchemaRegistry::VersionPolicy versionPolicy) const {
639 static_assert(std::is_base_of<UsdSchemaBase, SchemaType>::value,
640 "Provided type must derive UsdSchemaBase.");
641 const UsdSchemaRegistry::SchemaInfo *schemaInfo =
642 UsdSchemaRegistry::FindSchemaInfo<SchemaType>();
643 if (!schemaInfo) {
644 TF_CODING_ERROR("Class '%s' is not correctly registered with the "
645 "UsdSchemaRegistry as a schema type. The schema may need to be "
646 "regenerated.",
647 TfType::Find<SchemaType>().GetTypeName().c_str());
648 return false;
649 }
650 return IsInFamily(schemaInfo->family, schemaInfo->version,
651 versionPolicy);
652 };
653
658 USD_API
660 const TfType &schemaType,
661 UsdSchemaRegistry::VersionPolicy versionPolicy) const;
662
671 USD_API
673 const TfToken &schemaIdentifier,
674 UsdSchemaRegistry::VersionPolicy versionPolicy) const;
675
680 USD_API
682 const TfToken &schemaFamily,
683 UsdSchemaVersion *schemaVersion) const;
684
686
732
739 template <typename SchemaType>
740 bool
741 HasAPI() const {
742 static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
743 "Provided type must derive UsdAPISchemaBase.");
744 static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
745 "Provided type must not be UsdAPISchemaBase.");
746 static_assert(
747 SchemaType::schemaKind == UsdSchemaKind::SingleApplyAPI ||
748 SchemaType::schemaKind == UsdSchemaKind::MultipleApplyAPI,
749 "Provided schema type must be an applied API schema.");
750
751 return _HasAPI(UsdSchemaRegistry::FindSchemaInfo<SchemaType>());
752 }
753
759 template <typename SchemaType>
760 bool
761 HasAPI(const TfToken &instanceName) const {
762 static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
763 "Provided type must derive UsdAPISchemaBase.");
764 static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
765 "Provided type must not be UsdAPISchemaBase.");
766 static_assert(SchemaType::schemaKind == UsdSchemaKind::MultipleApplyAPI,
767 "Provided schema type must be a multi apply API schema.");
768
769 return _HasAPIInstance(
770 UsdSchemaRegistry::FindSchemaInfo<SchemaType>(), instanceName);
771 }
772
774 USD_API
775 bool HasAPI(const TfType& schemaType) const;
776
779 USD_API
780 bool HasAPI(const TfType& schemaType,
781 const TfToken& instanceName) const;
782
785 USD_API
786 bool HasAPI(const TfToken& schemaIdentifier) const;
787
791 USD_API
792 bool HasAPI(const TfToken& schemaIdentifier,
793 const TfToken& instanceName) const;
794
797 USD_API
798 bool HasAPI(const TfToken& schemaFamily,
799 UsdSchemaVersion schemaVersion) const;
800
804 USD_API
805 bool HasAPI(const TfToken& schemaFamily,
806 UsdSchemaVersion schemaVersion,
807 const TfToken& instanceName) const;
808
810
814
821 USD_API
823 const TfToken &schemaFamily) const;
824
830 USD_API
832 const TfToken &schemaFamily,
833 const TfToken &instanceName) const;
834
843 USD_API
845 const TfToken &schemaFamily,
846 UsdSchemaVersion schemaVersion,
847 UsdSchemaRegistry::VersionPolicy versionPolicy) const;
848
855 USD_API
857 const TfToken &schemaFamily,
858 UsdSchemaVersion schemaVersion,
860 const TfToken &instanceName) const;
861
866 template <typename SchemaType>
868 UsdSchemaRegistry::VersionPolicy versionPolicy) const {
869 static_assert(std::is_base_of<UsdSchemaBase, SchemaType>::value,
870 "Provided type must derive UsdSchemaBase.");
871 const UsdSchemaRegistry::SchemaInfo *schemaInfo =
872 UsdSchemaRegistry::FindSchemaInfo<SchemaType>();
873 if (!schemaInfo) {
874 TF_CODING_ERROR("Class '%s' is not correctly registered with the "
875 "UsdSchemaRegistry as a schema type. The schema may need to be "
876 "regenerated.",
877 TfType::Find<SchemaType>().GetTypeName().c_str());
878 return false;
879 }
880 return HasAPIInFamily(schemaInfo->family, schemaInfo->version,
881 versionPolicy);
882 };
883
888 template <typename SchemaType>
891 const TfToken &instanceName) const {
892 static_assert(std::is_base_of<UsdSchemaBase, SchemaType>::value,
893 "Provided type must derive UsdSchemaBase.");
894 const UsdSchemaRegistry::SchemaInfo *schemaInfo =
895 UsdSchemaRegistry::FindSchemaInfo<SchemaType>();
896 if (!schemaInfo) {
897 TF_CODING_ERROR("Class '%s' is not correctly registered with the "
898 "UsdSchemaRegistry as a schema type. The schema may need to be "
899 "regenerated.",
900 TfType::Find<SchemaType>().GetTypeName().c_str());
901 return false;
902 }
903 return HasAPIInFamily(schemaInfo->family, schemaInfo->version,
904 versionPolicy, instanceName);
905 };
906
911 USD_API
913 const TfType &schemaType,
914 UsdSchemaRegistry::VersionPolicy versionPolicy) const;
915
920 USD_API
922 const TfType &schemaType,
924 const TfToken &instanceName) const;
925
934 USD_API
936 const TfToken &schemaIdentifier,
937 UsdSchemaRegistry::VersionPolicy versionPolicy) const;
938
947 USD_API
949 const TfToken &schemaIdentifier,
951 const TfToken &instanceName) const;
952
966 USD_API
967 bool
969 const TfToken &schemaFamily,
970 UsdSchemaVersion *schemaVersion) const;
971
984 USD_API
985 bool
987 const TfToken &schemaFamily,
988 const TfToken &instanceName,
989 UsdSchemaVersion *schemaVersion) const;
990
992
996
1009 template <typename SchemaType>
1010 bool CanApplyAPI(std::string *whyNot = nullptr) const {
1011 static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
1012 "Provided type must derive UsdAPISchemaBase.");
1013 static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
1014 "Provided type must not be UsdAPISchemaBase.");
1015 static_assert(SchemaType::schemaKind == UsdSchemaKind::SingleApplyAPI,
1016 "Provided schema type must be a single apply API schema.");
1017
1018 const UsdSchemaRegistry::SchemaInfo *schemaInfo =
1019 UsdSchemaRegistry::FindSchemaInfo<SchemaType>();
1020 if (!schemaInfo) {
1021 TF_CODING_ERROR("Class '%s' is not correctly registered with the "
1022 "UsdSchemaRegistry as a schema type. The schema may need to be "
1023 "regenerated.",
1024 TfType::Find<SchemaType>().GetTypeName().c_str());
1025 return false;
1026 }
1027 return _CanApplySingleApplyAPI(*schemaInfo, whyNot);
1028 }
1029
1043 template <typename SchemaType>
1044 bool CanApplyAPI(const TfToken &instanceName,
1045 std::string *whyNot = nullptr) const {
1046 static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
1047 "Provided type must derive UsdAPISchemaBase.");
1048 static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
1049 "Provided type must not be UsdAPISchemaBase.");
1050 static_assert(SchemaType::schemaKind == UsdSchemaKind::MultipleApplyAPI,
1051 "Provided schema type must be a multiple apply API schema.");
1052
1053 const UsdSchemaRegistry::SchemaInfo *schemaInfo =
1054 UsdSchemaRegistry::FindSchemaInfo<SchemaType>();
1055 if (!schemaInfo) {
1056 TF_CODING_ERROR("Class '%s' is not correctly registered with the "
1057 "UsdSchemaRegistry as a schema type. The schema may need to be "
1058 "regenerated.",
1059 TfType::Find<SchemaType>().GetTypeName().c_str());
1060 return false;
1061 }
1062 return _CanApplyMultipleApplyAPI(*schemaInfo, instanceName, whyNot);
1063 }
1064
1067 USD_API
1068 bool CanApplyAPI(const TfType& schemaType,
1069 std::string *whyNot = nullptr) const;
1070
1074 USD_API
1075 bool CanApplyAPI(const TfType& schemaType,
1076 const TfToken& instanceName,
1077 std::string *whyNot = nullptr) const;
1078
1081 USD_API
1082 bool CanApplyAPI(const TfToken& schemaIdentifier,
1083 std::string *whyNot = nullptr) const;
1084
1089 USD_API
1090 bool CanApplyAPI(const TfToken& schemaIdentifier,
1091 const TfToken& instanceName,
1092 std::string *whyNot = nullptr) const;
1093
1096 USD_API
1097 bool CanApplyAPI(const TfToken& schemaFamily,
1098 UsdSchemaVersion schemaVersion,
1099 std::string *whyNot = nullptr) const;
1100
1105 USD_API
1106 bool CanApplyAPI(const TfToken& schemaFamily,
1107 UsdSchemaVersion schemaVersion,
1108 const TfToken& instanceName,
1109 std::string *whyNot = nullptr) const;
1110
1112
1116
1132 template <typename SchemaType>
1133 bool ApplyAPI() 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::SingleApplyAPI,
1139 "Provided schema type must be a single 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 _ApplySingleApplyAPI(*schemaInfo);
1151 }
1152
1173 template <typename SchemaType>
1174 bool ApplyAPI(const TfToken &instanceName) const {
1175 static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
1176 "Provided type must derive UsdAPISchemaBase.");
1177 static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
1178 "Provided type must not be UsdAPISchemaBase.");
1179 static_assert(SchemaType::schemaKind == UsdSchemaKind::MultipleApplyAPI,
1180 "Provided schema type must be a multiple apply API schema.");
1181
1182 const UsdSchemaRegistry::SchemaInfo *schemaInfo =
1183 UsdSchemaRegistry::FindSchemaInfo<SchemaType>();
1184 if (!schemaInfo) {
1185 TF_CODING_ERROR("Class '%s' is not correctly registered with the "
1186 "UsdSchemaRegistry as a schema type. The schema may need to be "
1187 "regenerated.",
1188 TfType::Find<SchemaType>().GetTypeName().c_str());
1189 return false;
1190 }
1191 return _ApplyMultipleApplyAPI(*schemaInfo, instanceName);
1192 }
1193
1195 USD_API
1196 bool ApplyAPI(const TfType& schemaType) const;
1197
1200 USD_API
1201 bool ApplyAPI(const TfType& schemaType,
1202 const TfToken& instanceName) const;
1203
1206 USD_API
1207 bool ApplyAPI(const TfToken& schemaIdentifier) const;
1208
1212 USD_API
1213 bool ApplyAPI(const TfToken& schemaIdentifier,
1214 const TfToken& instanceName) const;
1215
1218 USD_API
1219 bool ApplyAPI(const TfToken& schemaFamily,
1220 UsdSchemaVersion schemaVersion) const;
1221
1225 USD_API
1226 bool ApplyAPI(const TfToken& schemaFamily,
1227 UsdSchemaVersion schemaVersion,
1228 const TfToken& instanceName) const;
1229
1231
1235
1252 template <typename SchemaType>
1253 bool RemoveAPI() const {
1254 static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
1255 "Provided type must derive UsdAPISchemaBase.");
1256 static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
1257 "Provided type must not be UsdAPISchemaBase.");
1258 static_assert(SchemaType::schemaKind == UsdSchemaKind::SingleApplyAPI,
1259 "Provided schema type must be a single apply API schema.");
1260
1261 const UsdSchemaRegistry::SchemaInfo *schemaInfo =
1262 UsdSchemaRegistry::FindSchemaInfo<SchemaType>();
1263 if (!schemaInfo) {
1264 TF_CODING_ERROR("Class '%s' is not correctly registered with the "
1265 "UsdSchemaRegistry as a schema type. The schema may need to be "
1266 "regenerated.",
1267 TfType::Find<SchemaType>().GetTypeName().c_str());
1268 return false;
1269 }
1270 return _RemoveSingleApplyAPI(*schemaInfo);
1271 }
1272
1294 template <typename SchemaType>
1295 bool RemoveAPI(const TfToken &instanceName) const {
1296 static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
1297 "Provided type must derive UsdAPISchemaBase.");
1298 static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
1299 "Provided type must not be UsdAPISchemaBase.");
1300 static_assert(SchemaType::schemaKind == UsdSchemaKind::MultipleApplyAPI,
1301 "Provided schema type must be a multiple apply API schema.");
1302
1303 const UsdSchemaRegistry::SchemaInfo *schemaInfo =
1304 UsdSchemaRegistry::FindSchemaInfo<SchemaType>();
1305 if (!schemaInfo) {
1306 TF_CODING_ERROR("Class '%s' is not correctly registered with the "
1307 "UsdSchemaRegistry as a schema type. The schema may need to be "
1308 "regenerated.",
1309 TfType::Find<SchemaType>().GetTypeName().c_str());
1310 return false;
1311 }
1312 return _RemoveMultipleApplyAPI(*schemaInfo, instanceName);
1313 }
1314
1316 USD_API
1317 bool RemoveAPI(const TfType& schemaType) const;
1318
1321 USD_API
1322 bool RemoveAPI(const TfType& schemaType,
1323 const TfToken& instanceName) const;
1324
1327 USD_API
1328 bool RemoveAPI(const TfToken& schemaIdentifier) const;
1329
1333 USD_API
1334 bool RemoveAPI(const TfToken& schemaIdentifier,
1335 const TfToken& instanceName) const;
1336
1339 USD_API
1340 bool RemoveAPI(const TfToken& schemaFamily,
1341 UsdSchemaVersion schemaVersion) const;
1342
1346 USD_API
1347 bool RemoveAPI(const TfToken& schemaFamily,
1348 UsdSchemaVersion schemaVersion,
1349 const TfToken& instanceName) const;
1350
1352
1376 USD_API
1377 bool AddAppliedSchema(const TfToken &appliedSchemaName) const;
1378
1403 USD_API
1404 bool RemoveAppliedSchema(const TfToken &appliedSchemaName) const;
1405
1406 // --------------------------------------------------------------------- //
1408 // --------------------------------------------------------------------- //
1409
1415 USD_API
1416 UsdPrim GetChild(const TfToken &name) const;
1417
1426 inline SiblingRange GetChildren() const;
1427
1429 inline SiblingRange GetAllChildren() const;
1430
1450 inline SiblingRange
1451 GetFilteredChildren(const Usd_PrimFlagsPredicate &predicate) const;
1452
1455 USD_API
1457
1460 USD_API
1462
1465 USD_API
1467 const Usd_PrimFlagsPredicate &predicate) const;
1468
1481 inline SubtreeRange GetDescendants() const;
1482
1491 inline SubtreeRange GetAllDescendants() const;
1492
1516 inline SubtreeRange
1517 GetFilteredDescendants(const Usd_PrimFlagsPredicate &predicate) const;
1518
1524 USD_API
1526
1529 void SetChildrenReorder(const TfTokenVector &order) const {
1530 SetMetadata(SdfFieldKeys->PrimOrder, order);
1531 }
1532
1536 ClearMetadata(SdfFieldKeys->PrimOrder);
1537 }
1538
1539public:
1540 // --------------------------------------------------------------------- //
1542 // --------------------------------------------------------------------- //
1543
1547 Usd_PrimDataConstPtr prim = get_pointer(_Prim());
1548 SdfPath proxyPrimPath = _ProxyPrimPath();
1549 Usd_MoveToParent(prim, proxyPrimPath);
1550 return UsdPrim(prim, proxyPrimPath);
1551 }
1552
1561 USD_API
1563
1569 USD_API
1571 const Usd_PrimFlagsPredicate &predicate) const;
1572
1579 USD_API
1580 bool IsPseudoRoot() const;
1581
1585 USD_API UsdPrim GetPrimAtPath(const SdfPath& path) const;
1586
1590 USD_API UsdObject GetObjectAtPath(const SdfPath& path) const;
1591
1600 USD_API UsdProperty GetPropertyAtPath(const SdfPath& path) const;
1601
1610 USD_API UsdAttribute GetAttributeAtPath(const SdfPath& path) const;
1611
1621
1622 // --------------------------------------------------------------------- //
1624 // --------------------------------------------------------------------- //
1625
1631 USD_API
1633
1641 USD_API
1642 UsdVariantSet GetVariantSet(const std::string& variantSetName) const;
1643
1649 USD_API
1650 bool HasVariantSets() const;
1651
1652 // --------------------------------------------------------------------- //
1654 // --------------------------------------------------------------------- //
1655
1695 USD_API
1698 const SdfValueTypeName &typeName,
1699 bool custom,
1700 SdfVariability variability = SdfVariabilityVarying) const;
1703 USD_API
1706 const SdfValueTypeName &typeName,
1707 SdfVariability variability = SdfVariabilityVarying) const;
1708
1713 USD_API
1715 const std::vector<std::string> &nameElts,
1716 const SdfValueTypeName &typeName,
1717 bool custom,
1718 SdfVariability variability = SdfVariabilityVarying) const;
1722 USD_API
1724 const std::vector<std::string> &nameElts,
1725 const SdfValueTypeName &typeName,
1726 SdfVariability variability = SdfVariabilityVarying) const;
1727
1729 USD_API
1730 std::vector<UsdAttribute> GetAttributes() const;
1731
1734 USD_API
1735 std::vector<UsdAttribute> GetAuthoredAttributes() const;
1736
1749 USD_API
1750 UsdAttribute GetAttribute(const TfToken& attrName) const;
1751
1754 USD_API
1755 bool HasAttribute(const TfToken& attrName) const;
1756
1763 USD_API
1764 SdfPathVector
1766 Usd_PrimFlagsPredicate const &traversalPredicate,
1767 std::function<bool (UsdAttribute const &)> const &pred = nullptr,
1768 bool recurseOnSources = false) const;
1769
1773 USD_API
1774 SdfPathVector
1776 std::function<bool (UsdAttribute const &)> const &pred = nullptr,
1777 bool recurseOnSources = false) const;
1778
1779 // --------------------------------------------------------------------- //
1781 // --------------------------------------------------------------------- //
1782
1819 USD_API
1821 bool custom=true) const;
1822
1827 USD_API
1828 UsdRelationship CreateRelationship(const std::vector<std::string> &nameElts,
1829 bool custom=true)
1830 const;
1831
1833 USD_API
1834 std::vector<UsdRelationship> GetRelationships() const;
1835
1838 USD_API
1839 std::vector<UsdRelationship> GetAuthoredRelationships() const;
1840
1853 USD_API
1855
1858 USD_API
1859 bool HasRelationship(const TfToken& relName) const;
1860
1867 USD_API
1868 SdfPathVector
1870 Usd_PrimFlagsPredicate const &traversalPredicate,
1871 std::function<bool (UsdRelationship const &)> const &pred = nullptr,
1872 bool recurseOnTargets = false) const;
1873
1877 USD_API
1878 SdfPathVector
1880 std::function<bool (UsdRelationship const &)> const &pred = nullptr,
1881 bool recurseOnTargets = false) const;
1882
1883 // --------------------------------------------------------------------- //
1890 // --------------------------------------------------------------------- //
1891
1895 USD_API
1896 bool ClearPayload() const;
1897
1902 USD_API
1903 bool HasPayload() const;
1904
1910 USD_API
1911 bool SetPayload(const SdfPayload& payload) const;
1912
1915 USD_API
1917 const std::string& assetPath, const SdfPath& primPath) const;
1918
1922 USD_API
1923 bool SetPayload(const SdfLayerHandle& layer, const SdfPath& primPath) const;
1924
1926
1927 // --------------------------------------------------------------------- //
1929 // --------------------------------------------------------------------- //
1930
1938 USD_API
1940
1942 USD_API
1944
1950 USD_API
1952
1956 USD_API
1957 void Unload() const;
1958
1959 // --------------------------------------------------------------------- //
1961 // --------------------------------------------------------------------- //
1962
1972 USD_API
1974
1976 USD_API
1978
1979 // --------------------------------------------------------------------- //
1981 // --------------------------------------------------------------------- //
1982
1992 USD_API
1994
1996 USD_API
1998
1999 // --------------------------------------------------------------------- //
2001 // --------------------------------------------------------------------- //
2002
2010 USD_API
2012
2014 USD_API
2016
2017 // --------------------------------------------------------------------- //
2021 // --------------------------------------------------------------------- //
2022
2029 bool IsInstanceable() const {
2030 bool instanceable = false;
2031 return GetMetadata(SdfFieldKeys->Instanceable, &instanceable) &&
2032 instanceable;
2033 }
2034
2037 bool SetInstanceable(bool instanceable) const {
2038 return SetMetadata(SdfFieldKeys->Instanceable, instanceable);
2039 }
2040
2043 bool ClearInstanceable() const {
2044 return ClearMetadata(SdfFieldKeys->Instanceable);
2045 }
2046
2050 return HasAuthoredMetadata(SdfFieldKeys->Instanceable);
2051 }
2052
2058 bool IsInstance() const { return _Prim()->IsInstance(); }
2059
2063 bool IsInstanceProxy() const {
2064 return Usd_IsInstanceProxy(_Prim(), _ProxyPrimPath());
2065 }
2066
2074 USD_API
2075 static bool IsPrototypePath(const SdfPath& path);
2076
2081 USD_API
2082 static bool IsPathInPrototype(const SdfPath& path);
2083
2088 bool IsPrototype() const { return _Prim()->IsPrototype(); }
2089
2094 bool IsInPrototype() const {
2095 return (IsInstanceProxy() ?
2097 }
2098
2101 USD_API
2103
2108 if (IsInstanceProxy()) {
2109 return UsdPrim(_Prim(), SdfPath());
2110 }
2111 return UsdPrim();
2112 }
2113
2119 USD_API
2120 std::vector<UsdPrim> GetInstances() const;
2122
2123 // --------------------------------------------------------------------- //
2126 // --------------------------------------------------------------------- //
2127
2150 const PcpPrimIndex &GetPrimIndex() const { return _Prim()->GetPrimIndex(); }
2151
2172 USD_API
2174
2182 USD_API
2184 const UsdEditTarget &editTarget) const;
2185
2193 USD_API
2195 const UsdEditTarget &editTarget) const;
2196
2198
2199private:
2200 class _ProtoToInstancePathMap {
2201 friend class UsdPrim;
2202 public:
2203 using _Map = std::vector<std::pair<SdfPath, SdfPath>>;
2204 SdfPath MapProtoToInstance(SdfPath const &protoPath) const;
2205 private:
2206 _Map _map;
2207 };
2208
2209 friend class UsdObject;
2210 friend class UsdPrimSiblingIterator;
2211 friend class UsdPrimSubtreeIterator;
2212 friend class UsdProperty;
2213 friend class UsdSchemaBase;
2214 friend class UsdAPISchemaBase;
2215 friend class UsdStage;
2216 friend class Usd_StageImplAccess;
2217 friend class UsdPrimRange;
2218 friend class Usd_PrimData;
2219 friend class Usd_PrimFlagsPredicate;
2220 friend struct UsdPrim_RelTargetFinder;
2221 friend struct UsdPrim_AttrConnectionFinder;
2222
2223 // Prim constructor.
2224 UsdPrim(const Usd_PrimDataHandle &primData,
2225 const SdfPath &proxyPrimPath)
2226 : UsdObject(primData, proxyPrimPath) { }
2227
2228 // General constructor.
2229 UsdPrim(UsdObjType objType,
2230 const Usd_PrimDataHandle &prim,
2231 const SdfPath &proxyPrimPath,
2232 const TfToken &propName)
2233 : UsdObject(objType, prim, proxyPrimPath, propName) {}
2234
2235 // Helper to make a sibling range.
2236 inline SiblingRange
2237 _MakeSiblingRange(const Usd_PrimFlagsPredicate &pred) const;
2238
2239 // Helper to make a range of descendants.
2240 inline SubtreeRange
2241 _MakeDescendantsRange(const Usd_PrimFlagsPredicate &pred) const;
2242
2243 // Helper to make a vector of properties from names.
2244 std::vector<UsdProperty>
2245 _MakeProperties(const TfTokenVector &names) const;
2246
2247 // Helper for Get{Authored}{PropertyNames,Properties}
2248 TfTokenVector _GetPropertyNames(
2249 bool onlyAuthored,
2250 bool applyOrder=true,
2251 const PropertyPredicateFunc &predicate={}) const;
2252
2253 // Helper for Get(Authored)PropertiesInNamespace.
2254 std::vector<UsdProperty>
2255 _GetPropertiesInNamespace(const std::string &namespaces,
2256 bool onlyAuthored) const;
2257
2258 // Helper for Get(Authored)Attributes.
2259 std::vector<UsdAttribute>
2260 _GetAttributes(bool onlyAuthored, bool applyOrder=false) const;
2261
2262 // Helper for Get(Authored)Relationships.
2263 std::vector<UsdRelationship>
2264 _GetRelationships(bool onlyAuthored, bool applyOrder=false) const;
2265
2266 friend const PcpPrimIndex &Usd_PrimGetSourcePrimIndex(const UsdPrim&);
2267 // Return a const reference to the source PcpPrimIndex for this prim.
2268 //
2269 // For all prims in prototypes (which includes the prototype prim itself),
2270 // this is the prim index for the instance that was chosen to serve
2271 // as the prototype for all other instances. This prim index will not
2272 // have the same path as the prim's path.
2273 //
2274 // This is a private helper but is also wrapped out to Python
2275 // for testing and debugging purposes.
2276 const PcpPrimIndex &_GetSourcePrimIndex() const
2277 { return _Prim()->GetSourcePrimIndex(); }
2278
2279 // Helper function for MakeResolveTargetUpToEditTarget and
2280 // MakeResolveTargetStrongerThanEditTarget.
2282 _MakeResolveTargetFromEditTarget(
2283 const UsdEditTarget &editTarget,
2284 bool makeAsStrongerThan) const;
2285
2286 _ProtoToInstancePathMap _GetProtoToInstancePathMap() const;
2287};
2288
2293 using _UnderlyingIterator = const Usd_PrimData*;
2294 class _PtrProxy {
2295 public:
2296 UsdPrim* operator->() { return &_prim; }
2297 private:
2298 friend class UsdPrimSiblingIterator;
2299 explicit _PtrProxy(const UsdPrim& prim) : _prim(prim) {}
2300 UsdPrim _prim;
2301 };
2302public:
2303 using iterator_category = std::forward_iterator_tag;
2304 using value_type = UsdPrim;
2305 using reference = UsdPrim;
2306 using pointer = _PtrProxy;
2307 using difference_type = std::ptrdiff_t;
2308
2309 // Default ctor.
2310 UsdPrimSiblingIterator() = default;
2311
2313 reference operator*() const { return dereference(); }
2314
2316 pointer operator->() const { return pointer(dereference()); }
2317
2320 increment();
2321 return *this;
2322 }
2323
2326 UsdPrimSiblingIterator result = *this;
2327 increment();
2328 return result;
2329 }
2330
2331 bool operator==(const UsdPrimSiblingIterator& other) const {
2332 return equal(other);
2333 }
2334
2335 bool operator!=(const UsdPrimSiblingIterator& other) const {
2336 return !equal(other);
2337 }
2338
2339private:
2340 friend class UsdPrim;
2341
2342 // Constructor used by Prim.
2343 UsdPrimSiblingIterator(const _UnderlyingIterator &i,
2344 const SdfPath& proxyPrimPath,
2345 const Usd_PrimFlagsPredicate &predicate)
2346 : _underlyingIterator(i)
2347 , _proxyPrimPath(proxyPrimPath)
2348 , _predicate(predicate) {
2349 // Need to advance iterator to first matching element.
2350 if (_underlyingIterator &&
2351 !Usd_EvalPredicate(_predicate, _underlyingIterator,
2352 _proxyPrimPath))
2353 increment();
2354 }
2355
2356 bool equal(const UsdPrimSiblingIterator &other) const {
2357 return _underlyingIterator == other._underlyingIterator &&
2358 _proxyPrimPath == other._proxyPrimPath &&
2359 _predicate == other._predicate;
2360 }
2361
2362 void increment() {
2363 if (Usd_MoveToNextSiblingOrParent(_underlyingIterator, _proxyPrimPath,
2364 _predicate)) {
2365 _underlyingIterator = nullptr;
2366 _proxyPrimPath = SdfPath();
2367 }
2368 }
2369
2370 reference dereference() const {
2371 return UsdPrim(_underlyingIterator, _proxyPrimPath);
2372 }
2373
2374 _UnderlyingIterator _underlyingIterator = nullptr;
2375 SdfPath _proxyPrimPath;
2376 Usd_PrimFlagsPredicate _predicate;
2377};
2378
2384public:
2390 typedef std::ptrdiff_t difference_type;
2395
2396 UsdPrimSiblingRange() = default;
2397
2400 UsdPrimSiblingIterator end) : _begin(begin),
2401 _end(end) {}
2402
2404 iterator begin() const { return _begin; }
2405
2407 const_iterator cbegin() const { return _begin; }
2408
2410 iterator end() const { return _end; }
2411
2413 const_iterator cend() const { return _end; }
2414
2416 explicit operator bool() const { return !empty(); }
2417
2419 bool equal(const UsdPrimSiblingRange& other) const {
2420 return _begin == other._begin && _end == other._end;
2421 }
2422
2425 TF_DEV_AXIOM(!empty());
2426 return *begin();
2427 }
2428
2431 std::advance(_begin, n);
2432 return *this;
2433 }
2434
2437 std::advance(_end, n);
2438 return *this;
2439 }
2440
2442 bool empty() const { return begin() == end(); }
2443
2444private:
2446 friend bool operator==(const UsdPrimSiblingRange &lhs,
2447 const UsdPrimSiblingRange &rhs) {
2448 return lhs.equal(rhs);
2449 }
2450
2452 template <class ForwardRange>
2453 friend bool operator==(const UsdPrimSiblingRange& lhs,
2454 const ForwardRange& rhs) {
2455 static_assert(
2456 std::is_same<typename decltype(std::cbegin(rhs))::iterator_category,
2457 std::forward_iterator_tag>::value,
2458 "rhs must be a forward iterator."
2459 );
2460 return (std::distance(std::cbegin(lhs), std::cend(lhs)) ==
2461 std::distance(std::cbegin(rhs), std::cend(rhs))) &&
2462 std::equal(std::cbegin(lhs), std::cend(lhs), std::cbegin(rhs));
2463 }
2464
2466 template <class ForwardRange>
2467 friend bool operator==(const ForwardRange& lhs,
2468 const UsdPrimSiblingRange& rhs) {
2469 return rhs == lhs;
2470 }
2471
2473 friend bool operator!=(const UsdPrimSiblingRange &lhs,
2474 const UsdPrimSiblingRange &rhs) {
2475 return !lhs.equal(rhs);
2476 }
2477
2479 template <class ForwardRange>
2480 friend bool operator!=(const ForwardRange& lhs,
2481 const UsdPrimSiblingRange& rhs) {
2482 return !(lhs == rhs);
2483 }
2484
2486 template <class ForwardRange>
2487 friend bool operator!=(const UsdPrimSiblingRange& lhs,
2488 const ForwardRange& rhs) {
2489 return !(lhs == rhs);
2490 }
2491
2492 iterator _begin;
2493 iterator _end;
2494};
2495
2496// Inform TfIterator it should feel free to make copies of the range type.
2497template <>
2498struct Tf_ShouldIterateOverCopy<
2499 UsdPrimSiblingRange> : std::true_type {};
2500template <>
2501struct Tf_ShouldIterateOverCopy<
2502 const UsdPrimSiblingRange> : std::true_type {};
2503
2505UsdPrim::GetFilteredChildren(const Usd_PrimFlagsPredicate &pred) const
2506{
2507 return _MakeSiblingRange(
2508 Usd_CreatePredicateForTraversal(_Prim(), _ProxyPrimPath(), pred));
2509}
2510
2513{
2515}
2516
2519{
2521}
2522
2523// Helper to make a sibling range.
2525UsdPrim::_MakeSiblingRange(const Usd_PrimFlagsPredicate &pred) const {
2526 Usd_PrimDataConstPtr firstChild = get_pointer(_Prim());
2527 SdfPath firstChildPath = _ProxyPrimPath();
2528 if (!Usd_MoveToChild(firstChild, firstChildPath, pred)) {
2529 firstChild = nullptr;
2530 firstChildPath = SdfPath();
2531 }
2532
2533 return SiblingRange(
2534 SiblingIterator(firstChild, firstChildPath, pred),
2535 SiblingIterator(nullptr, SdfPath(), pred));
2536}
2537
2542 using _UnderlyingIterator = Usd_PrimDataConstPtr;
2543 class _PtrProxy {
2544 public:
2545 UsdPrim* operator->() { return &_prim; }
2546 private:
2547 friend class UsdPrimSubtreeIterator;
2548 explicit _PtrProxy(const UsdPrim& prim) : _prim(prim) {}
2549 UsdPrim _prim;
2550 };
2551public:
2552 using iterator_category = std::forward_iterator_tag;
2553 using value_type = UsdPrim;
2554 using reference = UsdPrim;
2555 using pointer = _PtrProxy;
2556 using difference_type = std::ptrdiff_t;
2557
2558 // Default ctor.
2559 UsdPrimSubtreeIterator() = default;
2560
2562 reference operator*() const { return dereference(); }
2564 pointer operator->() const { return pointer(dereference()); }
2565
2568 increment();
2569 return *this;
2570 }
2571
2575 increment();
2576 return result;
2577 }
2578
2580 bool operator==(const UsdPrimSubtreeIterator &other) const {
2581 return equal(other);
2582 }
2583
2585 bool operator!=(const UsdPrimSubtreeIterator &other) const {
2586 return !equal(other);
2587 }
2588
2589
2590private:
2591 friend class UsdPrim;
2592
2593 // Constructor used by Prim.
2594 UsdPrimSubtreeIterator(const _UnderlyingIterator &i,
2595 const SdfPath &proxyPrimPath,
2596 const Usd_PrimFlagsPredicate &predicate)
2597 : _underlyingIterator(i)
2598 , _proxyPrimPath(proxyPrimPath)
2599 , _predicate(predicate) {
2600 // Need to advance iterator to first matching element.
2601 if (_underlyingIterator &&
2602 !Usd_EvalPredicate(_predicate, _underlyingIterator,
2603 _proxyPrimPath)) {
2604 if (Usd_MoveToNextSiblingOrParent(_underlyingIterator,
2605 _proxyPrimPath, _predicate)) {
2606 _underlyingIterator = nullptr;
2607 _proxyPrimPath = SdfPath();
2608 }
2609 }
2610 }
2611
2612 bool equal(const UsdPrimSubtreeIterator &other) const {
2613 return _underlyingIterator == other._underlyingIterator &&
2614 _proxyPrimPath == other._proxyPrimPath &&
2615 _predicate == other._predicate;
2616 }
2617
2618 void increment() {
2619 if (!Usd_MoveToChild(_underlyingIterator, _proxyPrimPath,
2620 _predicate)) {
2621 while (Usd_MoveToNextSiblingOrParent(_underlyingIterator,
2622 _proxyPrimPath,
2623 _predicate)) {}
2624 }
2625 }
2626
2627 reference dereference() const {
2628 return UsdPrim(_underlyingIterator, _proxyPrimPath);
2629 }
2630
2631 _UnderlyingIterator _underlyingIterator = nullptr;
2632 SdfPath _proxyPrimPath;
2633 Usd_PrimFlagsPredicate _predicate;
2634};
2635
2641public:
2647 typedef std::ptrdiff_t difference_type;
2652
2653 UsdPrimSubtreeRange() = default;
2654
2657 UsdPrimSubtreeIterator end) : _begin(begin),
2658 _end(end) {}
2659
2661 iterator begin() const { return _begin; }
2662
2664 const_iterator cbegin() const { return _begin; }
2665
2667 iterator end() const { return _end; }
2668
2670 const_iterator cend() const { return _end; }
2671
2673 explicit operator bool() const {
2674 return !empty();
2675 }
2676
2678 bool equal(const UsdPrimSubtreeRange& other) const {
2679 return _begin == other._begin && _end == other._end;
2680 }
2681
2684 TF_DEV_AXIOM(!empty());
2685 return *begin();
2686 }
2687
2690 std::advance(_begin, n);
2691 return *this;
2692 }
2693
2696 std::advance(_end, n);
2697 return *this;
2698 }
2699
2701 bool empty() const { return begin() == end(); }
2702
2703private:
2705 friend bool operator==(const UsdPrimSubtreeRange &lhs,
2706 const UsdPrimSubtreeRange &rhs) {
2707 return lhs.equal(rhs);
2708 }
2709
2711 template <class ForwardRange>
2712 friend bool operator==(const UsdPrimSubtreeRange& lhs,
2713 const ForwardRange& rhs) {
2714 static_assert(
2715 std::is_convertible<
2716 typename decltype(std::cbegin(rhs))::iterator_category,
2717 std::forward_iterator_tag>::value,
2718 "rhs must be a forward iterator."
2719 );
2720 return (std::distance(std::cbegin(lhs), std::cend(lhs)) ==
2721 std::distance(std::cbegin(rhs), std::cend(rhs))) &&
2722 std::equal(std::cbegin(lhs), std::cend(lhs), std::cbegin(rhs));
2723 }
2724
2726 template <class ForwardRange>
2727 friend bool operator==(const ForwardRange& lhs,
2728 const UsdPrimSubtreeRange& rhs) {
2729 return rhs == lhs;
2730 }
2731
2733 friend bool operator!=(const UsdPrimSubtreeRange &lhs,
2734 const UsdPrimSubtreeRange &rhs) {
2735 return !lhs.equal(rhs);
2736 }
2737
2739 template <class ForwardRange>
2740 friend bool operator!=(const ForwardRange& lhs,
2741 const UsdPrimSubtreeRange& rhs) {
2742 return !(lhs == rhs);
2743 }
2744
2746 template <class ForwardRange>
2747 friend bool operator!=(const UsdPrimSubtreeRange& lhs,
2748 const ForwardRange& rhs) {
2749 return !(lhs == rhs);
2750 }
2751
2752 iterator _begin;
2753 iterator _end;
2754};
2755
2756// Inform TfIterator it should feel free to make copies of the range type.
2757template <>
2758struct Tf_ShouldIterateOverCopy<
2759 UsdPrimSubtreeRange> : std::true_type {};
2760template <>
2761struct Tf_ShouldIterateOverCopy<
2762 const UsdPrimSubtreeRange> : std::true_type {};
2763
2765UsdPrim::GetFilteredDescendants(const Usd_PrimFlagsPredicate &pred) const
2766{
2767 return _MakeDescendantsRange(
2768 Usd_CreatePredicateForTraversal(_Prim(), _ProxyPrimPath(), pred));
2769}
2770
2773{
2775}
2776
2779{
2781}
2782
2783// Helper to make a sibling range.
2785UsdPrim::_MakeDescendantsRange(const Usd_PrimFlagsPredicate &pred) const {
2786 Usd_PrimDataConstPtr firstChild = get_pointer(_Prim());
2787 SdfPath firstChildPath = _ProxyPrimPath();
2788 Usd_PrimDataConstPtr endChild = firstChild;
2789 SdfPath endChildPath = firstChildPath;
2790 if (Usd_MoveToChild(firstChild, firstChildPath, pred)) {
2791 while (Usd_MoveToNextSiblingOrParent(endChild, endChildPath, pred)) {}
2792 }
2793
2794 return SubtreeRange(
2795 SubtreeIterator(firstChild, firstChildPath, pred),
2796 SubtreeIterator(endChild, endChildPath, pred));
2797}
2798
2799
2801// UsdObject methods that require UsdPrim be a complete type.
2802
2803inline UsdPrim
2805{
2806 return UsdPrim(_prim, _proxyPrimPath);
2807}
2808
2809PXR_NAMESPACE_CLOSE_SCOPE
2810
2811#endif // PXR_USD_USD_PRIM_H
2812
PcpPrimIndex is an index of the all sites of scene description that contribute opinions to a specific...
Definition: primIndex.h:78
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
Represents a payload and all its meta data.
Definition: payload.h:58
Represents a value type name, i.e.
Definition: valueTypeName.h:88
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:88
TfType represents a dynamic runtime type.
Definition: type.h:65
The base class for all API schemas.
Scenegraph object for authoring and retrieving numeric, string, and array valued data,...
Definition: attribute.h:176
Defines a mapping from scene graph paths to Sdf spec paths in a SdfLayer where edits should be direct...
Definition: editTarget.h:79
A proxy class for applying listOp edits to the inherit paths list for a prim.
Definition: inherits.h:51
Base class for Usd scenegraph objects, providing common API.
Definition: object.h:132
bool SetMetadata(const TfToken &key, const T &value) const
Set metadatum key's value to value.
Definition: object.h:764
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...
UsdPrim GetPrim() const
Return this object if it is a prim, otherwise return this object's nearest owning prim.
Definition: prim.h:2804
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 GetMetadata(const TfToken &key, T *value) const
Resolve the requested metadatum named key into value, returning true on success.
Definition: object.h:756
USD_API bool ClearMetadata(const TfToken &key) const
Clears the authored key's value at the current EditTarget, returning false on error.
UsdPayloads provides an interface to authoring and introspecting payloads.
Definition: payloads.h:43
Class representing the builtin definition of a prim given the schemas registered in the schema regist...
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:134
SiblingRange GetAllChildren() const
Return all this prim's children as an iterable range.
Definition: prim.h:2512
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 ...
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:164
USD_API bool HasPayload() const
const PcpPrimIndex & GetPrimIndex() const
Return the cached prim index containing all sites that can contribute opinions to this prim.
Definition: prim.h:2150
USD_API bool ApplyAPI(const TfToken &schemaFamily, UsdSchemaVersion schemaVersion, const TfToken &instanceName) const
This is an overload of ApplyAPI with instanceName that takes a schemaFamily and schemaVersion to dete...
USD_API bool IsA(const TfType &schemaType) const
This is an overload of IsA that takes a TfType schemaType .
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:2107
USD_API bool HasAPIInFamily(const TfType &schemaType, UsdSchemaRegistry::VersionPolicy versionPolicy) const
Overload for convenience of HasAPIInFamily that finds a registered schema for the given schemaType an...
USD_API bool CanApplyAPI(const TfToken &schemaFamily, UsdSchemaVersion schemaVersion, const TfToken &instanceName, std::string *whyNot=nullptr) const
This is an overload of CanApplyAPI with instanceName that takes a schemaFamily and schemaVersion to d...
bool IsInstanceProxy() const
Return true if this prim is an instance proxy, false otherwise.
Definition: prim.h:2063
USD_API bool RemoveAPI(const TfToken &schemaFamily, UsdSchemaVersion schemaVersion) const
This is an overload of RemoveAPI that takes a schemaFamily and schemaVersion to determine the schema ...
UsdPrim GetParent() const
Return this prim's parent prim.
Definition: prim.h:1546
USD_API bool SetKind(const TfToken &kind) const
Author a kind for this prim, at the current UsdEditTarget.
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 SetPayload(const SdfPayload &payload) const
UsdPrim()
Construct an invalid prim.
Definition: prim.h:145
bool IsInstanceable() const
Return true if this prim has been marked as instanceable.
Definition: prim.h:2029
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 UsdSpecializes GetSpecializes() const
Return a UsdSpecializes object that allows one to add, remove, or mutate specializes at the currently...
SiblingRange GetChildren() const
Return this prim's active, loaded, defined, non-abstract children as an iterable range.
Definition: prim.h:2518
USD_API bool HasAuthoredSpecializes() const
Returns true if this prim has any authored specializes.
USD_API bool ClearPayload() const
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:1044
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 ...
SubtreeRange GetDescendants() const
Return this prim's active, loaded, defined, non-abstract descendants as an iterable range.
Definition: prim.h:2778
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:1010
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 std::vector< UsdProperty > GetAuthoredPropertiesInNamespace(const std::string &namespaces) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool SetTypeName(const TfToken &typeName) const
Author this Prim's typeName at the current EditTarget.
Definition: prim.h:219
USD_API UsdAttribute GetAttribute(const TfToken &attrName) const
Return a UsdAttribute with the name attrName.
USD_API bool HasAuthoredInherits() const
Return true if this prim has any authored inherits.
bool HasAuthoredInstanceable() const
Return true if this prim has an authored opinion for 'instanceable', false otherwise.
Definition: prim.h:2049
USD_API bool RemoveAPI(const TfToken &schemaIdentifier, const TfToken &instanceName) const
This is an overload of RemoveAPI with instanceName that takes a schemaIdentifier to determine the sch...
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:2765
SdfSpecifier GetSpecifier() const
Return this prim's composed specifier.
Definition: prim.h:169
const UsdPrimTypeInfo & GetPrimTypeInfo() const
Return the prim's full type info composed from its type name, applied API schemas,...
Definition: prim.h:157
USD_API bool GetKind(TfToken *kind) const
Retrieve the authored kind for this prim.
bool ClearActive() const
Remove the authored 'active' opinion at the current EditTarget.
Definition: prim.h:253
USD_API bool ApplyAPI(const TfToken &schemaFamily, UsdSchemaVersion schemaVersion) const
This is an overload of ApplyAPI that takes a schemaFamily and schemaVersion to determine the schema t...
USD_API std::vector< UsdProperty > GetPropertiesInNamespace(const std::string &namespaces) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
SubtreeRange GetAllDescendants() const
Return all this prim's descendants as an iterable range.
Definition: prim.h:2772
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:2505
USD_API TfTokenVector GetAppliedSchemas() const
Return a vector containing the names of API schemas which have been applied to this prim.
USD_API bool IsInFamily(const TfToken &schemaIdentifier, UsdSchemaRegistry::VersionPolicy versionPolicy) const
Overload for convenience of IsInFamily that parses the schema family and version to use from the give...
USD_API UsdInherits GetInherits() const
Return a UsdInherits object that allows one to add, remove, or mutate inherits at the currently set U...
USD_API bool HasAPIInFamily(const TfToken &schemaFamily, const TfToken &instanceName) const
Return true if the prim has a specific instance instanceName of an applied multiple-apply API schema ...
void ClearChildrenReorder() const
Remove the opinion for the metadata used to reorder children of this prim at the current EditTarget.
Definition: prim.h:1535
USD_API bool IsSubComponent() const
Return true if this prim is a subcomponent based on its kind metadata, false otherwise.
Definition: prim.h:294
USD_API UsdPrim GetPrototype() const
If this prim is an instance, return the UsdPrim for the corresponding prototype.
USD_API bool GetVersionIfHasAPIInFamily(const TfToken &schemaFamily, const TfToken &instanceName, UsdSchemaVersion *schemaVersion) const
Return true if the prim has a specific instance instanceName of an applied multiple-apply API schema ...
USD_API void Unload() const
Unloads this prim and all its descendants.
bool HasAPI() const
Return true if the UsdPrim has had an applied API schema represented by the C++ class type SchemaType...
Definition: prim.h:741
USD_API TfTokenVector GetAllChildrenNames() const
Return the names of the child prims in the order they appear when iterating over GetAllChildren.
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:1529
USD_API std::vector< UsdPrim > GetInstances() const
If this prim is a prototype prim, returns all prims that are instances of this prototype.
USD_API bool IsInFamily(const TfToken &schemaFamily, UsdSchemaVersion schemaVersion, UsdSchemaRegistry::VersionPolicy versionPolicy) const
Return true if the prim's schema type, is or inherits from the schema type of any schema in the given...
USD_API UsdPayloads GetPayloads() const
Return a UsdPayloads object that allows one to add, remove, or mutate payloads at the currently set U...
USD_API UsdProperty GetPropertyAtPath(const SdfPath &path) const
Returns the property at path on the same stage as this prim.
void ClearPropertyOrder() const
Remove the opinion for propertyOrder metadata on this prim at the current EditTarget.
Definition: prim.h:473
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 UsdVariantSet GetVariantSet(const std::string &variantSetName) const
Retrieve a specifically named VariantSet for editing or constructing a UsdEditTarget.
USD_API bool HasAttribute(const TfToken &attrName) const
Return true if this prim has an attribute named attrName, false otherwise.
USD_API bool HasAPI(const TfToken &schemaFamily, UsdSchemaVersion schemaVersion) const
This is an overload of HasAPI that takes a schemaFamily and schemaVersion to determine the schema typ...
USD_API UsdAttribute GetAttributeAtPath(const SdfPath &path) const
Returns the attribute at path on the same stage as this prim.
USD_API bool HasAPIInFamily(const TfToken &schemaFamily, UsdSchemaVersion schemaVersion, UsdSchemaRegistry::VersionPolicy versionPolicy) const
Return true if the prim has an applied API schema that is a schema in the given schemaFamily that m...
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:761
bool IsPrototype() const
Return true if this prim is an instancing prototype prim, false otherwise.
Definition: prim.h:2088
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:268
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 bool AddAppliedSchema(const TfToken &appliedSchemaName) const
Adds the applied API schema name token appliedSchemaName to the apiSchemas metadata for this prim at ...
USD_API bool CanApplyAPI(const TfType &schemaType, const TfToken &instanceName, std::string *whyNot=nullptr) const
This is an overload of CanApplyAPI with instanceName that takes a TfType schemaType .
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 ...
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:591
USD_API UsdPrim GetPrimAtPath(const SdfPath &path) const
Returns the prim at path on the same stage as this prim.
UsdPrimSubtreeIterator SubtreeIterator
Convenience typedefs.
Definition: prim.h:141
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 ...
bool IsInPrototype() const
Return true if this prim is a prototype prim or a descendant of a prototype prim, false otherwise.
Definition: prim.h:2094
USD_API bool SetPayload(const SdfLayerHandle &layer, const SdfPath &primPath) const
void SetPropertyOrder(const TfTokenVector &order) const
Author an opinion for propertyOrder metadata on this prim at the current EditTarget.
Definition: prim.h:467
static USD_API bool IsPrototypePath(const SdfPath &path)
Return true if the given path identifies a prototype prim, false otherwise.
USD_API bool HasAPIInFamily(const TfToken &schemaIdentifier, UsdSchemaRegistry::VersionPolicy versionPolicy, const TfToken &instanceName) const
Overload for convenience of HasAPIInFamily that parses the schema family and version to use from the ...
USD_API bool HasAPI(const TfType &schemaType) const
This is an overload of HasAPI that takes a TfType schemaType .
USD_API bool CanApplyAPI(const TfType &schemaType, std::string *whyNot=nullptr) const
This is an overload of CanApplyAPI that takes a TfType schemaType .
USD_API bool IsPseudoRoot() const
Returns true if the prim is the pseudo root.
USD_API bool HasProperty(const TfToken &propName) const
Return true if this prim has an property named propName, false otherwise.
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 IsInstance() const
Return true if this prim is an instance of a prototype, false otherwise.
Definition: prim.h:2058
USD_API UsdAttribute CreateAttribute(const TfToken &name, const SdfValueTypeName &typeName, SdfVariability variability=SdfVariabilityVarying) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
USD_API SdfPrimSpecHandleVector GetPrimStack() const
Return all the authored SdfPrimSpecs that may contain opinions for this prim in order from strong to ...
USD_API SdfPathVector FindAllRelationshipTargetPaths(std::function< bool(UsdRelationship const &)> const &pred=nullptr, bool recurseOnTargets=false) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool HasAuthoredActive() const
Return true if this prim has an authored opinion for 'active', false otherwise.
Definition: prim.h:261
USD_API bool HasVariantSets() const
Return true if this prim has any authored VariantSets.
bool IsDefined() const
Return true if this prim and all its ancestors have defining specifiers, false otherwise.
Definition: prim.h:301
USD_API bool IsA(const TfToken &schemaIdentifier) const
This is an overload of IsA that takes a schemaIdentifier to determine the schema type.
USD_API bool RemoveAPI(const TfToken &schemaIdentifier) const
This is an overload of RemoveAPI that takes a schemaIdentifier to determine the schema type.
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.
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:889
USD_API UsdPrim GetNextSibling() const
Return this prim's next active, loaded, defined, non-abstract sibling if it has one,...
USD_API bool CanApplyAPI(const TfToken &schemaIdentifier, std::string *whyNot=nullptr) const
This is an overload of CanApplyAPI that takes a schemaIdentifier to determine the schema type.
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...
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...
USD_API bool RemoveAPI(const TfType &schemaType) const
This is an overload of RemoveAPI that takes a TfType schemaType .
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...
USD_API bool IsInFamily(const TfType &schemaType, UsdSchemaRegistry::VersionPolicy versionPolicy) const
Overload for convenience of IsInFamily that finds a registered schema for the given schemaType and us...
USD_API bool HasAuthoredPayloads() const
Return true if this prim has any authored payloads.
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...
USD_API UsdVariantSets GetVariantSets() const
Return a UsdVariantSets object representing all the VariantSets present on this prim.
USD_API UsdObject GetObjectAtPath(const SdfPath &path) const
Returns the object at path on the same stage as this prim.
USD_API bool RemoveAPI(const TfType &schemaType, const TfToken &instanceName) const
This is an overload of RemoveAPI with instanceName that takes a TfType schemaType .
USD_API bool HasAuthoredReferences() const
Return true if this prim has any authored references.
USD_API std::vector< UsdRelationship > GetAuthoredRelationships() const
Like GetRelationships(), but exclude relationships without authored scene description from the result...
const TfToken & GetTypeName() const
Return this prim's composed type name.
Definition: prim.h:216
std::function< bool(const TfToken &propertyName)> PropertyPredicateFunc
Alias for the "predicate" function parameter passed into the various Get{Authored}{PropertyNames,...
Definition: prim.h:321
USD_API UsdRelationship CreateRelationship(const std::vector< std::string > &nameElts, bool custom=true) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
USD_API std::vector< UsdProperty > GetProperties(const PropertyPredicateFunc &predicate={}) const
Return all of this prim's properties (attributes and relationships), including all builtin properties...
USD_API bool ApplyAPI(const TfType &schemaType, const TfToken &instanceName) const
This is an overload of ApplyAPI with instanceName that takes a TfType schemaType .
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:1295
USD_API UsdAttribute CreateAttribute(const std::vector< std::string > &nameElts, const SdfValueTypeName &typeName, SdfVariability variability=SdfVariabilityVarying) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
USD_API bool HasAPIInFamily(const TfToken &schemaFamily, UsdSchemaVersion schemaVersion, UsdSchemaRegistry::VersionPolicy versionPolicy, const TfToken &instanceName) const
Return true if the prim has a specific instance instanceName of an applied multiple-apply API schema ...
USD_API bool CanApplyAPI(const TfToken &schemaIdentifier, const TfToken &instanceName, std::string *whyNot=nullptr) const
This is an overload of CanApplyAPI with instanceName that takes a schemaIdentifier to determine the s...
USD_API TfTokenVector GetPropertyOrder() const
Return the strongest propertyOrder metadata value authored on 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:1253
USD_API bool HasAPI(const TfToken &schemaIdentifier, const TfToken &instanceName) const
This is an overload of HasAPI with instanceName that takes a schemaIdentifier to determine the schema...
USD_API UsdProperty GetProperty(const TfToken &propName) const
Return a UsdProperty with the name propName.
USD_API bool HasAPI(const TfToken &schemaFamily, UsdSchemaVersion schemaVersion, const TfToken &instanceName) const
This is an overload of HasAPI with instanceName that takes a schemaFamily and schemaVersion to determ...
bool SetSpecifier(SdfSpecifier specifier) const
Author an opinion for this Prim's specifier at the current edit target.
Definition: prim.h:205
USD_API bool SetPayload(const std::string &assetPath, const SdfPath &primPath) const
bool IsComponent() const
Return true if this prim is a component model based on its kind metadata, false otherwise.
Definition: prim.h:285
UsdPrimSiblingIterator SiblingIterator
Convenience typedefs.
Definition: prim.h:137
bool IsActive() const
Return true if this prim is active, meaning neither it nor any of its ancestors have active=false.
Definition: prim.h:238
USD_API UsdAttribute CreateAttribute(const std::vector< std::string > &nameElts, const SdfValueTypeName &typeName, bool custom, SdfVariability variability=SdfVariabilityVarying) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
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...
bool SetActive(bool active) const
Author 'active' metadata for this prim at the current EditTarget.
Definition: prim.h:244
bool HasDefiningSpecifier() const
Return true if this prim has a specifier of type SdfSpecifierDef or SdfSpecifierClass.
Definition: prim.h:305
USD_API std::vector< UsdAttribute > GetAttributes() const
Like GetProperties(), but exclude all relationships from the result.
USD_API TfTokenVector GetChildrenNames() const
Return the names of the child prims in the order they appear when iterating over GetChildren.
USD_API TfTokenVector GetChildrenReorder() const
Return the strongest opinion for the metadata used to reorder children of this prim.
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...
USD_API UsdReferences GetReferences() const
Return a UsdReferences object that allows one to add, remove, or mutate references at the currently s...
USD_API void Load(UsdLoadPolicy policy=UsdLoadWithDescendants) const
Load this prim, all its ancestors, and by default all its descendants.
USD_API bool RemoveAppliedSchema(const TfToken &appliedSchemaName) const
Removes the applied API schema name token appliedSchemaName from the apiSchemas metadata for this pri...
USD_API SdfPathVector FindAllAttributeConnectionPaths(std::function< bool(UsdAttribute const &)> const &pred=nullptr, bool recurseOnSources=false) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
USD_API bool ApplyAPI(const TfType &schemaType) const
This is an overload of ApplyAPI that takes a TfType schemaType .
USD_API bool RemoveProperty(const TfToken &propName)
Remove all scene description for the property with the given propName in the current UsdEditTarget.
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:1133
bool IsGroup() const
Return true if this prim is a model group based on its kind metadata, false otherwise.
Definition: prim.h:280
USD_API std::vector< UsdRelationship > GetRelationships() const
Like GetProperties(), but exclude all attributes from the result.
USD_API PcpPrimIndex ComputeExpandedPrimIndex() const
Compute the prim index containing all sites that could contribute opinions to this prim.
bool SetInstanceable(bool instanceable) const
Author 'instanceable' metadata for this prim at the current EditTarget.
Definition: prim.h:2037
bool IsModel() const
Return true if this prim is a model based on its kind metadata, false otherwise.
Definition: prim.h:272
bool ClearInstanceable() const
Remove the authored 'instanceable' opinion at the current EditTarget.
Definition: prim.h:2043
USD_API UsdRelationship GetRelationship(const TfToken &relName) const
Return a UsdRelationship with the name relName.
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:1174
USD_API bool RemoveAPI(const TfToken &schemaFamily, UsdSchemaVersion schemaVersion, const TfToken &instanceName) const
This is an overload of RemoveAPI with instanceName that takes a schemaFamily and schemaVersion to det...
USD_API bool HasAPIInFamily(const TfToken &schemaIdentifier, UsdSchemaRegistry::VersionPolicy versionPolicy) const
Overload for convenience of HasAPIInFamily that parses the schema family and version to use from the ...
USD_API bool IsA(const TfToken &schemaFamily, UsdSchemaVersion schemaVersion) const
This is an overload of IsA that takes a schemaFamily and schemaVersion to determine the schema type.
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 bool CanApplyAPI(const TfToken &schemaFamily, UsdSchemaVersion schemaVersion, std::string *whyNot=nullptr) const
This is an overload of CanApplyAPI that takes a schemaFamily and schemaVersion to determine the schem...
USD_API bool ApplyAPI(const TfToken &schemaIdentifier, const TfToken &instanceName) const
This is an overload of ApplyAPI with instanceName that takes a schemaIdentifier to determine the sche...
USD_API bool HasAPI(const TfToken &schemaIdentifier) const
This is an overload of HasAPI that takes a schemaIdentifier to determine the schema type.
USD_API bool HasAPI(const TfType &schemaType, const TfToken &instanceName) const
This is an overload of HasAPI with instanceName that takes a TfType schemaType .
USD_API bool HasRelationship(const TfToken &relName) const
Return true if this prim has a relationship named relName, false otherwise.
bool HasAuthoredTypeName() const
Return true if a typeName has been authored.
Definition: prim.h:230
USD_API UsdRelationship GetRelationshipAtPath(const SdfPath &path) const
Returns the relationship at path on the same stage as this prim.
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...
USD_API std::vector< UsdProperty > GetAuthoredProperties(const PropertyPredicateFunc &predicate={}) const
Return this prim's properties (attributes and relationships) that have authored scene description,...
USD_API bool ApplyAPI(const TfToken &schemaIdentifier) const
This is an overload of ApplyAPI that takes a schemaIdentifier to determine the schema type.
bool IsAbstract() const
Return true if this prim or any of its ancestors is a class.
Definition: prim.h:297
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:867
USD_API std::vector< UsdAttribute > GetAuthoredAttributes() const
Like GetAttributes(), but exclude attributes without authored scene description from the result.
USD_API bool HasAPIInFamily(const TfType &schemaType, UsdSchemaRegistry::VersionPolicy versionPolicy, const TfToken &instanceName) const
Overload for convenience of HasAPIInFamily that finds a registered schema for the given schemaType an...
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:637
bool ClearTypeName() const
Clear the opinion for this Prim's typeName at the current edit target.
Definition: prim.h:225
An forward-iterable range that traverses a subtree of prims rooted at a given prim in depth-first ord...
Definition: primRange.h:119
Forward traversal iterator of sibling UsdPrim s.
Definition: prim.h:2292
UsdPrimSiblingIterator & operator++()
Preincrement.
Definition: prim.h:2319
reference operator*() const
Dereference.
Definition: prim.h:2313
UsdPrimSiblingIterator operator++(int)
Postincrement.
Definition: prim.h:2325
pointer operator->() const
Indirection.
Definition: prim.h:2316
Forward iterator range of sibling UsdPrim s.
Definition: prim.h:2383
reference front() const
Return *begin(). This range must not be empty.
Definition: prim.h:2424
iterator begin() const
First iterator.
Definition: prim.h:2404
UsdPrimSiblingIterator iterator
Iterator type.
Definition: prim.h:2386
const_iterator cbegin() const
First iterator.
Definition: prim.h:2407
UsdPrimSiblingRange & advance_end(difference_type n)
Advance this range's end iterator.
Definition: prim.h:2436
UsdPrimSiblingRange(UsdPrimSiblingIterator begin, UsdPrimSiblingIterator end)
Construct with a pair of iterators.
Definition: prim.h:2399
bool empty() const
Return begin() == end().
Definition: prim.h:2442
iterator end() const
Past-the-end iterator.
Definition: prim.h:2410
iterator::reference reference
Iterator reference_type.
Definition: prim.h:2394
friend bool operator!=(const UsdPrimSiblingRange &lhs, const ForwardRange &rhs)
Inequality comparison.
Definition: prim.h:2487
friend bool operator==(const UsdPrimSiblingRange &lhs, const ForwardRange &rhs)
Equality comparison.
Definition: prim.h:2453
const_iterator cend() const
Past-the-end iterator.
Definition: prim.h:2413
friend bool operator==(const ForwardRange &lhs, const UsdPrimSiblingRange &rhs)
Equality comparison.
Definition: prim.h:2467
friend bool operator!=(const ForwardRange &lhs, const UsdPrimSiblingRange &rhs)
Inequality comparison.
Definition: prim.h:2480
bool equal(const UsdPrimSiblingRange &other) const
Equality compare.
Definition: prim.h:2419
iterator::value_type value_type
Iterator value_type.
Definition: prim.h:2392
UsdPrimSiblingRange & advance_begin(difference_type n)
Advance this range's begin iterator.
Definition: prim.h:2430
std::ptrdiff_t difference_type
Iterator difference type.
Definition: prim.h:2390
friend bool operator!=(const UsdPrimSiblingRange &lhs, const UsdPrimSiblingRange &rhs)
Inequality comparison.
Definition: prim.h:2473
friend bool operator==(const UsdPrimSiblingRange &lhs, const UsdPrimSiblingRange &rhs)
Equality comparison.
Definition: prim.h:2446
UsdPrimSiblingIterator const_iterator
Const iterator type.
Definition: prim.h:2388
Forward traversal iterator of sibling UsdPrim s.
Definition: prim.h:2541
bool operator==(const UsdPrimSubtreeIterator &other) const
Equality.
Definition: prim.h:2580
UsdPrimSubtreeIterator & operator++()
Preincrement.
Definition: prim.h:2567
reference operator*() const
Dereference.
Definition: prim.h:2562
UsdPrimSubtreeIterator operator++(int)
Postincrement.
Definition: prim.h:2573
bool operator!=(const UsdPrimSubtreeIterator &other) const
Inequality.
Definition: prim.h:2585
pointer operator->() const
Indirection.
Definition: prim.h:2564
Forward iterator range of sibling UsdPrim s.
Definition: prim.h:2640
reference front() const
Return *begin(). This range must not be empty.
Definition: prim.h:2683
iterator begin() const
First iterator.
Definition: prim.h:2661
UsdPrimSubtreeIterator const_iterator
Const iterator type.
Definition: prim.h:2645
const_iterator cbegin() const
First iterator.
Definition: prim.h:2664
UsdPrimSubtreeIterator iterator
Iterator type.
Definition: prim.h:2643
friend bool operator==(const ForwardRange &lhs, const UsdPrimSubtreeRange &rhs)
Equality comparison.
Definition: prim.h:2727
bool empty() const
Return begin() == end().
Definition: prim.h:2701
iterator end() const
Past-the-end iterator.
Definition: prim.h:2667
iterator::reference reference
Iterator reference_type.
Definition: prim.h:2651
friend bool operator==(const UsdPrimSubtreeRange &lhs, const UsdPrimSubtreeRange &rhs)
Equality comparison.
Definition: prim.h:2705
UsdPrimSubtreeRange & advance_end(difference_type n)
Advance this range's end iterator.
Definition: prim.h:2695
const_iterator cend() const
Past-the-end iterator.
Definition: prim.h:2670
bool equal(const UsdPrimSubtreeRange &other) const
Equality compare.
Definition: prim.h:2678
UsdPrimSubtreeRange(UsdPrimSubtreeIterator begin, UsdPrimSubtreeIterator end)
Construct with a pair of iterators.
Definition: prim.h:2656
friend bool operator!=(const UsdPrimSubtreeRange &lhs, const UsdPrimSubtreeRange &rhs)
Inequality comparison.
Definition: prim.h:2733
iterator::value_type value_type
Iterator value_type.
Definition: prim.h:2649
UsdPrimSubtreeRange & advance_begin(difference_type n)
Advance this range's begin iterator.
Definition: prim.h:2689
std::ptrdiff_t difference_type
Iterator difference type.
Definition: prim.h:2647
friend bool operator==(const UsdPrimSubtreeRange &lhs, const ForwardRange &rhs)
Equality comparison.
Definition: prim.h:2712
friend bool operator!=(const UsdPrimSubtreeRange &lhs, const ForwardRange &rhs)
Inequality comparison.
Definition: prim.h:2747
friend bool operator!=(const ForwardRange &lhs, const UsdPrimSubtreeRange &rhs)
Inequality comparison.
Definition: prim.h:2740
Class that holds the full type information for a prim.
Definition: primTypeInfo.h:48
Base class for UsdAttribute and UsdRelationship scenegraph objects.
Definition: property.h:55
UsdReferences provides an interface to authoring and introspecting references in Usd.
Definition: references.h:214
A UsdRelationship creates dependencies between scenegraph objects by allowing a prim to target other ...
Definition: relationship.h:128
Defines a subrange of nodes and layers within a prim's prim index to consider when performing value r...
Definition: resolveTarget.h:73
The base class for all schema types in Usd.
Definition: schemaBase.h:56
UsdSchemaVersion version
The version number of the schema within its schema family.
TfToken family
The name of the family of schema's which the schema is a version of.
VersionPolicy
A policy for filtering by schema version when querying for schemas in a particular schema family.
Structure that holds the information about a schema that is registered with the schema registry.
A proxy class for applying listOp edits to the specializes list for a prim.
Definition: specializes.h:51
The outermost container for scene description, which owns and presents composed prims as a scenegraph...
Definition: stage.h:151
A UsdVariantSet represents a single VariantSet in USD (e.g.
Definition: variantSets.h:56
UsdVariantSets represents the collection of VariantSets that are present on a UsdPrim.
Definition: variantSets.h:222
UsdLoadPolicy
Controls UsdStage::Load() and UsdPrim::Load() behavior regarding whether or not descendant prims are ...
Definition: common.h:116
@ UsdLoadWithDescendants
Load a prim plus all its descendants.
Definition: common.h:118
Standard pointer typedefs.
#define TF_DEV_AXIOM(cond)
The same as TF_AXIOM, but compiled only in dev builds.
Definition: diagnostic.h:222
#define TF_CODING_ERROR(fmt, args)
Issue an internal programming error, but continue execution.
Definition: diagnostic.h:85
UsdObjType
Enum values to represent the various Usd object types.
Definition: object.h:52
unspecified UsdPrimDefaultPredicate
The default predicate used for prim traversals in methods like UsdPrim::GetChildren,...
unspecified UsdPrimAllPrimsPredicate
Predicate that includes all prims.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:457
SdfSpecifier
An enum that identifies the possible specifiers for an SdfPrimSpec.
Definition: types.h:116
SdfVariability
An enum that identifies variability types for attributes.
Definition: types.h:172