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 UsdRelationship;
61 class UsdPayloads;
62 class UsdReferences;
63 class UsdSchemaBase;
64 class UsdAPISchemaBase;
65 class UsdInherits;
66 class UsdSpecializes;
67 class UsdVariantSets;
68 class UsdVariantSet;
69 
70 class SdfPayload;
71 
73 typedef boost::iterator_range<UsdPrimSiblingIterator> UsdPrimSiblingRange;
74 
76 typedef boost::iterator_range<UsdPrimSubtreeIterator> UsdPrimSubtreeRange;
77 
132 class UsdPrim : public UsdObject
133 {
134 public:
138 
142 
144  UsdPrim() : UsdObject(_Null<UsdPrim>()) {}
145 
155  return _Prim()->GetPrimTypeInfo();
156  }
157 
162  return _Prim()->GetPrimDefinition();
163  }
164 
166  SdfSpecifier GetSpecifier() const { return _Prim()->GetSpecifier(); };
167 
181  USD_API
182  SdfPrimSpecHandleVector GetPrimStack() const;
183 
186  bool SetSpecifier(SdfSpecifier specifier) const {
187  return SetMetadata(SdfFieldKeys->Specifier, specifier);
188  }
189 
197  const TfToken &GetTypeName() const { return _Prim()->GetTypeName(); };
198 
200  bool SetTypeName(const TfToken & typeName) const {
201  return SetMetadata(SdfFieldKeys->TypeName, typeName);
202  }
203 
206  bool ClearTypeName() const {
207  return ClearMetadata(SdfFieldKeys->TypeName);
208  }
209 
211  bool HasAuthoredTypeName() const {
212  return HasAuthoredMetadata(SdfFieldKeys->TypeName);
213  }
214 
219  bool IsActive() const { return _Prim()->IsActive(); }
220 
225  bool SetActive(bool active) const {
226  return SetMetadata(SdfFieldKeys->Active, active);
227  }
228 
234  bool ClearActive() const {
235  return ClearMetadata(SdfFieldKeys->Active);
236  }
237 
242  bool HasAuthoredActive() const {
243  return HasAuthoredMetadata(SdfFieldKeys->Active);
244  }
245 
249  bool IsLoaded() const { return _Prim()->IsLoaded(); }
250 
253  bool IsModel() const { return _Prim()->IsModel(); }
254 
258  bool IsGroup() const { return _Prim()->IsGroup(); }
259 
261  bool IsAbstract() const { return _Prim()->IsAbstract(); }
262 
265  bool IsDefined() const { return _Prim()->IsDefined(); }
266 
269  bool HasDefiningSpecifier() const {
270  return _Prim()->HasDefiningSpecifier();
271  }
272 
279  USD_API
281 
284  using PropertyPredicateFunc =
285  std::function<bool (const TfToken &propertyName)>;
286 
298  USD_API
300  const PropertyPredicateFunc &predicate={}) const;
301 
315  USD_API
317  const PropertyPredicateFunc &predicate={}) const;
318 
362  USD_API
363  std::vector<UsdProperty> GetProperties(
364  const PropertyPredicateFunc &predicate={}) const;
365 
379  USD_API
380  std::vector<UsdProperty> GetAuthoredProperties(
381  const PropertyPredicateFunc &predicate={}) const;
382 
394  USD_API
395  std::vector<UsdProperty>
396  GetPropertiesInNamespace(const std::vector<std::string> &namespaces) const;
397 
402  USD_API
403  std::vector<UsdProperty>
404  GetPropertiesInNamespace(const std::string &namespaces) const;
405 
411  USD_API
412  std::vector<UsdProperty>
414  const std::vector<std::string> &namespaces) const;
415 
421  USD_API
422  std::vector<UsdProperty>
423  GetAuthoredPropertiesInNamespace(const std::string &namespaces) const;
424 
426  USD_API
428 
431  void SetPropertyOrder(const TfTokenVector &order) const {
432  SetMetadata(SdfFieldKeys->PropertyOrder, order);
433  }
434 
437  void ClearPropertyOrder() const {
438  ClearMetadata(SdfFieldKeys->PropertyOrder);
439  }
440 
449  USD_API
450  bool RemoveProperty(const TfToken &propName);
451 
464  USD_API
465  UsdProperty GetProperty(const TfToken &propName) const;
466 
469  USD_API
470  bool HasProperty(const TfToken &propName) const;
471 
472 private:
473  // The non-templated implementation of UsdPrim::IsA using the
474  // TfType system. \p validateSchemaType is provided for python clients
475  // because they can't use compile time assertions on the input type.
476  USD_API
477  bool _IsA(const TfType& schemaType, bool validateSchemaType) const;
478 
479  // Separate implementations for UsdPrim::HasAPI for single and multiple
480  // apply API schema TfTypes.
481  USD_API
482  bool _HasSingleApplyAPI(const TfType& schemaType) const;
483 
484  USD_API
485  bool _HasMultiApplyAPI(const TfType& schemaType,
486  const TfToken &instanceName) const;
487 
488  // Private implementation for all ApplyAPI, CanApplyAPI, and RemoveAPI
489  // methods for both single apply and multiple apply APIs. The multiple
490  // apply API methods validate that the instance name is non-empty, but
491  // otherwise all of these methods do no other input validation as the
492  // public methods are expected to have already done either compile time or
493  // runtime validation already.
494  USD_API
495  bool _CanApplyAPI(const TfType& schemaType,
496  std::string *whyNot) const;
497 
498  USD_API
499  bool _CanApplyAPI(const TfType& schemaType,
500  const TfToken& instanceName,
501  std::string *whyNot) const;
502 
503  USD_API
504  bool _ApplyAPI(const TfType& schemaType) const;
505 
506  USD_API
507  bool _ApplyAPI(const TfType& schemaType,
508  const TfToken& instanceName) const;
509 
510  USD_API
511  bool _RemoveAPI(const TfType& schemaType) const;
512 
513  USD_API
514  bool _RemoveAPI(const TfType& schemaType,
515  const TfToken& instanceName) const;
516 
517 public:
522  template <typename T>
523  bool IsA() const {
524  static_assert(std::is_base_of<UsdSchemaBase, T>::value,
525  "Provided type must derive UsdSchemaBase.");
526  return _IsA(TfType::Find<T>(), /*validateSchemaType=*/false);
527  };
528 
533  USD_API
534  bool IsA(const TfType& schemaType) const;
535 
564 
569  template <typename T>
570  typename std::enable_if<T::schemaKind != UsdSchemaKind::MultipleApplyAPI,
571  bool>::type
572  HasAPI() const {
573  static_assert(std::is_base_of<UsdAPISchemaBase, T>::value,
574  "Provided type must derive UsdAPISchemaBase.");
575  static_assert(!std::is_same<UsdAPISchemaBase, T>::value,
576  "Provided type must not be UsdAPISchemaBase.");
577  // Note that this function template is enabled for any schema kind,
578  // other than MultipleApplyAPI, but is only valid for SingleApplyAPI.
579  // This static assert provides better error information for calling
580  // HasAPI with an invalid template type than if we limited HasAPI
581  // substitution matching to just the two valid schema kinds.
582  static_assert(T::schemaKind == UsdSchemaKind::SingleApplyAPI,
583  "Provided schema type must be a single apply API schema.");
584 
585  return _HasSingleApplyAPI(TfType::Find<T>());
586  }
587 
596  template <typename T>
597  typename std::enable_if<T::schemaKind == UsdSchemaKind::MultipleApplyAPI,
598  bool>::type
599  HasAPI(const TfToken &instanceName = TfToken()) const {
600  static_assert(std::is_base_of<UsdAPISchemaBase, T>::value,
601  "Provided type must derive UsdAPISchemaBase.");
602  static_assert(!std::is_same<UsdAPISchemaBase, T>::value,
603  "Provided type must not be UsdAPISchemaBase.");
604  static_assert(T::schemaKind == UsdSchemaKind::MultipleApplyAPI,
605  "Provided schema type must be a multi apply API schema.");
606 
607  return _HasMultiApplyAPI(TfType::Find<T>(), instanceName);
608  }
609 
622  USD_API
623  bool HasAPI(const TfType& schemaType,
624  const TfToken& instanceName=TfToken()) const;
625 
627 
640  template <typename SchemaType>
641  bool CanApplyAPI(std::string *whyNot = nullptr) const {
642  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
643  "Provided type must derive UsdAPISchemaBase.");
644  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
645  "Provided type must not be UsdAPISchemaBase.");
646  static_assert(SchemaType::schemaKind == UsdSchemaKind::SingleApplyAPI,
647  "Provided schema type must be a single apply API schema.");
648 
649  static const TfType schemaType = TfType::Find<SchemaType>();
650  return _CanApplyAPI(schemaType, whyNot);
651  }
652 
659  USD_API
660  bool CanApplyAPI(const TfType& schemaType,
661  std::string *whyNot = nullptr) const;
662 
676  template <typename SchemaType>
677  bool CanApplyAPI(const TfToken &instanceName,
678  std::string *whyNot = nullptr) const {
679  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
680  "Provided type must derive UsdAPISchemaBase.");
681  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
682  "Provided type must not be UsdAPISchemaBase.");
683  static_assert(SchemaType::schemaKind == UsdSchemaKind::MultipleApplyAPI,
684  "Provided schema type must be a multiple apply API schema.");
685 
686  static const TfType schemaType = TfType::Find<SchemaType>();
687  return _CanApplyAPI(schemaType, instanceName, whyNot);
688  }
689 
696  USD_API
697  bool CanApplyAPI(const TfType& schemaType,
698  const TfToken& instanceName,
699  std::string *whyNot = nullptr) const;
700 
716  template <typename SchemaType>
717  bool ApplyAPI() const {
718  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
719  "Provided type must derive UsdAPISchemaBase.");
720  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
721  "Provided type must not be UsdAPISchemaBase.");
722  static_assert(SchemaType::schemaKind == UsdSchemaKind::SingleApplyAPI,
723  "Provided schema type must be a single apply API schema.");
724 
725  static const TfType schemaType = TfType::Find<SchemaType>();
726  return _ApplyAPI(schemaType);
727  }
728 
735  USD_API
736  bool ApplyAPI(const TfType& schemaType) const;
737 
758  template <typename SchemaType>
759  bool ApplyAPI(const TfToken &instanceName) const {
760  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
761  "Provided type must derive UsdAPISchemaBase.");
762  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
763  "Provided type must not be UsdAPISchemaBase.");
764  static_assert(SchemaType::schemaKind == UsdSchemaKind::MultipleApplyAPI,
765  "Provided schema type must be a multiple apply API schema.");
766 
767  static const TfType schemaType = TfType::Find<SchemaType>();
768  return _ApplyAPI(schemaType, instanceName);
769  }
770 
777  USD_API
778  bool ApplyAPI(const TfType& schemaType, const TfToken& instanceName) const;
779 
796  template <typename SchemaType>
797  bool RemoveAPI() const {
798  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
799  "Provided type must derive UsdAPISchemaBase.");
800  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
801  "Provided type must not be UsdAPISchemaBase.");
802  static_assert(SchemaType::schemaKind == UsdSchemaKind::SingleApplyAPI,
803  "Provided schema type must be a single apply API schema.");
804 
805  static const TfType schemaType = TfType::Find<SchemaType>();
806  return _RemoveAPI(schemaType);
807  }
808 
815  USD_API
816  bool RemoveAPI(const TfType& schemaType) const;
817 
839  template <typename SchemaType>
840  bool RemoveAPI(const TfToken &instanceName) const {
841  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
842  "Provided type must derive UsdAPISchemaBase.");
843  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
844  "Provided type must not be UsdAPISchemaBase.");
845  static_assert(SchemaType::schemaKind == UsdSchemaKind::MultipleApplyAPI,
846  "Provided schema type must be a multiple apply API schema.");
847 
848  static const TfType schemaType = TfType::Find<SchemaType>();
849  return _RemoveAPI(schemaType, instanceName);
850  }
851 
858  USD_API
859  bool RemoveAPI(const TfType& schemaType,
860  const TfToken& instanceName) const;
861 
885  USD_API
886  bool AddAppliedSchema(const TfToken &appliedSchemaName) const;
887 
912  USD_API
913  bool RemoveAppliedSchema(const TfToken &appliedSchemaName) const;
914 
915  // --------------------------------------------------------------------- //
917  // --------------------------------------------------------------------- //
918 
924  USD_API
925  UsdPrim GetChild(const TfToken &name) const;
926 
935  inline SiblingRange GetChildren() const;
936 
938  inline SiblingRange GetAllChildren() const;
939 
959  inline SiblingRange
960  GetFilteredChildren(const Usd_PrimFlagsPredicate &predicate) const;
961 
964  USD_API
966 
969  USD_API
971 
974  USD_API
976  const Usd_PrimFlagsPredicate &predicate) const;
977 
990  inline SubtreeRange GetDescendants() const;
991 
1000  inline SubtreeRange GetAllDescendants() const;
1001 
1025  inline SubtreeRange
1026  GetFilteredDescendants(const Usd_PrimFlagsPredicate &predicate) const;
1027 
1033  USD_API
1035 
1038  void SetChildrenReorder(const TfTokenVector &order) const {
1039  SetMetadata(SdfFieldKeys->PrimOrder, order);
1040  }
1041 
1044  void ClearChildrenReorder() const {
1045  ClearMetadata(SdfFieldKeys->PrimOrder);
1046  }
1047 
1048 public:
1049  // --------------------------------------------------------------------- //
1051  // --------------------------------------------------------------------- //
1052 
1055  UsdPrim GetParent() const {
1056  Usd_PrimDataConstPtr prim = get_pointer(_Prim());
1057  SdfPath proxyPrimPath = _ProxyPrimPath();
1058  Usd_MoveToParent(prim, proxyPrimPath);
1059  return UsdPrim(prim, proxyPrimPath);
1060  }
1061 
1070  USD_API
1071  UsdPrim GetNextSibling() const;
1072 
1078  USD_API
1080  const Usd_PrimFlagsPredicate &predicate) const;
1081 
1088  USD_API
1089  bool IsPseudoRoot() const;
1090 
1094  USD_API UsdPrim GetPrimAtPath(const SdfPath& path) const;
1095 
1099  USD_API UsdObject GetObjectAtPath(const SdfPath& path) const;
1100 
1109  USD_API UsdProperty GetPropertyAtPath(const SdfPath& path) const;
1110 
1119  USD_API UsdAttribute GetAttributeAtPath(const SdfPath& path) const;
1120 
1129  USD_API UsdRelationship GetRelationshipAtPath(const SdfPath& path) const;
1130 
1131  // --------------------------------------------------------------------- //
1133  // --------------------------------------------------------------------- //
1134 
1140  USD_API
1142 
1150  USD_API
1151  UsdVariantSet GetVariantSet(const std::string& variantSetName) const;
1152 
1158  USD_API
1159  bool HasVariantSets() const;
1160 
1161  // --------------------------------------------------------------------- //
1163  // --------------------------------------------------------------------- //
1164 
1204  USD_API
1205  UsdAttribute
1206  CreateAttribute(const TfToken& name,
1207  const SdfValueTypeName &typeName,
1208  bool custom,
1209  SdfVariability variability = SdfVariabilityVarying) const;
1212  USD_API
1213  UsdAttribute
1214  CreateAttribute(const TfToken& name,
1215  const SdfValueTypeName &typeName,
1216  SdfVariability variability = SdfVariabilityVarying) const;
1217 
1222  USD_API
1224  const std::vector<std::string> &nameElts,
1225  const SdfValueTypeName &typeName,
1226  bool custom,
1227  SdfVariability variability = SdfVariabilityVarying) const;
1231  USD_API
1233  const std::vector<std::string> &nameElts,
1234  const SdfValueTypeName &typeName,
1235  SdfVariability variability = SdfVariabilityVarying) const;
1236 
1238  USD_API
1239  std::vector<UsdAttribute> GetAttributes() const;
1240 
1243  USD_API
1244  std::vector<UsdAttribute> GetAuthoredAttributes() const;
1245 
1258  USD_API
1259  UsdAttribute GetAttribute(const TfToken& attrName) const;
1260 
1263  USD_API
1264  bool HasAttribute(const TfToken& attrName) const;
1265 
1271  USD_API
1272  SdfPathVector
1274  std::function<bool (UsdAttribute const &)> const &pred = nullptr,
1275  bool recurseOnSources = false) const;
1276 
1277  // --------------------------------------------------------------------- //
1279  // --------------------------------------------------------------------- //
1280 
1317  USD_API
1319  bool custom=true) const;
1320 
1325  USD_API
1326  UsdRelationship CreateRelationship(const std::vector<std::string> &nameElts,
1327  bool custom=true)
1328  const;
1329 
1331  USD_API
1332  std::vector<UsdRelationship> GetRelationships() const;
1333 
1336  USD_API
1337  std::vector<UsdRelationship> GetAuthoredRelationships() const;
1338 
1351  USD_API
1352  UsdRelationship GetRelationship(const TfToken& relName) const;
1353 
1356  USD_API
1357  bool HasRelationship(const TfToken& relName) const;
1358 
1365  USD_API
1366  SdfPathVector
1368  std::function<bool (UsdRelationship const &)> const &pred = nullptr,
1369  bool recurseOnTargets = false) const;
1370 
1371  // --------------------------------------------------------------------- //
1378  // --------------------------------------------------------------------- //
1379 
1383  USD_API
1384  bool ClearPayload() const;
1385 
1390  USD_API
1391  bool HasPayload() const;
1392 
1398  USD_API
1399  bool SetPayload(const SdfPayload& payload) const;
1400 
1403  USD_API
1404  bool SetPayload(
1405  const std::string& assetPath, const SdfPath& primPath) const;
1406 
1410  USD_API
1411  bool SetPayload(const SdfLayerHandle& layer, const SdfPath& primPath) const;
1412 
1414 
1415  // --------------------------------------------------------------------- //
1417  // --------------------------------------------------------------------- //
1418 
1426  USD_API
1427  UsdPayloads GetPayloads() const;
1428 
1430  USD_API
1431  bool HasAuthoredPayloads() const;
1432 
1438  USD_API
1439  void Load(UsdLoadPolicy policy = UsdLoadWithDescendants) const;
1440 
1444  USD_API
1445  void Unload() const;
1446 
1447  // --------------------------------------------------------------------- //
1449  // --------------------------------------------------------------------- //
1450 
1460  USD_API
1461  UsdReferences GetReferences() const;
1462 
1464  USD_API
1465  bool HasAuthoredReferences() const;
1466 
1467  // --------------------------------------------------------------------- //
1469  // --------------------------------------------------------------------- //
1470 
1480  USD_API
1481  UsdInherits GetInherits() const;
1482 
1484  USD_API
1485  bool HasAuthoredInherits() const;
1486 
1487  // --------------------------------------------------------------------- //
1489  // --------------------------------------------------------------------- //
1490 
1498  USD_API
1500 
1502  USD_API
1503  bool HasAuthoredSpecializes() const;
1504 
1505  // --------------------------------------------------------------------- //
1509  // --------------------------------------------------------------------- //
1510 
1517  bool IsInstanceable() const {
1518  bool instanceable = false;
1519  return GetMetadata(SdfFieldKeys->Instanceable, &instanceable) &&
1520  instanceable;
1521  }
1522 
1525  bool SetInstanceable(bool instanceable) const {
1526  return SetMetadata(SdfFieldKeys->Instanceable, instanceable);
1527  }
1528 
1531  bool ClearInstanceable() const {
1532  return ClearMetadata(SdfFieldKeys->Instanceable);
1533  }
1534 
1538  return HasAuthoredMetadata(SdfFieldKeys->Instanceable);
1539  }
1540 
1546  bool IsInstance() const { return _Prim()->IsInstance(); }
1547 
1551  bool IsInstanceProxy() const {
1552  return Usd_IsInstanceProxy(_Prim(), _ProxyPrimPath());
1553  }
1554 
1562  USD_API
1563  static bool IsPrototypePath(const SdfPath& path);
1564 
1569  USD_API
1570  static bool IsPathInPrototype(const SdfPath& path);
1571 
1576  bool IsPrototype() const { return _Prim()->IsPrototype(); }
1577 
1582  bool IsInPrototype() const {
1583  return (IsInstanceProxy() ?
1584  IsPathInPrototype(GetPrimPath()) : _Prim()->IsInPrototype());
1585  }
1586 
1589  USD_API
1590  UsdPrim GetPrototype() const;
1591 
1596  if (IsInstanceProxy()) {
1597  return UsdPrim(_Prim(), SdfPath());
1598  }
1599  return UsdPrim();
1600  }
1601 
1607  USD_API
1608  std::vector<UsdPrim> GetInstances() const;
1610 
1611  // --------------------------------------------------------------------- //
1614  // --------------------------------------------------------------------- //
1615 
1638  const PcpPrimIndex &GetPrimIndex() const { return _Prim()->GetPrimIndex(); }
1639 
1653  USD_API
1655 
1657 
1658 private:
1659  friend class UsdObject;
1660  friend class UsdPrimSiblingIterator;
1661  friend class UsdPrimSubtreeIterator;
1662  friend class UsdProperty;
1663  friend class UsdSchemaBase;
1664  friend class UsdAPISchemaBase;
1665  friend class UsdStage;
1666  friend class UsdPrimRange;
1667  friend class Usd_PrimData;
1668  friend class Usd_PrimFlagsPredicate;
1669  friend struct UsdPrim_RelTargetFinder;
1670  friend struct UsdPrim_AttrConnectionFinder;
1671 
1672  // Prim constructor.
1673  UsdPrim(const Usd_PrimDataHandle &primData,
1674  const SdfPath &proxyPrimPath)
1675  : UsdObject(primData, proxyPrimPath) { }
1676 
1677  // General constructor.
1678  UsdPrim(UsdObjType objType,
1679  const Usd_PrimDataHandle &prim,
1680  const SdfPath &proxyPrimPath,
1681  const TfToken &propName)
1682  : UsdObject(objType, prim, proxyPrimPath, propName) {}
1683 
1684  // Helper to make a sibling range.
1685  inline SiblingRange
1686  _MakeSiblingRange(const Usd_PrimFlagsPredicate &pred) const;
1687 
1688  // Helper to make a range of descendants.
1689  inline SubtreeRange
1690  _MakeDescendantsRange(const Usd_PrimFlagsPredicate &pred) const;
1691 
1692  // Helper to make a vector of properties from names.
1693  std::vector<UsdProperty>
1694  _MakeProperties(const TfTokenVector &names) const;
1695 
1696  // Helper for Get{Authored}{PropertyNames,Properties}
1697  TfTokenVector _GetPropertyNames(
1698  bool onlyAuthored,
1699  bool applyOrder=true,
1700  const PropertyPredicateFunc &predicate={}) const;
1701 
1702  // Helper for Get(Authored)PropertiesInNamespace.
1703  std::vector<UsdProperty>
1704  _GetPropertiesInNamespace(const std::string &namespaces,
1705  bool onlyAuthored) const;
1706 
1707  // Helper for Get(Authored)Attributes.
1708  std::vector<UsdAttribute>
1709  _GetAttributes(bool onlyAuthored, bool applyOrder=false) const;
1710 
1711  // Helper for Get(Authored)Relationships.
1712  std::vector<UsdRelationship>
1713  _GetRelationships(bool onlyAuthored, bool applyOrder=false) const;
1714 
1715  friend const PcpPrimIndex &Usd_PrimGetSourcePrimIndex(const UsdPrim&);
1716  // Return a const reference to the source PcpPrimIndex for this prim.
1717  //
1718  // For all prims in prototypes (which includes the prototype prim itself),
1719  // this is the prim index for the instance that was chosen to serve
1720  // as the prototype for all other instances. This prim index will not
1721  // have the same path as the prim's path.
1722  //
1723  // This is a private helper but is also wrapped out to Python
1724  // for testing and debugging purposes.
1725  const PcpPrimIndex &_GetSourcePrimIndex() const
1726  { return _Prim()->GetSourcePrimIndex(); }
1727 };
1728 
1729 #ifdef doxygen
1730 
1734 public:
1740  typedef unspecified-integral-type difference_type;
1742  reference operator*() const;
1744  unspecified-type operator->() const;
1749 private:
1751  friend bool operator==(const UsdPrimSiblingIterator &lhs,
1752  const UsdPrimSiblingIterator &rhs);
1754  friend bool operator!=(const UsdPrimSiblingIterator &lhs,
1755  const UsdPrimSiblingIterator &rhs);
1756 };
1757 
1763 public:
1769  typedef unspecified-integral-type difference_type;
1774 
1778 
1780  template <class ForwardRange>
1781  UsdPrimSiblingRange(const ForwardRange &r);
1782 
1784  template <class ForwardRange>
1785  UsdPrimSiblingRange &operator=(const ForwardRange &r);
1786 
1788  iterator begin() const;
1789 
1791  iterator end() const;
1792 
1794  operator unspecified_bool_type() const;
1795 
1797  bool equal(const iterator_range&) const;
1798 
1800  reference front() const;
1801 
1803  iterator_range& advance_begin(difference_type n);
1804 
1806  iterator_range& advance_end(difference_type n);
1807 
1808  ;
1809  bool empty() const;
1810 
1811 private:
1813  friend bool operator==(const UsdPrimSiblingRange &lhs,
1814  const UsdPrimSiblingRange &rhs);
1816  friend bool operator!=(const UsdPrimSiblingRange &lhs,
1817  const UsdPrimSiblingRange &rhs);
1818 };
1819 
1820 #else
1821 
1822 // Sibling iterator class. Converts ref to weak and filters according to a
1823 // supplied predicate.
1824 class UsdPrimSiblingIterator : public boost::iterator_adaptor<
1825  UsdPrimSiblingIterator, // crtp base.
1826  const Usd_PrimData *, // base iterator.
1827  UsdPrim, // value type.
1828  boost::forward_traversal_tag, // traversal
1829  UsdPrim> // reference type.
1830 {
1831 public:
1832  // Default ctor.
1834 
1835 private:
1836  friend class UsdPrim;
1837 
1838  // Constructor used by Prim.
1839  UsdPrimSiblingIterator(const base_type &i, const SdfPath& proxyPrimPath,
1840  const Usd_PrimFlagsPredicate &predicate)
1841  : iterator_adaptor_(i)
1842  , _proxyPrimPath(proxyPrimPath)
1843  , _predicate(predicate) {
1844  // Need to advance iterator to first matching element.
1845  if (base() && !Usd_EvalPredicate(_predicate, base(), _proxyPrimPath))
1846  increment();
1847  }
1848 
1849  // Core implementation invoked by iterator_adaptor.
1850  friend class boost::iterator_core_access;
1851  bool equal(const UsdPrimSiblingIterator &other) const {
1852  return base() == other.base() &&
1853  _proxyPrimPath == other._proxyPrimPath &&
1854  _predicate == other._predicate;
1855  }
1856 
1857  void increment() {
1858  base_type &base = base_reference();
1859  if (Usd_MoveToNextSiblingOrParent(base, _proxyPrimPath, _predicate)) {
1860  base = nullptr;
1861  _proxyPrimPath = SdfPath();
1862  }
1863  }
1864 
1865  reference dereference() const {
1866  return UsdPrim(base(), _proxyPrimPath);
1867  }
1868 
1869  SdfPath _proxyPrimPath;
1870  Usd_PrimFlagsPredicate _predicate;
1871 };
1872 
1873 // Typedef iterator range.
1874 typedef boost::iterator_range<UsdPrimSiblingIterator> UsdPrimSiblingRange;
1875 
1876 // Inform TfIterator it should feel free to make copies of the range type.
1877 template <>
1878 struct Tf_ShouldIterateOverCopy<
1879  UsdPrimSiblingRange> : boost::true_type {};
1880 template <>
1881 struct Tf_ShouldIterateOverCopy<
1882  const UsdPrimSiblingRange> : boost::true_type {};
1883 
1884 #endif // doxygen
1885 
1886 
1888 UsdPrim::GetFilteredChildren(const Usd_PrimFlagsPredicate &pred) const
1889 {
1890  return _MakeSiblingRange(
1891  Usd_CreatePredicateForTraversal(_Prim(), _ProxyPrimPath(), pred));
1892 }
1893 
1896 {
1898 }
1899 
1902 {
1904 }
1905 
1906 // Helper to make a sibling range.
1908 UsdPrim::_MakeSiblingRange(const Usd_PrimFlagsPredicate &pred) const {
1909  Usd_PrimDataConstPtr firstChild = get_pointer(_Prim());
1910  SdfPath firstChildPath = _ProxyPrimPath();
1911  if (!Usd_MoveToChild(firstChild, firstChildPath, pred)) {
1912  firstChild = nullptr;
1913  firstChildPath = SdfPath();
1914  }
1915 
1916  return SiblingRange(
1917  SiblingIterator(firstChild, firstChildPath, pred),
1918  SiblingIterator(nullptr, SdfPath(), pred));
1919 }
1920 
1921 #ifdef doxygen
1922 
1926 public:
1932  typedef unspecified-integral-type difference_type;
1934  reference operator*() const;
1936  unspecified-type operator->() const;
1941 private:
1943  friend bool operator==(const UsdPrimSubtreeIterator &lhs,
1944  const UsdPrimSubtreeIterator &rhs);
1946  friend bool operator!=(const UsdPrimSubtreeIterator &lhs,
1947  const UsdPrimSubtreeIterator &rhs);
1948 };
1949 
1955 public:
1961  typedef unspecified-integral-type difference_type;
1966 
1970 
1972  template <class ForwardRange>
1973  UsdPrimSubtreeRange(const ForwardRange &r);
1974 
1976  template <class ForwardRange>
1977  UsdPrimSubtreeRange &operator=(const ForwardRange &r);
1978 
1980  iterator begin() const;
1981 
1983  iterator end() const;
1984 
1986  operator unspecified_bool_type() const;
1987 
1989  bool equal(const iterator_range&) const;
1990 
1992  reference front() const;
1993 
1995  iterator_range& advance_begin(difference_type n);
1996 
1998  iterator_range& advance_end(difference_type n);
1999 
2001  bool empty() const;
2002 
2003 private:
2005  friend bool operator==(const UsdPrimSubtreeRange &lhs,
2006  const UsdPrimSubtreeRange &rhs);
2008  friend bool operator!=(const UsdPrimSubtreeRange &lhs,
2009  const UsdPrimSubtreeRange &rhs);
2010 };
2011 
2012 #else
2013 
2014 // Subtree iterator class. Converts ref to weak and filters according to a
2015 // supplied predicate.
2016 class UsdPrimSubtreeIterator : public boost::iterator_adaptor<
2017  UsdPrimSubtreeIterator, // crtp base.
2018  const Usd_PrimData *, // base iterator.
2019  UsdPrim, // value type.
2020  boost::forward_traversal_tag, // traversal
2021  UsdPrim> // reference type.
2022 {
2023 public:
2024  // Default ctor.
2026 
2027 private:
2028  friend class UsdPrim;
2029 
2030  // Constructor used by Prim.
2031  UsdPrimSubtreeIterator(const base_type &i, const SdfPath &proxyPrimPath,
2032  const Usd_PrimFlagsPredicate &predicate)
2033  : iterator_adaptor_(i)
2034  , _proxyPrimPath(proxyPrimPath)
2035  , _predicate(predicate) {
2036  // Need to advance iterator to first matching element.
2037  base_type &base = base_reference();
2038  if (base && !Usd_EvalPredicate(_predicate, base, _proxyPrimPath)) {
2039  if (Usd_MoveToNextSiblingOrParent(base, _proxyPrimPath,
2040  _predicate)) {
2041  base = nullptr;
2042  _proxyPrimPath = SdfPath();
2043  }
2044  }
2045  }
2046 
2047  // Core implementation invoked by iterator_adaptor.
2048  friend class boost::iterator_core_access;
2049  bool equal(const UsdPrimSubtreeIterator &other) const {
2050  return base() == other.base() &&
2051  _proxyPrimPath == other._proxyPrimPath &&
2052  _predicate == other._predicate;
2053  }
2054 
2055  void increment() {
2056  base_type &base = base_reference();
2057  if (!Usd_MoveToChild(base, _proxyPrimPath, _predicate)) {
2058  while (Usd_MoveToNextSiblingOrParent(base, _proxyPrimPath,
2059  _predicate)) {}
2060  }
2061  }
2062 
2063  reference dereference() const {
2064  return UsdPrim(base(), _proxyPrimPath);
2065  }
2066 
2067  SdfPath _proxyPrimPath;
2068  Usd_PrimFlagsPredicate _predicate;
2069 };
2070 
2071 // Typedef iterator range.
2072 typedef boost::iterator_range<UsdPrimSubtreeIterator> UsdPrimSubtreeRange;
2073 
2074 // Inform TfIterator it should feel free to make copies of the range type.
2075 template <>
2076 struct Tf_ShouldIterateOverCopy<
2077  UsdPrimSubtreeRange> : boost::true_type {};
2078 template <>
2079 struct Tf_ShouldIterateOverCopy<
2080  const UsdPrimSubtreeRange> : boost::true_type {};
2081 
2082 #endif // doxygen
2083 
2085 UsdPrim::GetFilteredDescendants(const Usd_PrimFlagsPredicate &pred) const
2086 {
2087  return _MakeDescendantsRange(
2088  Usd_CreatePredicateForTraversal(_Prim(), _ProxyPrimPath(), pred));
2089 }
2090 
2093 {
2095 }
2096 
2099 {
2101 }
2102 
2103 // Helper to make a sibling range.
2105 UsdPrim::_MakeDescendantsRange(const Usd_PrimFlagsPredicate &pred) const {
2106  Usd_PrimDataConstPtr firstChild = get_pointer(_Prim());
2107  SdfPath firstChildPath = _ProxyPrimPath();
2108  Usd_PrimDataConstPtr endChild = firstChild;
2109  SdfPath endChildPath = firstChildPath;
2110  if (Usd_MoveToChild(firstChild, firstChildPath, pred)) {
2111  while (Usd_MoveToNextSiblingOrParent(endChild, endChildPath, pred)) {}
2112  }
2113 
2114  return SubtreeRange(
2115  SubtreeIterator(firstChild, firstChildPath, pred),
2116  SubtreeIterator(endChild, endChildPath, pred));
2117 }
2118 
2119 
2121 // UsdObject methods that require UsdPrim be a complete type.
2122 
2123 inline UsdPrim
2125 {
2126  return UsdPrim(_prim, _proxyPrimPath);
2127 }
2128 
2129 PXR_NAMESPACE_CLOSE_SCOPE
2130 
2131 #endif // PXR_USD_USD_PRIM_H
2132 
const UsdPrimTypeInfo & GetPrimTypeInfo() const
Return the prim's full type info composed from its type name, applied API schemas,...
Definition: prim.h:154
void ClearPropertyOrder() const
Remove the opinion for propertyOrder metadata on this prim at the current EditTarget.
Definition: prim.h:437
A proxy class for applying listOp edits to the specializes list for a prim.
Definition: specializes.h:51
bool SetMetadata(const TfToken &key, const T &value) const
Set metadatum key's value to value.
Definition: object.h:731
iterator::value_type value_type
Iterator value_type.
Definition: prim.h:1963
USD_API std::vector< UsdRelationship > GetAuthoredRelationships() const
Like GetRelationships(), but exclude relationships without authored scene description from the result...
unspecified integral type difference_type
Iterator difference type.
Definition: prim.h:1932
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:186
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:75
bool CanApplyAPI(std::string *whyNot=nullptr) const
}@
Definition: prim.h:641
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:2085
value_type reference
Iterator reference type, in this case the same as value_type.
Definition: prim.h:1930
friend bool operator==(const UsdPrimSiblingIterator &lhs, const UsdPrimSiblingIterator &rhs)
Equality.
bool CanApplyAPI(const TfToken &instanceName, std::string *whyNot=nullptr) const
Returns whether a multiple-apply API schema with the given C++ type 'SchemaType' can be applied to th...
Definition: prim.h:677
bool IsGroup() const
Return true if this prim is a model group based on its kind metadata, false otherwise.
Definition: prim.h:258
SdfSpecifier GetSpecifier() const
Return this prim's composed specifier.
Definition: prim.h:166
UsdPrimSiblingIterator iterator
Iterator type.
Definition: prim.h:1765
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:1038
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:1736
bool IsActive() const
Return true if this prim is active, meaning neither it nor any of its ancestors have active=false.
Definition: prim.h:219
bool ClearInstanceable() const
Remove the authored 'instanceable' opinion at the current EditTarget.
Definition: prim.h:1531
bool HasAuthoredInstanceable() const
Return true if this prim has an authored opinion for 'instanceable', false otherwise.
Definition: prim.h:1537
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:2098
The outermost container for scene description, which owns and presents composed prims as a scenegraph...
Definition: stage.h:145
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:1517
A proxy class for applying listOp edits to the inherit paths list for a prim.
Definition: inherits.h:51
friend bool operator!=(const UsdPrimSubtreeRange &lhs, const UsdPrimSubtreeRange &rhs)
Inequality comparison.
static USD_API bool IsPathInPrototype(const SdfPath &path)
Return true if the given path identifies a prototype prim or a prim or property descendant of a proto...
UsdPrimSiblingIterator & operator++()
Postincrement.
unspecified integral type difference_type
Iterator difference type.
Definition: prim.h:1769
USD_API TfTokenVector GetChildrenNames() const
Return the names of the child prims in the order they appear when iterating over GetChildren.
USD_API bool HasAuthoredInherits() const
Return true if this prim has any authored inherits.
USD_API UsdPrim GetFilteredNextSibling(const Usd_PrimFlagsPredicate &predicate) const
Return this prim's next sibling that matches predicate if it has one, otherwise return the invalid Us...
USD_API std::vector< UsdProperty > GetAuthoredPropertiesInNamespace(const std::vector< std::string > &namespaces) const
Like GetPropertiesInNamespace(), but exclude properties that do not have authored scene description f...
The base class for all API schemas.
USD_API UsdVariantSet GetVariantSet(const std::string &variantSetName) const
Retrieve a specifically named VariantSet for editing or constructing a UsdEditTarget.
Scenegraph object for authoring and retrieving numeric, string, and array valued data,...
Definition: attribute.h:176
USD_API UsdPrim GetChild(const TfToken &name) const
Return this prim's direct child named name if it has one, otherwise return an invalid UsdPrim.
USD_API bool RemoveProperty(const TfToken &propName)
Remove all scene description for the property with the given propName in the current UsdEditTarget.
bool IsInstance() const
Return true if this prim is an instance of a prototype, false otherwise.
Definition: prim.h:1546
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:1582
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:1762
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:1957
iterator::value_type value_type
Iterator value_type.
Definition: prim.h:1771
USD_API bool HasRelationship(const TfToken &relName) const
Return true if this prim has a relationship named relName, false otherwise.
USD_API SdfPathVector FindAllRelationshipTargetPaths(std::function< bool(UsdRelationship const &)> const &pred=nullptr, bool recurseOnTargets=false) const
Search the prim subtree rooted at this prim for relationships for which predicate returns true,...
Single Apply API schema.
reference front() const
Return *begin(). This range must not be empty.
void SetPropertyOrder(const TfTokenVector &order) const
Author an opinion for propertyOrder metadata on this prim at the current EditTarget.
Definition: prim.h:431
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:1525
USD_API PcpPrimIndex ComputeExpandedPrimIndex() const
Compute the prim index containing all sites that could contribute opinions to this prim.
bool RemoveAPI() const
Removes a single-apply API schema with the given C++ type 'SchemaType' from this prim in the current ...
Definition: prim.h:797
std::enable_if< T::schemaKind==UsdSchemaKind::MultipleApplyAPI, bool >::type HasAPI(const TfToken &instanceName=TfToken()) const
Return true if the UsdPrim has had a multiple-apply API schema represented by the C++ class type T ap...
Definition: prim.h:599
reference operator *() const
Dereference.
unspecified integral type difference_type
Iterator difference type.
Definition: prim.h:1740
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:161
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:1638
UsdPrimSubtreeIterator & operator++()
Postincrement.
bool IsAbstract() const
Return true if this prim or any of its ancestors is a class.
Definition: prim.h:261
USD_API TfTokenVector GetAuthoredPropertyNames(const PropertyPredicateFunc &predicate={}) const
Return this prim's property names (attributes and relationships) that have authored scene description...
USD_API bool HasProperty(const TfToken &propName) const
Return true if this prim has an property named propName, false otherwise.
USD_API bool SetPayload(const SdfPayload &payload) const
USD_API std::vector< UsdProperty > GetPropertiesInNamespace(const std::vector< std::string > &namespaces) const
Return this prim's properties that are inside the given property namespace ordered according to the s...
A UsdVariantSet represents a single VariantSet in USD (e.g.
Definition: variantSets.h:56
bool ApplyAPI() const
Applies a single-apply API schema with the given C++ type 'SchemaType' to this prim in the current ed...
Definition: prim.h:717
Forward iterator range of sibling UsdPrim s.
Definition: prim.h:1954
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:1055
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:1888
SiblingRange GetChildren() const
Return this prim's active, loaded, defined, non-abstract children as an iterable range.
Definition: prim.h:1901
Base class for Usd scenegraph objects, providing common API.
Definition: object.h:130
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:132
UsdPrimSiblingRange & operator=(const ForwardRange &r)
Assign from another compatible range type.
bool IsA() const
Return true if the prim's schema type, is or inherits schema type T.
Definition: prim.h:523
SdfSpecifier
An enum that identifies the possible specifiers for an SdfPrimSpec.
Definition: types.h:123
UsdPrim value_type
Iterator value type.
Definition: prim.h:1928
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:1551
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:197
SubtreeRange GetAllDescendants() const
Return all this prim's descendants as an iterable range.
Definition: prim.h:2092
unspecified type operator->() const
Indirection.
USD_API bool HasVariantSets() const
Return true if this prim has any authored VariantSets.
USD_API UsdVariantSets GetVariantSets() const
Return a UsdVariantSets object representing all the VariantSets present on this prim.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:290
USD_API bool ClearPayload() const
bool GetMetadata(const TfToken &key, T *value) const
Resolve the requested metadatum named key into value, returning true on success.
Definition: object.h:723
iterator_range & advance_begin(difference_type n)
Advance this range's begin iterator.
iterator::reference reference
Iterator reference_type.
Definition: prim.h:1965
USD_API bool HasPayload() const
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:242
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:206
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:1895
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:840
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:1595
Base class for UsdAttribute and UsdRelationship scenegraph objects.
Definition: property.h:55
bool ClearActive() const
Remove the authored 'active' opinion at the current EditTarget.
Definition: prim.h:234
bool SetTypeName(const TfToken &typeName) const
Author this Prim's typeName at the current EditTarget.
Definition: prim.h:200
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:211
void ClearChildrenReorder() const
Remove the opinion for the metadata used to reorder children of this prim at the current EditTarget.
Definition: prim.h:1044
bool IsModel() const
Return true if this prim is a model based on its kind metadata, false otherwise.
Definition: prim.h:253
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:249
unspecified integral type difference_type
Iterator difference type.
Definition: prim.h:1961
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:1576
Forward traversal iterator of sibling UsdPrim s.
Definition: prim.h:1925
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:144
std::function< bool(const TfToken &propertyName)> PropertyPredicateFunc
Alias for the "predicate" function parameter passed into the various Get{Authored}{PropertyNames,...
Definition: prim.h:285
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:140
bool IsDefined() const
Return true if this prim and all its ancestors have defining specifiers, false otherwise.
Definition: prim.h:265
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:136
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:1767
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:225
UsdPrimSubtreeIterator const_iterator
Const iterator type.
Definition: prim.h:1959
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:1773
Forward traversal iterator of sibling UsdPrim s.
Definition: prim.h:1733
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:2124
std::enable_if< T::schemaKind !=UsdSchemaKind::MultipleApplyAPI, bool >::type HasAPI() const
Using HasAPI in C++
Definition: prim.h:572
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:1738
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
USD_API std::vector< UsdRelationship > GetRelationships() const
Like GetProperties(), but exclude all attributes from the result.
bool ApplyAPI(const TfToken &instanceName) const
Applies a multiple-apply API schema with the given C++ type 'SchemaType' and instance name instanceNa...
Definition: prim.h:759
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.
bool HasDefiningSpecifier() const
Return true if this prim has a specifier of type SdfSpecifierDef or SdfSpecifierClass.
Definition: prim.h:269
USD_API std::vector< UsdProperty > GetAuthoredProperties(const PropertyPredicateFunc &predicate={}) const
Return this prim's properties (attributes and relationships) that have authored scene description,...