prim.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_USD_USD_PRIM_H
25 #define PXR_USD_USD_PRIM_H
26 
28 
29 #include "pxr/pxr.h"
30 #include "pxr/usd/usd/api.h"
31 #include "pxr/usd/usd/common.h"
32 #include "pxr/usd/usd/object.h"
33 #include "pxr/usd/usd/primFlags.h"
34 
35 #include "pxr/usd/sdf/schema.h"
36 #include "pxr/base/trace/trace.h"
37 
39 #include "pxr/base/tf/refBase.h"
40 #include "pxr/base/tf/token.h"
41 #include "pxr/base/tf/weakBase.h"
42 
43 #include "pxr/usd/sdf/path.h"
44 
45 #include <boost/iterator/iterator_adaptor.hpp>
46 #include <boost/range/iterator_range.hpp>
47 
48 #include <string>
49 #include <type_traits>
50 #include <vector>
51 
52 PXR_NAMESPACE_OPEN_SCOPE
53 
54 class UsdPrim;
55 class UsdPrimDefinition;
56 class UsdPrimRange;
57 class Usd_PrimData;
58 
59 class UsdAttribute;
60 class UsdEditTarget;
61 class UsdRelationship;
62 class UsdPayloads;
63 class UsdReferences;
64 class UsdResolveTarget;
65 class UsdSchemaBase;
66 class UsdAPISchemaBase;
67 class UsdInherits;
68 class UsdSpecializes;
69 class UsdVariantSets;
70 class UsdVariantSet;
71 
72 class SdfPayload;
73 
75 typedef boost::iterator_range<UsdPrimSiblingIterator> UsdPrimSiblingRange;
76 
78 typedef boost::iterator_range<UsdPrimSubtreeIterator> UsdPrimSubtreeRange;
79 
134 class UsdPrim : public UsdObject
135 {
136 public:
140 
144 
146  UsdPrim() : UsdObject(_Null<UsdPrim>()) {}
147 
159  return _Prim()->GetPrimTypeInfo();
160  }
161 
166  return _Prim()->GetPrimDefinition();
167  }
168 
170  SdfSpecifier GetSpecifier() const { return _Prim()->GetSpecifier(); };
171 
185  USD_API
186  SdfPrimSpecHandleVector GetPrimStack() const;
187 
200  USD_API
201  std::vector<std::pair<SdfPrimSpecHandle, SdfLayerOffset>>
203 
206  bool SetSpecifier(SdfSpecifier specifier) const {
207  return SetMetadata(SdfFieldKeys->Specifier, specifier);
208  }
209 
217  const TfToken &GetTypeName() const { return _Prim()->GetTypeName(); };
218 
220  bool SetTypeName(const TfToken & typeName) const {
221  return SetMetadata(SdfFieldKeys->TypeName, typeName);
222  }
223 
226  bool ClearTypeName() const {
227  return ClearMetadata(SdfFieldKeys->TypeName);
228  }
229 
231  bool HasAuthoredTypeName() const {
232  return HasAuthoredMetadata(SdfFieldKeys->TypeName);
233  }
234 
239  bool IsActive() const { return _Prim()->IsActive(); }
240 
245  bool SetActive(bool active) const {
246  return SetMetadata(SdfFieldKeys->Active, active);
247  }
248 
254  bool ClearActive() const {
255  return ClearMetadata(SdfFieldKeys->Active);
256  }
257 
262  bool HasAuthoredActive() const {
263  return HasAuthoredMetadata(SdfFieldKeys->Active);
264  }
265 
269  bool IsLoaded() const { return _Prim()->IsLoaded(); }
270 
273  bool IsModel() const { return _Prim()->IsModel(); }
274 
278  bool IsGroup() const { return _Prim()->IsGroup(); }
279 
281  bool IsAbstract() const { return _Prim()->IsAbstract(); }
282 
285  bool IsDefined() const { return _Prim()->IsDefined(); }
286 
289  bool HasDefiningSpecifier() const {
290  return _Prim()->HasDefiningSpecifier();
291  }
292 
299  USD_API
301 
304  using PropertyPredicateFunc =
305  std::function<bool (const TfToken &propertyName)>;
306 
318  USD_API
320  const PropertyPredicateFunc &predicate={}) const;
321 
335  USD_API
337  const PropertyPredicateFunc &predicate={}) const;
338 
382  USD_API
383  std::vector<UsdProperty> GetProperties(
384  const PropertyPredicateFunc &predicate={}) const;
385 
399  USD_API
400  std::vector<UsdProperty> GetAuthoredProperties(
401  const PropertyPredicateFunc &predicate={}) const;
402 
414  USD_API
415  std::vector<UsdProperty>
416  GetPropertiesInNamespace(const std::vector<std::string> &namespaces) const;
417 
422  USD_API
423  std::vector<UsdProperty>
424  GetPropertiesInNamespace(const std::string &namespaces) const;
425 
431  USD_API
432  std::vector<UsdProperty>
434  const std::vector<std::string> &namespaces) const;
435 
441  USD_API
442  std::vector<UsdProperty>
443  GetAuthoredPropertiesInNamespace(const std::string &namespaces) const;
444 
446  USD_API
448 
451  void SetPropertyOrder(const TfTokenVector &order) const {
452  SetMetadata(SdfFieldKeys->PropertyOrder, order);
453  }
454 
457  void ClearPropertyOrder() const {
458  ClearMetadata(SdfFieldKeys->PropertyOrder);
459  }
460 
469  USD_API
470  bool RemoveProperty(const TfToken &propName);
471 
484  USD_API
485  UsdProperty GetProperty(const TfToken &propName) const;
486 
489  USD_API
490  bool HasProperty(const TfToken &propName) const;
491 
492 private:
493  // Templated helper functions for the public schema query and API schema
494  // authoring functions. The public functions have overloads that take
495  // a type, an identifier, or a family and version and these helpers handle
496  // all three of these types of input.
497  template<class... SchemaArgs>
498  bool _IsA(
499  const SchemaArgs & ...schemaArgs) const;
500 
501  template<class... SchemaArgs>
502  bool _HasAPI(
503  const SchemaArgs & ...schemaArgs) const;
504 
505  template<class... SchemaArgs>
506  bool _HasAPIInstance(
507  const TfToken &instanceName,
508  const SchemaArgs & ...schemaArgs) const;
509 
510  template <class... SchemaArgs>
511  bool _CanApplySingleApplyAPI(
512  std::string *whyNot,
513  const SchemaArgs &... schemaArgs) const;
514 
515  template <class... SchemaArgs>
516  bool _CanApplyMultipleApplyAPI(
517  const TfToken& instanceName,
518  std::string *whyNot,
519  const SchemaArgs &... schemaArgs) const;
520 
521  template <class... SchemaArgs>
522  bool _ApplySingleApplyAPI(
523  const SchemaArgs &... schemaArgs) const;
524 
525  template <class... SchemaArgs>
526  bool _ApplyMultipleApplyAPI(
527  const TfToken &instanceName,
528  const SchemaArgs &... schemaArgs) const;
529 
530  template <class... SchemaArgs>
531  bool _RemoveSingleApplyAPI(
532  const SchemaArgs &... schemaArgs) const;
533 
534  template <class... SchemaArgs>
535  bool _RemoveMultipleApplyAPI(
536  const TfToken &instanceName,
537  const SchemaArgs &... schemaArgs) const;
538 
539 public:
543 
550  template <typename SchemaType>
551  bool IsA() const {
552  static_assert(std::is_base_of<UsdSchemaBase, SchemaType>::value,
553  "Provided type must derive UsdSchemaBase.");
554  return IsA(TfType::Find<SchemaType>());
555  };
556 
558  USD_API
559  bool IsA(const TfType& schemaType) const;
560 
563  USD_API
564  bool IsA(const TfToken& schemaIdentifier) const;
565 
568  USD_API
569  bool IsA(const TfToken& schemaFamily,
570  UsdSchemaVersion schemaVersion) const;
571 
573 
577 
580  USD_API
581  bool IsInFamily(const TfToken &schemaFamily) const;
582 
586  USD_API
587  bool IsInFamily(
588  const TfToken &schemaFamily,
589  UsdSchemaVersion schemaVersion,
590  UsdSchemaRegistry::VersionPolicy versionPolicy) const;
591 
596  template <typename SchemaType>
598  UsdSchemaRegistry::VersionPolicy versionPolicy) const {
599  static_assert(std::is_base_of<UsdSchemaBase, SchemaType>::value,
600  "Provided type must derive UsdSchemaBase.");
601  return IsInFamily(TfType::Find<SchemaType>(), versionPolicy);
602  };
603 
608  USD_API
609  bool IsInFamily(
610  const TfType &schemaType,
611  UsdSchemaRegistry::VersionPolicy versionPolicy) const;
612 
621  USD_API
622  bool IsInFamily(
623  const TfToken &schemaIdentifier,
624  UsdSchemaRegistry::VersionPolicy versionPolicy) const;
625 
630  USD_API
632  const TfToken &schemaFamily,
633  UsdSchemaVersion *schemaVersion) const;
634 
636 
682 
689  template <typename SchemaType>
690  bool
691  HasAPI() const {
692  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
693  "Provided type must derive UsdAPISchemaBase.");
694  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
695  "Provided type must not be UsdAPISchemaBase.");
696  static_assert(
697  SchemaType::schemaKind == UsdSchemaKind::SingleApplyAPI ||
698  SchemaType::schemaKind == UsdSchemaKind::MultipleApplyAPI,
699  "Provided schema type must be an applied API schema.");
700 
701  return HasAPI(TfType::Find<SchemaType>());
702  }
703 
709  template <typename SchemaType>
710  bool
711  HasAPI(const TfToken &instanceName) const {
712  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
713  "Provided type must derive UsdAPISchemaBase.");
714  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
715  "Provided type must not be UsdAPISchemaBase.");
716  static_assert(SchemaType::schemaKind == UsdSchemaKind::MultipleApplyAPI,
717  "Provided schema type must be a multi apply API schema.");
718 
719  return HasAPI(TfType::Find<SchemaType>(), instanceName);
720  }
721 
723  USD_API
724  bool HasAPI(const TfType& schemaType) const;
725 
728  USD_API
729  bool HasAPI(const TfType& schemaType,
730  const TfToken& instanceName) const;
731 
734  USD_API
735  bool HasAPI(const TfToken& schemaIdentifier) const;
736 
740  USD_API
741  bool HasAPI(const TfToken& schemaIdentifier,
742  const TfToken& instanceName) const;
743 
746  USD_API
747  bool HasAPI(const TfToken& schemaFamily,
748  UsdSchemaVersion schemaVersion) const;
749 
753  USD_API
754  bool HasAPI(const TfToken& schemaFamily,
755  UsdSchemaVersion schemaVersion,
756  const TfToken& instanceName) const;
757 
759 
763 
770  USD_API
771  bool HasAPIInFamily(
772  const TfToken &schemaFamily) const;
773 
779  USD_API
780  bool HasAPIInFamily(
781  const TfToken &schemaFamily,
782  const TfToken &instanceName) const;
783 
792  USD_API
793  bool HasAPIInFamily(
794  const TfToken &schemaFamily,
795  UsdSchemaVersion schemaVersion,
796  UsdSchemaRegistry::VersionPolicy versionPolicy) const;
797 
804  USD_API
805  bool HasAPIInFamily(
806  const TfToken &schemaFamily,
807  UsdSchemaVersion schemaVersion,
808  UsdSchemaRegistry::VersionPolicy versionPolicy,
809  const TfToken &instanceName) const;
810 
815  template <typename SchemaType>
817  UsdSchemaRegistry::VersionPolicy versionPolicy) const {
818  static_assert(std::is_base_of<UsdSchemaBase, SchemaType>::value,
819  "Provided type must derive UsdSchemaBase.");
820  return HasAPIInFamily(
821  TfType::Find<SchemaType>(), versionPolicy);
822  };
823 
828  template <typename SchemaType>
830  UsdSchemaRegistry::VersionPolicy versionPolicy,
831  const TfToken &instanceName) const {
832  static_assert(std::is_base_of<UsdSchemaBase, SchemaType>::value,
833  "Provided type must derive UsdSchemaBase.");
834  return HasAPIInFamily(
835  TfType::Find<SchemaType>(), versionPolicy, instanceName);
836  };
837 
842  USD_API
843  bool HasAPIInFamily(
844  const TfType &schemaType,
845  UsdSchemaRegistry::VersionPolicy versionPolicy) const;
846 
851  USD_API
852  bool HasAPIInFamily(
853  const TfType &schemaType,
854  UsdSchemaRegistry::VersionPolicy versionPolicy,
855  const TfToken &instanceName) const;
856 
865  USD_API
866  bool HasAPIInFamily(
867  const TfToken &schemaIdentifier,
868  UsdSchemaRegistry::VersionPolicy versionPolicy) const;
869 
878  USD_API
879  bool HasAPIInFamily(
880  const TfToken &schemaIdentifier,
881  UsdSchemaRegistry::VersionPolicy versionPolicy,
882  const TfToken &instanceName) const;
883 
897  USD_API
898  bool
900  const TfToken &schemaFamily,
901  UsdSchemaVersion *schemaVersion) const;
902 
915  USD_API
916  bool
918  const TfToken &schemaFamily,
919  const TfToken &instanceName,
920  UsdSchemaVersion *schemaVersion) const;
921 
923 
927 
940  template <typename SchemaType>
941  bool CanApplyAPI(std::string *whyNot = nullptr) const {
942  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
943  "Provided type must derive UsdAPISchemaBase.");
944  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
945  "Provided type must not be UsdAPISchemaBase.");
946  static_assert(SchemaType::schemaKind == UsdSchemaKind::SingleApplyAPI,
947  "Provided schema type must be a single apply API schema.");
948 
949  static const TfType schemaType = TfType::Find<SchemaType>();
950  return CanApplyAPI(schemaType, whyNot);
951  }
952 
966  template <typename SchemaType>
967  bool CanApplyAPI(const TfToken &instanceName,
968  std::string *whyNot = nullptr) const {
969  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
970  "Provided type must derive UsdAPISchemaBase.");
971  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
972  "Provided type must not be UsdAPISchemaBase.");
973  static_assert(SchemaType::schemaKind == UsdSchemaKind::MultipleApplyAPI,
974  "Provided schema type must be a multiple apply API schema.");
975 
976  static const TfType schemaType = TfType::Find<SchemaType>();
977  return CanApplyAPI(schemaType, instanceName, whyNot);
978  }
979 
982  USD_API
983  bool CanApplyAPI(const TfType& schemaType,
984  std::string *whyNot = nullptr) const;
985 
989  USD_API
990  bool CanApplyAPI(const TfType& schemaType,
991  const TfToken& instanceName,
992  std::string *whyNot = nullptr) const;
993 
996  USD_API
997  bool CanApplyAPI(const TfToken& schemaIdentifier,
998  std::string *whyNot = nullptr) const;
999 
1004  USD_API
1005  bool CanApplyAPI(const TfToken& schemaIdentifier,
1006  const TfToken& instanceName,
1007  std::string *whyNot = nullptr) const;
1008 
1011  USD_API
1012  bool CanApplyAPI(const TfToken& schemaFamily,
1013  UsdSchemaVersion schemaVersion,
1014  std::string *whyNot = nullptr) const;
1015 
1020  USD_API
1021  bool CanApplyAPI(const TfToken& schemaFamily,
1022  UsdSchemaVersion schemaVersion,
1023  const TfToken& instanceName,
1024  std::string *whyNot = nullptr) const;
1025 
1027 
1031 
1047  template <typename SchemaType>
1048  bool ApplyAPI() const {
1049  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
1050  "Provided type must derive UsdAPISchemaBase.");
1051  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
1052  "Provided type must not be UsdAPISchemaBase.");
1053  static_assert(SchemaType::schemaKind == UsdSchemaKind::SingleApplyAPI,
1054  "Provided schema type must be a single apply API schema.");
1055 
1056  static const TfType schemaType = TfType::Find<SchemaType>();
1057  return ApplyAPI(schemaType);
1058  }
1059 
1080  template <typename SchemaType>
1081  bool ApplyAPI(const TfToken &instanceName) const {
1082  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
1083  "Provided type must derive UsdAPISchemaBase.");
1084  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
1085  "Provided type must not be UsdAPISchemaBase.");
1086  static_assert(SchemaType::schemaKind == UsdSchemaKind::MultipleApplyAPI,
1087  "Provided schema type must be a multiple apply API schema.");
1088 
1089  static const TfType schemaType = TfType::Find<SchemaType>();
1090  return ApplyAPI(schemaType, instanceName);
1091  }
1092 
1094  USD_API
1095  bool ApplyAPI(const TfType& schemaType) const;
1096 
1099  USD_API
1100  bool ApplyAPI(const TfType& schemaType,
1101  const TfToken& instanceName) const;
1102 
1105  USD_API
1106  bool ApplyAPI(const TfToken& schemaIdentifier) const;
1107 
1111  USD_API
1112  bool ApplyAPI(const TfToken& schemaIdentifier,
1113  const TfToken& instanceName) const;
1114 
1117  USD_API
1118  bool ApplyAPI(const TfToken& schemaFamily,
1119  UsdSchemaVersion schemaVersion) const;
1120 
1124  USD_API
1125  bool ApplyAPI(const TfToken& schemaFamily,
1126  UsdSchemaVersion schemaVersion,
1127  const TfToken& instanceName) const;
1128 
1130 
1134 
1151  template <typename SchemaType>
1152  bool RemoveAPI() const {
1153  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
1154  "Provided type must derive UsdAPISchemaBase.");
1155  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
1156  "Provided type must not be UsdAPISchemaBase.");
1157  static_assert(SchemaType::schemaKind == UsdSchemaKind::SingleApplyAPI,
1158  "Provided schema type must be a single apply API schema.");
1159 
1160  static const TfType schemaType = TfType::Find<SchemaType>();
1161  return RemoveAPI(schemaType);
1162  }
1163 
1185  template <typename SchemaType>
1186  bool RemoveAPI(const TfToken &instanceName) const {
1187  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
1188  "Provided type must derive UsdAPISchemaBase.");
1189  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
1190  "Provided type must not be UsdAPISchemaBase.");
1191  static_assert(SchemaType::schemaKind == UsdSchemaKind::MultipleApplyAPI,
1192  "Provided schema type must be a multiple apply API schema.");
1193 
1194  static const TfType schemaType = TfType::Find<SchemaType>();
1195  return RemoveAPI(schemaType, instanceName);
1196  }
1197 
1199  USD_API
1200  bool RemoveAPI(const TfType& schemaType) const;
1201 
1204  USD_API
1205  bool RemoveAPI(const TfType& schemaType,
1206  const TfToken& instanceName) const;
1207 
1210  USD_API
1211  bool RemoveAPI(const TfToken& schemaIdentifier) const;
1212 
1216  USD_API
1217  bool RemoveAPI(const TfToken& schemaIdentifier,
1218  const TfToken& instanceName) const;
1219 
1222  USD_API
1223  bool RemoveAPI(const TfToken& schemaFamily,
1224  UsdSchemaVersion schemaVersion) const;
1225 
1229  USD_API
1230  bool RemoveAPI(const TfToken& schemaFamily,
1231  UsdSchemaVersion schemaVersion,
1232  const TfToken& instanceName) const;
1233 
1235 
1259  USD_API
1260  bool AddAppliedSchema(const TfToken &appliedSchemaName) const;
1261 
1286  USD_API
1287  bool RemoveAppliedSchema(const TfToken &appliedSchemaName) const;
1288 
1289  // --------------------------------------------------------------------- //
1291  // --------------------------------------------------------------------- //
1292 
1298  USD_API
1299  UsdPrim GetChild(const TfToken &name) const;
1300 
1309  inline SiblingRange GetChildren() const;
1310 
1312  inline SiblingRange GetAllChildren() const;
1313 
1333  inline SiblingRange
1334  GetFilteredChildren(const Usd_PrimFlagsPredicate &predicate) const;
1335 
1338  USD_API
1340 
1343  USD_API
1345 
1348  USD_API
1350  const Usd_PrimFlagsPredicate &predicate) const;
1351 
1364  inline SubtreeRange GetDescendants() const;
1365 
1374  inline SubtreeRange GetAllDescendants() const;
1375 
1399  inline SubtreeRange
1400  GetFilteredDescendants(const Usd_PrimFlagsPredicate &predicate) const;
1401 
1407  USD_API
1409 
1412  void SetChildrenReorder(const TfTokenVector &order) const {
1413  SetMetadata(SdfFieldKeys->PrimOrder, order);
1414  }
1415 
1418  void ClearChildrenReorder() const {
1419  ClearMetadata(SdfFieldKeys->PrimOrder);
1420  }
1421 
1422 public:
1423  // --------------------------------------------------------------------- //
1425  // --------------------------------------------------------------------- //
1426 
1429  UsdPrim GetParent() const {
1430  Usd_PrimDataConstPtr prim = get_pointer(_Prim());
1431  SdfPath proxyPrimPath = _ProxyPrimPath();
1432  Usd_MoveToParent(prim, proxyPrimPath);
1433  return UsdPrim(prim, proxyPrimPath);
1434  }
1435 
1444  USD_API
1445  UsdPrim GetNextSibling() const;
1446 
1452  USD_API
1454  const Usd_PrimFlagsPredicate &predicate) const;
1455 
1462  USD_API
1463  bool IsPseudoRoot() const;
1464 
1468  USD_API UsdPrim GetPrimAtPath(const SdfPath& path) const;
1469 
1473  USD_API UsdObject GetObjectAtPath(const SdfPath& path) const;
1474 
1483  USD_API UsdProperty GetPropertyAtPath(const SdfPath& path) const;
1484 
1493  USD_API UsdAttribute GetAttributeAtPath(const SdfPath& path) const;
1494 
1503  USD_API UsdRelationship GetRelationshipAtPath(const SdfPath& path) const;
1504 
1505  // --------------------------------------------------------------------- //
1507  // --------------------------------------------------------------------- //
1508 
1514  USD_API
1516 
1524  USD_API
1525  UsdVariantSet GetVariantSet(const std::string& variantSetName) const;
1526 
1532  USD_API
1533  bool HasVariantSets() const;
1534 
1535  // --------------------------------------------------------------------- //
1537  // --------------------------------------------------------------------- //
1538 
1578  USD_API
1579  UsdAttribute
1580  CreateAttribute(const TfToken& name,
1581  const SdfValueTypeName &typeName,
1582  bool custom,
1583  SdfVariability variability = SdfVariabilityVarying) const;
1586  USD_API
1587  UsdAttribute
1588  CreateAttribute(const TfToken& name,
1589  const SdfValueTypeName &typeName,
1590  SdfVariability variability = SdfVariabilityVarying) const;
1591 
1596  USD_API
1598  const std::vector<std::string> &nameElts,
1599  const SdfValueTypeName &typeName,
1600  bool custom,
1601  SdfVariability variability = SdfVariabilityVarying) const;
1605  USD_API
1607  const std::vector<std::string> &nameElts,
1608  const SdfValueTypeName &typeName,
1609  SdfVariability variability = SdfVariabilityVarying) const;
1610 
1612  USD_API
1613  std::vector<UsdAttribute> GetAttributes() const;
1614 
1617  USD_API
1618  std::vector<UsdAttribute> GetAuthoredAttributes() const;
1619 
1632  USD_API
1633  UsdAttribute GetAttribute(const TfToken& attrName) const;
1634 
1637  USD_API
1638  bool HasAttribute(const TfToken& attrName) const;
1639 
1645  USD_API
1646  SdfPathVector
1648  std::function<bool (UsdAttribute const &)> const &pred = nullptr,
1649  bool recurseOnSources = false) const;
1650 
1651  // --------------------------------------------------------------------- //
1653  // --------------------------------------------------------------------- //
1654 
1691  USD_API
1693  bool custom=true) const;
1694 
1699  USD_API
1700  UsdRelationship CreateRelationship(const std::vector<std::string> &nameElts,
1701  bool custom=true)
1702  const;
1703 
1705  USD_API
1706  std::vector<UsdRelationship> GetRelationships() const;
1707 
1710  USD_API
1711  std::vector<UsdRelationship> GetAuthoredRelationships() const;
1712 
1725  USD_API
1726  UsdRelationship GetRelationship(const TfToken& relName) const;
1727 
1730  USD_API
1731  bool HasRelationship(const TfToken& relName) const;
1732 
1739  USD_API
1740  SdfPathVector
1742  std::function<bool (UsdRelationship const &)> const &pred = nullptr,
1743  bool recurseOnTargets = false) const;
1744 
1745  // --------------------------------------------------------------------- //
1752  // --------------------------------------------------------------------- //
1753 
1757  USD_API
1758  bool ClearPayload() const;
1759 
1764  USD_API
1765  bool HasPayload() const;
1766 
1772  USD_API
1773  bool SetPayload(const SdfPayload& payload) const;
1774 
1777  USD_API
1778  bool SetPayload(
1779  const std::string& assetPath, const SdfPath& primPath) const;
1780 
1784  USD_API
1785  bool SetPayload(const SdfLayerHandle& layer, const SdfPath& primPath) const;
1786 
1788 
1789  // --------------------------------------------------------------------- //
1791  // --------------------------------------------------------------------- //
1792 
1800  USD_API
1801  UsdPayloads GetPayloads() const;
1802 
1804  USD_API
1805  bool HasAuthoredPayloads() const;
1806 
1812  USD_API
1813  void Load(UsdLoadPolicy policy = UsdLoadWithDescendants) const;
1814 
1818  USD_API
1819  void Unload() const;
1820 
1821  // --------------------------------------------------------------------- //
1823  // --------------------------------------------------------------------- //
1824 
1834  USD_API
1835  UsdReferences GetReferences() const;
1836 
1838  USD_API
1839  bool HasAuthoredReferences() const;
1840 
1841  // --------------------------------------------------------------------- //
1843  // --------------------------------------------------------------------- //
1844 
1854  USD_API
1855  UsdInherits GetInherits() const;
1856 
1858  USD_API
1859  bool HasAuthoredInherits() const;
1860 
1861  // --------------------------------------------------------------------- //
1863  // --------------------------------------------------------------------- //
1864 
1872  USD_API
1874 
1876  USD_API
1877  bool HasAuthoredSpecializes() const;
1878 
1879  // --------------------------------------------------------------------- //
1883  // --------------------------------------------------------------------- //
1884 
1891  bool IsInstanceable() const {
1892  bool instanceable = false;
1893  return GetMetadata(SdfFieldKeys->Instanceable, &instanceable) &&
1894  instanceable;
1895  }
1896 
1899  bool SetInstanceable(bool instanceable) const {
1900  return SetMetadata(SdfFieldKeys->Instanceable, instanceable);
1901  }
1902 
1905  bool ClearInstanceable() const {
1906  return ClearMetadata(SdfFieldKeys->Instanceable);
1907  }
1908 
1912  return HasAuthoredMetadata(SdfFieldKeys->Instanceable);
1913  }
1914 
1920  bool IsInstance() const { return _Prim()->IsInstance(); }
1921 
1925  bool IsInstanceProxy() const {
1926  return Usd_IsInstanceProxy(_Prim(), _ProxyPrimPath());
1927  }
1928 
1936  USD_API
1937  static bool IsPrototypePath(const SdfPath& path);
1938 
1943  USD_API
1944  static bool IsPathInPrototype(const SdfPath& path);
1945 
1950  bool IsPrototype() const { return _Prim()->IsPrototype(); }
1951 
1956  bool IsInPrototype() const {
1957  return (IsInstanceProxy() ?
1958  IsPathInPrototype(GetPrimPath()) : _Prim()->IsInPrototype());
1959  }
1960 
1963  USD_API
1964  UsdPrim GetPrototype() const;
1965 
1970  if (IsInstanceProxy()) {
1971  return UsdPrim(_Prim(), SdfPath());
1972  }
1973  return UsdPrim();
1974  }
1975 
1981  USD_API
1982  std::vector<UsdPrim> GetInstances() const;
1984 
1985  // --------------------------------------------------------------------- //
1988  // --------------------------------------------------------------------- //
1989 
2012  const PcpPrimIndex &GetPrimIndex() const { return _Prim()->GetPrimIndex(); }
2013 
2034  USD_API
2036 
2044  USD_API
2046  const UsdEditTarget &editTarget) const;
2047 
2055  USD_API
2057  const UsdEditTarget &editTarget) const;
2058 
2060 
2061 private:
2062  friend class UsdObject;
2063  friend class UsdPrimSiblingIterator;
2064  friend class UsdPrimSubtreeIterator;
2065  friend class UsdProperty;
2066  friend class UsdSchemaBase;
2067  friend class UsdAPISchemaBase;
2068  friend class UsdStage;
2069  friend class UsdPrimRange;
2070  friend class Usd_PrimData;
2071  friend class Usd_PrimFlagsPredicate;
2072  friend struct UsdPrim_RelTargetFinder;
2073  friend struct UsdPrim_AttrConnectionFinder;
2074 
2075  // Prim constructor.
2076  UsdPrim(const Usd_PrimDataHandle &primData,
2077  const SdfPath &proxyPrimPath)
2078  : UsdObject(primData, proxyPrimPath) { }
2079 
2080  // General constructor.
2081  UsdPrim(UsdObjType objType,
2082  const Usd_PrimDataHandle &prim,
2083  const SdfPath &proxyPrimPath,
2084  const TfToken &propName)
2085  : UsdObject(objType, prim, proxyPrimPath, propName) {}
2086 
2087  // Helper to make a sibling range.
2088  inline SiblingRange
2089  _MakeSiblingRange(const Usd_PrimFlagsPredicate &pred) const;
2090 
2091  // Helper to make a range of descendants.
2092  inline SubtreeRange
2093  _MakeDescendantsRange(const Usd_PrimFlagsPredicate &pred) const;
2094 
2095  // Helper to make a vector of properties from names.
2096  std::vector<UsdProperty>
2097  _MakeProperties(const TfTokenVector &names) const;
2098 
2099  // Helper for Get{Authored}{PropertyNames,Properties}
2100  TfTokenVector _GetPropertyNames(
2101  bool onlyAuthored,
2102  bool applyOrder=true,
2103  const PropertyPredicateFunc &predicate={}) const;
2104 
2105  // Helper for Get(Authored)PropertiesInNamespace.
2106  std::vector<UsdProperty>
2107  _GetPropertiesInNamespace(const std::string &namespaces,
2108  bool onlyAuthored) const;
2109 
2110  // Helper for Get(Authored)Attributes.
2111  std::vector<UsdAttribute>
2112  _GetAttributes(bool onlyAuthored, bool applyOrder=false) const;
2113 
2114  // Helper for Get(Authored)Relationships.
2115  std::vector<UsdRelationship>
2116  _GetRelationships(bool onlyAuthored, bool applyOrder=false) const;
2117 
2118  friend const PcpPrimIndex &Usd_PrimGetSourcePrimIndex(const UsdPrim&);
2119  // Return a const reference to the source PcpPrimIndex for this prim.
2120  //
2121  // For all prims in prototypes (which includes the prototype prim itself),
2122  // this is the prim index for the instance that was chosen to serve
2123  // as the prototype for all other instances. This prim index will not
2124  // have the same path as the prim's path.
2125  //
2126  // This is a private helper but is also wrapped out to Python
2127  // for testing and debugging purposes.
2128  const PcpPrimIndex &_GetSourcePrimIndex() const
2129  { return _Prim()->GetSourcePrimIndex(); }
2130 
2131  // Helper function for MakeResolveTargetUpToEditTarget and
2132  // MakeResolveTargetStrongerThanEditTarget.
2134  _MakeResolveTargetFromEditTarget(
2135  const UsdEditTarget &editTarget,
2136  bool makeAsStrongerThan) const;
2137 };
2138 
2139 #ifdef doxygen
2140 
2144 public:
2150  typedef unspecified-integral-type difference_type;
2152  reference operator*() const;
2154  unspecified-type operator->() const;
2159 private:
2161  friend bool operator==(const UsdPrimSiblingIterator &lhs,
2162  const UsdPrimSiblingIterator &rhs);
2164  friend bool operator!=(const UsdPrimSiblingIterator &lhs,
2165  const UsdPrimSiblingIterator &rhs);
2166 };
2167 
2173 public:
2179  typedef unspecified-integral-type difference_type;
2184 
2188 
2190  template <class ForwardRange>
2191  UsdPrimSiblingRange(const ForwardRange &r);
2192 
2194  template <class ForwardRange>
2195  UsdPrimSiblingRange &operator=(const ForwardRange &r);
2196 
2198  iterator begin() const;
2199 
2201  iterator end() const;
2202 
2204  operator unspecified_bool_type() const;
2205 
2207  bool equal(const iterator_range&) const;
2208 
2210  reference front() const;
2211 
2213  iterator_range& advance_begin(difference_type n);
2214 
2216  iterator_range& advance_end(difference_type n);
2217 
2218  ;
2219  bool empty() const;
2220 
2221 private:
2223  friend bool operator==(const UsdPrimSiblingRange &lhs,
2224  const UsdPrimSiblingRange &rhs);
2226  friend bool operator!=(const UsdPrimSiblingRange &lhs,
2227  const UsdPrimSiblingRange &rhs);
2228 };
2229 
2230 #else
2231 
2232 // Sibling iterator class. Converts ref to weak and filters according to a
2233 // supplied predicate.
2234 class UsdPrimSiblingIterator : public boost::iterator_adaptor<
2235  UsdPrimSiblingIterator, // crtp base.
2236  const Usd_PrimData *, // base iterator.
2237  UsdPrim, // value type.
2238  boost::forward_traversal_tag, // traversal
2239  UsdPrim> // reference type.
2240 {
2241 public:
2242  // Default ctor.
2244 
2245 private:
2246  friend class UsdPrim;
2247 
2248  // Constructor used by Prim.
2249  UsdPrimSiblingIterator(const base_type &i, const SdfPath& proxyPrimPath,
2250  const Usd_PrimFlagsPredicate &predicate)
2251  : iterator_adaptor_(i)
2252  , _proxyPrimPath(proxyPrimPath)
2253  , _predicate(predicate) {
2254  // Need to advance iterator to first matching element.
2255  if (base() && !Usd_EvalPredicate(_predicate, base(), _proxyPrimPath))
2256  increment();
2257  }
2258 
2259  // Core implementation invoked by iterator_adaptor.
2260  friend class boost::iterator_core_access;
2261  bool equal(const UsdPrimSiblingIterator &other) const {
2262  return base() == other.base() &&
2263  _proxyPrimPath == other._proxyPrimPath &&
2264  _predicate == other._predicate;
2265  }
2266 
2267  void increment() {
2268  base_type &base = base_reference();
2269  if (Usd_MoveToNextSiblingOrParent(base, _proxyPrimPath, _predicate)) {
2270  base = nullptr;
2271  _proxyPrimPath = SdfPath();
2272  }
2273  }
2274 
2275  reference dereference() const {
2276  return UsdPrim(base(), _proxyPrimPath);
2277  }
2278 
2279  SdfPath _proxyPrimPath;
2280  Usd_PrimFlagsPredicate _predicate;
2281 };
2282 
2283 // Typedef iterator range.
2284 typedef boost::iterator_range<UsdPrimSiblingIterator> UsdPrimSiblingRange;
2285 
2286 // Inform TfIterator it should feel free to make copies of the range type.
2287 template <>
2288 struct Tf_ShouldIterateOverCopy<
2289  UsdPrimSiblingRange> : boost::true_type {};
2290 template <>
2291 struct Tf_ShouldIterateOverCopy<
2292  const UsdPrimSiblingRange> : boost::true_type {};
2293 
2294 #endif // doxygen
2295 
2296 
2298 UsdPrim::GetFilteredChildren(const Usd_PrimFlagsPredicate &pred) const
2299 {
2300  return _MakeSiblingRange(
2301  Usd_CreatePredicateForTraversal(_Prim(), _ProxyPrimPath(), pred));
2302 }
2303 
2306 {
2308 }
2309 
2312 {
2314 }
2315 
2316 // Helper to make a sibling range.
2318 UsdPrim::_MakeSiblingRange(const Usd_PrimFlagsPredicate &pred) const {
2319  Usd_PrimDataConstPtr firstChild = get_pointer(_Prim());
2320  SdfPath firstChildPath = _ProxyPrimPath();
2321  if (!Usd_MoveToChild(firstChild, firstChildPath, pred)) {
2322  firstChild = nullptr;
2323  firstChildPath = SdfPath();
2324  }
2325 
2326  return SiblingRange(
2327  SiblingIterator(firstChild, firstChildPath, pred),
2328  SiblingIterator(nullptr, SdfPath(), pred));
2329 }
2330 
2331 #ifdef doxygen
2332 
2336 public:
2342  typedef unspecified-integral-type difference_type;
2344  reference operator*() const;
2346  unspecified-type operator->() const;
2351 private:
2353  friend bool operator==(const UsdPrimSubtreeIterator &lhs,
2354  const UsdPrimSubtreeIterator &rhs);
2356  friend bool operator!=(const UsdPrimSubtreeIterator &lhs,
2357  const UsdPrimSubtreeIterator &rhs);
2358 };
2359 
2365 public:
2371  typedef unspecified-integral-type difference_type;
2376 
2380 
2382  template <class ForwardRange>
2383  UsdPrimSubtreeRange(const ForwardRange &r);
2384 
2386  template <class ForwardRange>
2387  UsdPrimSubtreeRange &operator=(const ForwardRange &r);
2388 
2390  iterator begin() const;
2391 
2393  iterator end() const;
2394 
2396  operator unspecified_bool_type() const;
2397 
2399  bool equal(const iterator_range&) const;
2400 
2402  reference front() const;
2403 
2405  iterator_range& advance_begin(difference_type n);
2406 
2408  iterator_range& advance_end(difference_type n);
2409 
2411  bool empty() const;
2412 
2413 private:
2415  friend bool operator==(const UsdPrimSubtreeRange &lhs,
2416  const UsdPrimSubtreeRange &rhs);
2418  friend bool operator!=(const UsdPrimSubtreeRange &lhs,
2419  const UsdPrimSubtreeRange &rhs);
2420 };
2421 
2422 #else
2423 
2424 // Subtree iterator class. Converts ref to weak and filters according to a
2425 // supplied predicate.
2426 class UsdPrimSubtreeIterator : public boost::iterator_adaptor<
2427  UsdPrimSubtreeIterator, // crtp base.
2428  const Usd_PrimData *, // base iterator.
2429  UsdPrim, // value type.
2430  boost::forward_traversal_tag, // traversal
2431  UsdPrim> // reference type.
2432 {
2433 public:
2434  // Default ctor.
2436 
2437 private:
2438  friend class UsdPrim;
2439 
2440  // Constructor used by Prim.
2441  UsdPrimSubtreeIterator(const base_type &i, const SdfPath &proxyPrimPath,
2442  const Usd_PrimFlagsPredicate &predicate)
2443  : iterator_adaptor_(i)
2444  , _proxyPrimPath(proxyPrimPath)
2445  , _predicate(predicate) {
2446  // Need to advance iterator to first matching element.
2447  base_type &base = base_reference();
2448  if (base && !Usd_EvalPredicate(_predicate, base, _proxyPrimPath)) {
2449  if (Usd_MoveToNextSiblingOrParent(base, _proxyPrimPath,
2450  _predicate)) {
2451  base = nullptr;
2452  _proxyPrimPath = SdfPath();
2453  }
2454  }
2455  }
2456 
2457  // Core implementation invoked by iterator_adaptor.
2458  friend class boost::iterator_core_access;
2459  bool equal(const UsdPrimSubtreeIterator &other) const {
2460  return base() == other.base() &&
2461  _proxyPrimPath == other._proxyPrimPath &&
2462  _predicate == other._predicate;
2463  }
2464 
2465  void increment() {
2466  base_type &base = base_reference();
2467  if (!Usd_MoveToChild(base, _proxyPrimPath, _predicate)) {
2468  while (Usd_MoveToNextSiblingOrParent(base, _proxyPrimPath,
2469  _predicate)) {}
2470  }
2471  }
2472 
2473  reference dereference() const {
2474  return UsdPrim(base(), _proxyPrimPath);
2475  }
2476 
2477  SdfPath _proxyPrimPath;
2478  Usd_PrimFlagsPredicate _predicate;
2479 };
2480 
2481 // Typedef iterator range.
2482 typedef boost::iterator_range<UsdPrimSubtreeIterator> UsdPrimSubtreeRange;
2483 
2484 // Inform TfIterator it should feel free to make copies of the range type.
2485 template <>
2486 struct Tf_ShouldIterateOverCopy<
2487  UsdPrimSubtreeRange> : boost::true_type {};
2488 template <>
2489 struct Tf_ShouldIterateOverCopy<
2490  const UsdPrimSubtreeRange> : boost::true_type {};
2491 
2492 #endif // doxygen
2493 
2495 UsdPrim::GetFilteredDescendants(const Usd_PrimFlagsPredicate &pred) const
2496 {
2497  return _MakeDescendantsRange(
2498  Usd_CreatePredicateForTraversal(_Prim(), _ProxyPrimPath(), pred));
2499 }
2500 
2503 {
2505 }
2506 
2509 {
2511 }
2512 
2513 // Helper to make a sibling range.
2515 UsdPrim::_MakeDescendantsRange(const Usd_PrimFlagsPredicate &pred) const {
2516  Usd_PrimDataConstPtr firstChild = get_pointer(_Prim());
2517  SdfPath firstChildPath = _ProxyPrimPath();
2518  Usd_PrimDataConstPtr endChild = firstChild;
2519  SdfPath endChildPath = firstChildPath;
2520  if (Usd_MoveToChild(firstChild, firstChildPath, pred)) {
2521  while (Usd_MoveToNextSiblingOrParent(endChild, endChildPath, pred)) {}
2522  }
2523 
2524  return SubtreeRange(
2525  SubtreeIterator(firstChild, firstChildPath, pred),
2526  SubtreeIterator(endChild, endChildPath, pred));
2527 }
2528 
2529 
2531 // UsdObject methods that require UsdPrim be a complete type.
2532 
2533 inline UsdPrim
2535 {
2536  return UsdPrim(_prim, _proxyPrimPath);
2537 }
2538 
2539 PXR_NAMESPACE_CLOSE_SCOPE
2540 
2541 #endif // PXR_USD_USD_PRIM_H
2542 
const UsdPrimTypeInfo & GetPrimTypeInfo() const
Return the prim's full type info composed from its type name, applied API schemas,...
Definition: prim.h:158
void ClearPropertyOrder() const
Remove the opinion for propertyOrder metadata on this prim at the current EditTarget.
Definition: prim.h:457
A proxy class for applying listOp edits to the specializes list for a prim.
Definition: specializes.h:51
bool SetMetadata(const TfToken &key, const T &value) const
Set metadatum key's value to value.
Definition: object.h:755
iterator::value_type value_type
Iterator value_type.
Definition: prim.h:2373
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:829
unspecified integral type difference_type
Iterator difference type.
Definition: prim.h:2342
USD_API bool HasAttribute(const TfToken &attrName) const
Return true if this prim has an attribute named attrName, false otherwise.
UsdObjType
Enum values to represent the various Usd object types.
Definition: object.h:49
bool SetSpecifier(SdfSpecifier specifier) const
Author an opinion for this Prim's specifier at the current edit target.
Definition: prim.h:206
USD_API bool HasAuthoredPayloads() const
Return true if this prim has any authored payloads.
USD_API bool AddAppliedSchema(const TfToken &appliedSchemaName) const
Adds the applied API schema name token appliedSchemaName to the apiSchemas metadata for this prim at ...
bool empty() const
Return begin() == end().
PcpPrimIndex is an index of the all sites of scene description that contribute opinions to a specific...
Definition: primIndex.h:76
bool CanApplyAPI(std::string *whyNot=nullptr) const
Returns whether a single-apply API schema with the given C++ type SchemaType can be applied to this p...
Definition: prim.h:941
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:2495
value_type reference
Iterator reference type, in this case the same as value_type.
Definition: prim.h:2340
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:967
bool IsGroup() const
Return true if this prim is a model group based on its kind metadata, false otherwise.
Definition: prim.h:278
SdfSpecifier GetSpecifier() const
Return this prim's composed specifier.
Definition: prim.h:170
UsdPrimSiblingIterator iterator
Iterator type.
Definition: prim.h:2175
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:1412
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:2146
bool IsActive() const
Return true if this prim is active, meaning neither it nor any of its ancestors have active=false.
Definition: prim.h:239
bool ClearInstanceable() const
Remove the authored 'instanceable' opinion at the current EditTarget.
Definition: prim.h:1905
bool HasAuthoredInstanceable() const
Return true if this prim has an authored opinion for 'instanceable', false otherwise.
Definition: prim.h:1911
friend bool operator!=(const UsdPrimSiblingIterator &lhs, const UsdPrimSiblingIterator &rhs)
Inequality.
USD_API UsdReferences GetReferences() const
Return a UsdReferences object that allows one to add, remove, or mutate references at the currently s...
USD_API std::vector< UsdProperty > GetProperties(const PropertyPredicateFunc &predicate={}) const
Return all of this prim's properties (attributes and relationships), including all builtin properties...
bool empty() const
Return begin() == end().
SubtreeRange GetDescendants() const
Return this prim's active, loaded, defined, non-abstract descendants as an iterable range.
Definition: prim.h:2508
The outermost container for scene description, which owns and presents composed prims as a scenegraph...
Definition: stage.h:147
friend bool operator==(const UsdPrimSiblingRange &lhs, const UsdPrimSiblingRange &rhs)
Equality comparison.
Represents a value type name, i.e.
Definition: valueTypeName.h:87
Load a prim plus all its descendants.
Definition: common.h:118
bool IsInstanceable() const
Return true if this prim has been marked as instanceable.
Definition: prim.h:1891
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:816
unspecified integral type difference_type
Iterator difference type.
Definition: prim.h:2179
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:597
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:1920
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:1956
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:2172
UsdReferences provides an interface to authoring and introspecting references in Usd.
Definition: references.h:214
USD_API UsdAttribute GetAttribute(const TfToken &attrName) const
Return a UsdAttribute with the name attrName.
USD_API bool HasAuthoredReferences() const
Return true if this prim has any authored references.
UsdPrimSubtreeIterator iterator
Iterator type.
Definition: prim.h:2367
iterator::value_type value_type
Iterator value_type.
Definition: prim.h:2181
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:711
void SetPropertyOrder(const TfTokenVector &order) const
Author an opinion for propertyOrder metadata on this prim at the current EditTarget.
Definition: prim.h:451
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
bool SetInstanceable(bool instanceable) const
Author 'instanceable' metadata for this prim at the current EditTarget.
Definition: prim.h:1899
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:1152
reference operator *() const
Dereference.
unspecified integral type difference_type
Iterator difference type.
Definition: prim.h:2150
iterator_range & advance_end(difference_type n)
Advance this range's end iterator.
USD_API bool ClearMetadata(const TfToken &key) const
Clears the authored key's value at the current EditTarget, returning false on error.
iterator begin() const
First iterator.
const UsdPrimDefinition & GetPrimDefinition() const
Return this prim's definition based on the prim's type if the type is a registered prim type.
Definition: prim.h:165
UsdPrimSiblingRange(UsdPrimSiblingIterator begin, UsdPrimSiblingIterator end)
Construct with a pair of iterators.
const PcpPrimIndex & GetPrimIndex() const
Return the cached prim index containing all sites that can contribute opinions to this prim.
Definition: prim.h:2012
UsdPrimSubtreeIterator & operator++()
Postincrement.
bool IsAbstract() const
Return true if this prim or any of its ancestors is a class.
Definition: prim.h:281
USD_API TfTokenVector GetAuthoredPropertyNames(const PropertyPredicateFunc &predicate={}) const
Return this prim's property names (attributes and relationships) that have authored scene description...
USD_API bool HasProperty(const TfToken &propName) const
Return true if this prim has an property named propName, false otherwise.
USD_API bool SetPayload(const SdfPayload &payload) const
USD_API std::vector< UsdProperty > GetPropertiesInNamespace(const std::vector< std::string > &namespaces) const
Return this prim's properties that are inside the given property namespace ordered according to the s...
A UsdVariantSet represents a single VariantSet in USD (e.g.
Definition: variantSets.h:56
bool ApplyAPI() const
Applies a single-apply API schema with the given C++ type SchemaType to this prim in the current edit...
Definition: prim.h:1048
Forward iterator range of sibling UsdPrim s.
Definition: prim.h:2364
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:1429
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:2298
SiblingRange GetChildren() const
Return this prim's active, loaded, defined, non-abstract children as an iterable range.
Definition: prim.h:2311
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:130
Defines a mapping from scene graph paths to Sdf spec paths in a SdfLayer where edits should be direct...
Definition: editTarget.h:78
Represents a payload and all its meta data.
Definition: payload.h:60
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:134
UsdPrimSiblingRange & operator=(const ForwardRange &r)
Assign from another compatible range type.
bool IsA() const
Return true if the prim's schema type, is or inherits from the TfType of the schema class type Schema...
Definition: prim.h:551
SdfSpecifier
An enum that identifies the possible specifiers for an SdfPrimSpec.
Definition: types.h:123
UsdPrim value_type
Iterator value type.
Definition: prim.h:2338
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:1925
UsdPrimSubtreeRange & operator=(const ForwardRange &r)
Assign from another compatible range type.
const TfToken & GetTypeName() const
Return this prim's composed type name.
Definition: prim.h:217
SubtreeRange GetAllDescendants() const
Return all this prim's descendants as an iterable range.
Definition: prim.h:2502
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:691
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:747
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:2375
USD_API bool HasPayload() const
USD_API UsdResolveTarget MakeResolveTargetStrongerThanEditTarget(const UsdEditTarget &editTarget) const
Creates and returns a resolve target that, when passed to a UsdAttributeQuery for one of this prim's ...
UsdPayloads provides an interface to authoring and introspecting payloads.
Definition: payloads.h:43
bool HasAuthoredActive() const
Return true if this prim has an authored opinion for 'active', false otherwise.
Definition: prim.h:262
A UsdRelationship creates dependencies between scenegraph objects by allowing a prim to target other ...
Definition: relationship.h:128
USD_API TfTokenVector GetPropertyNames(const PropertyPredicateFunc &predicate={}) const
Return all of this prim's property names (attributes and relationships), including all builtin proper...
USD_API SdfPathVector FindAllAttributeConnectionPaths(std::function< bool(UsdAttribute const &)> const &pred=nullptr, bool recurseOnSources=false) const
Search the prim subtree rooted at this prim for attributes for which predicate returns true,...
USD_API UsdRelationship GetRelationshipAtPath(const SdfPath &path) const
Returns the relationship at path on the same stage as this prim.
unspecified type operator->() const
Indirection.
USD_API void Unload() const
Unloads this prim and all its descendants.
SdfVariability
An enum that identifies variability types for attributes.
Definition: types.h:179
bool ClearTypeName() const
Clear the opinion for this Prim's typeName at the current edit target.
Definition: prim.h:226
Class that holds the full type information for a prim.
Definition: primTypeInfo.h:47
SiblingRange GetAllChildren() const
Return all this prim's children as an iterable range.
Definition: prim.h:2305
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:1186
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:1969
Base class for UsdAttribute and UsdRelationship scenegraph objects.
Definition: property.h:55
USD_API std::vector< std::pair< SdfPrimSpecHandle, SdfLayerOffset > > GetPrimStackWithLayerOffsets() const
Return all the authored SdfPrimSpecs that may contain opinions for this prim in order from strong to ...
bool ClearActive() const
Remove the authored 'active' opinion at the current EditTarget.
Definition: prim.h:254
bool SetTypeName(const TfToken &typeName) const
Author this Prim's typeName at the current EditTarget.
Definition: prim.h:220
An forward-iterable range that traverses a subtree of prims rooted at a given prim in depth-first ord...
Definition: primRange.h:118
const SdfPath & GetPrimPath() const
Return this object's path if this object is a prim, otherwise this object's nearest owning prim's pat...
Definition: object.h:209
bool HasAuthoredTypeName() const
Return true if a typeName has been authored.
Definition: prim.h:231
void ClearChildrenReorder() const
Remove the opinion for the metadata used to reorder children of this prim at the current EditTarget.
Definition: prim.h:1418
bool IsModel() const
Return true if this prim is a model based on its kind metadata, false otherwise.
Definition: prim.h:273
bool IsLoaded() const
Return true if this prim is active, and either it is loadable and it is loaded, or its nearest loadab...
Definition: prim.h:269
unspecified integral type difference_type
Iterator difference type.
Definition: prim.h:2371
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:1950
Forward traversal iterator of sibling UsdPrim s.
Definition: prim.h:2335
unspecified UsdPrimAllPrimsPredicate
Predicate that includes all prims.
iterator begin() const
First iterator.
USD_API bool RemoveAppliedSchema(const TfToken &appliedSchemaName) const
Removes the applied API schema name token appliedSchemaName from the apiSchemas metadata for this pri...
UsdPrim()
Construct an invalid prim.
Definition: prim.h:146
std::function< bool(const TfToken &propertyName)> PropertyPredicateFunc
Alias for the "predicate" function parameter passed into the various Get{Authored}{PropertyNames,...
Definition: prim.h:305
reference front() const
Return *begin(). This range must not be empty.
TfType represents a dynamic runtime type.
Definition: type.h:64
UsdPrimSubtreeIterator SubtreeIterator
Convenience typedefs.
Definition: prim.h:142
bool IsDefined() const
Return true if this prim and all its ancestors have defining specifiers, false otherwise.
Definition: prim.h:285
USD_API SdfPrimSpecHandleVector GetPrimStack() const
Return all the authored SdfPrimSpecs that may contain opinions for this prim in order from strong to ...
bool equal(const iterator_range &) const
Equality compare.
USD_API TfTokenVector GetAppliedSchemas() const
Return a vector containing the names of API schemas which have been applied to this prim.
UsdPrimSiblingIterator SiblingIterator
Convenience typedefs.
Definition: prim.h:138
USD_API UsdSpecializes GetSpecializes() const
Return a UsdSpecializes object that allows one to add, remove, or mutate specializes at the currently...
USD_API UsdPrim GetPrimAtPath(const SdfPath &path) const
Returns the prim at path on the same stage as this prim.
UsdPrimSiblingIterator const_iterator
Const iterator type.
Definition: prim.h:2177
USD_API UsdObject GetObjectAtPath(const SdfPath &path) const
Returns the object at path on the same stage as this prim.
UsdVariantSets represents the collection of VariantSets that are present on a UsdPrim.
Definition: variantSets.h:222
iterator end() const
Past-the-end iterator.
bool SetActive(bool active) const
Author 'active' metadata for this prim at the current EditTarget.
Definition: prim.h:245
UsdPrimSubtreeIterator const_iterator
Const iterator type.
Definition: prim.h:2369
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:2183
Forward traversal iterator of sibling UsdPrim s.
Definition: prim.h:2143
USD_API UsdAttribute GetAttributeAtPath(const SdfPath &path) const
Returns the attribute at path on the same stage as this prim.
USD_API UsdPrim GetNextSibling() const
Return this prim's next active, loaded, defined, non-abstract sibling if it has one,...
USD_API UsdProperty GetPropertyAtPath(const SdfPath &path) const
Returns the property at path on the same stage as this prim.
USD_API TfTokenVector GetFilteredChildrenNames(const Usd_PrimFlagsPredicate &predicate) const
Return the names of the child prims in the order they appear when iterating over GetFilteredChildren(...
USD_API UsdPayloads GetPayloads() const
Return a UsdPayloads object that allows one to add, remove, or mutate payloads at the currently set U...
iterator_range & advance_end(difference_type n)
Advance this range's end iterator.
UsdPrim GetPrim() const
Return this object if it is a prim, otherwise return this object's nearest owning prim.
Definition: prim.h:2534
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:2148
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:1081
USD_API std::vector< UsdAttribute > GetAuthoredAttributes() const
Like GetAttributes(), but exclude attributes without authored scene description from the result.
iterator_range & advance_begin(difference_type n)
Advance this range's begin iterator.
Defines a subrange of nodes and layers within a prim's prim index to consider when performing value r...
Definition: resolveTarget.h:73
bool HasDefiningSpecifier() const
Return true if this prim has a specifier of type SdfSpecifierDef or SdfSpecifierClass.
Definition: prim.h:289
USD_API std::vector< UsdProperty > GetAuthoredProperties(const PropertyPredicateFunc &predicate={}) const
Return this prim's properties (attributes and relationships) that have authored scene description,...