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 
157  return _Prim()->GetPrimTypeInfo();
158  }
159 
164  return _Prim()->GetPrimDefinition();
165  }
166 
168  SdfSpecifier GetSpecifier() const { return _Prim()->GetSpecifier(); };
169 
183  USD_API
184  SdfPrimSpecHandleVector GetPrimStack() const;
185 
188  bool SetSpecifier(SdfSpecifier specifier) const {
189  return SetMetadata(SdfFieldKeys->Specifier, specifier);
190  }
191 
199  const TfToken &GetTypeName() const { return _Prim()->GetTypeName(); };
200 
202  bool SetTypeName(const TfToken & typeName) const {
203  return SetMetadata(SdfFieldKeys->TypeName, typeName);
204  }
205 
208  bool ClearTypeName() const {
209  return ClearMetadata(SdfFieldKeys->TypeName);
210  }
211 
213  bool HasAuthoredTypeName() const {
214  return HasAuthoredMetadata(SdfFieldKeys->TypeName);
215  }
216 
221  bool IsActive() const { return _Prim()->IsActive(); }
222 
227  bool SetActive(bool active) const {
228  return SetMetadata(SdfFieldKeys->Active, active);
229  }
230 
236  bool ClearActive() const {
237  return ClearMetadata(SdfFieldKeys->Active);
238  }
239 
244  bool HasAuthoredActive() const {
245  return HasAuthoredMetadata(SdfFieldKeys->Active);
246  }
247 
251  bool IsLoaded() const { return _Prim()->IsLoaded(); }
252 
255  bool IsModel() const { return _Prim()->IsModel(); }
256 
260  bool IsGroup() const { return _Prim()->IsGroup(); }
261 
263  bool IsAbstract() const { return _Prim()->IsAbstract(); }
264 
267  bool IsDefined() const { return _Prim()->IsDefined(); }
268 
271  bool HasDefiningSpecifier() const {
272  return _Prim()->HasDefiningSpecifier();
273  }
274 
281  USD_API
283 
286  using PropertyPredicateFunc =
287  std::function<bool (const TfToken &propertyName)>;
288 
300  USD_API
302  const PropertyPredicateFunc &predicate={}) const;
303 
317  USD_API
319  const PropertyPredicateFunc &predicate={}) const;
320 
364  USD_API
365  std::vector<UsdProperty> GetProperties(
366  const PropertyPredicateFunc &predicate={}) const;
367 
381  USD_API
382  std::vector<UsdProperty> GetAuthoredProperties(
383  const PropertyPredicateFunc &predicate={}) const;
384 
396  USD_API
397  std::vector<UsdProperty>
398  GetPropertiesInNamespace(const std::vector<std::string> &namespaces) const;
399 
404  USD_API
405  std::vector<UsdProperty>
406  GetPropertiesInNamespace(const std::string &namespaces) const;
407 
413  USD_API
414  std::vector<UsdProperty>
416  const std::vector<std::string> &namespaces) const;
417 
423  USD_API
424  std::vector<UsdProperty>
425  GetAuthoredPropertiesInNamespace(const std::string &namespaces) const;
426 
428  USD_API
430 
433  void SetPropertyOrder(const TfTokenVector &order) const {
434  SetMetadata(SdfFieldKeys->PropertyOrder, order);
435  }
436 
439  void ClearPropertyOrder() const {
440  ClearMetadata(SdfFieldKeys->PropertyOrder);
441  }
442 
451  USD_API
452  bool RemoveProperty(const TfToken &propName);
453 
466  USD_API
467  UsdProperty GetProperty(const TfToken &propName) const;
468 
471  USD_API
472  bool HasProperty(const TfToken &propName) const;
473 
474 private:
475  // The non-templated implementation of UsdPrim::IsA using the
476  // TfType system. \p validateSchemaType is provided for python clients
477  // because they can't use compile time assertions on the input type.
478  USD_API
479  bool _IsA(const TfType& schemaType, bool validateSchemaType) const;
480 
481  // Separate implementations for UsdPrim::HasAPI for single and multiple
482  // apply API schema TfTypes.
483  USD_API
484  bool _HasSingleApplyAPI(const TfType& schemaType) const;
485 
486  USD_API
487  bool _HasMultiApplyAPI(const TfType& schemaType,
488  const TfToken &instanceName) const;
489 
490  // Private implementation for all ApplyAPI, CanApplyAPI, and RemoveAPI
491  // methods for both single apply and multiple apply APIs. The multiple
492  // apply API methods validate that the instance name is non-empty, but
493  // otherwise all of these methods do no other input validation as the
494  // public methods are expected to have already done either compile time or
495  // runtime validation already.
496  USD_API
497  bool _CanApplyAPI(const TfType& schemaType,
498  std::string *whyNot) const;
499 
500  USD_API
501  bool _CanApplyAPI(const TfType& schemaType,
502  const TfToken& instanceName,
503  std::string *whyNot) const;
504 
505  USD_API
506  bool _ApplyAPI(const TfType& schemaType) const;
507 
508  USD_API
509  bool _ApplyAPI(const TfType& schemaType,
510  const TfToken& instanceName) const;
511 
512  USD_API
513  bool _RemoveAPI(const TfType& schemaType) const;
514 
515  USD_API
516  bool _RemoveAPI(const TfType& schemaType,
517  const TfToken& instanceName) const;
518 
519 public:
524  template <typename T>
525  bool IsA() const {
526  static_assert(std::is_base_of<UsdSchemaBase, T>::value,
527  "Provided type must derive UsdSchemaBase.");
528  return _IsA(TfType::Find<T>(), /*validateSchemaType=*/false);
529  };
530 
535  USD_API
536  bool IsA(const TfType& schemaType) const;
537 
566 
571  template <typename T>
572  typename std::enable_if<T::schemaKind != UsdSchemaKind::MultipleApplyAPI,
573  bool>::type
574  HasAPI() const {
575  static_assert(std::is_base_of<UsdAPISchemaBase, T>::value,
576  "Provided type must derive UsdAPISchemaBase.");
577  static_assert(!std::is_same<UsdAPISchemaBase, T>::value,
578  "Provided type must not be UsdAPISchemaBase.");
579  // Note that this function template is enabled for any schema kind,
580  // other than MultipleApplyAPI, but is only valid for SingleApplyAPI.
581  // This static assert provides better error information for calling
582  // HasAPI with an invalid template type than if we limited HasAPI
583  // substitution matching to just the two valid schema kinds.
584  static_assert(T::schemaKind == UsdSchemaKind::SingleApplyAPI,
585  "Provided schema type must be a single apply API schema.");
586 
587  return _HasSingleApplyAPI(TfType::Find<T>());
588  }
589 
598  template <typename T>
599  typename std::enable_if<T::schemaKind == UsdSchemaKind::MultipleApplyAPI,
600  bool>::type
601  HasAPI(const TfToken &instanceName = TfToken()) const {
602  static_assert(std::is_base_of<UsdAPISchemaBase, T>::value,
603  "Provided type must derive UsdAPISchemaBase.");
604  static_assert(!std::is_same<UsdAPISchemaBase, T>::value,
605  "Provided type must not be UsdAPISchemaBase.");
606  static_assert(T::schemaKind == UsdSchemaKind::MultipleApplyAPI,
607  "Provided schema type must be a multi apply API schema.");
608 
609  return _HasMultiApplyAPI(TfType::Find<T>(), instanceName);
610  }
611 
624  USD_API
625  bool HasAPI(const TfType& schemaType,
626  const TfToken& instanceName=TfToken()) const;
627 
629 
642  template <typename SchemaType>
643  bool CanApplyAPI(std::string *whyNot = nullptr) const {
644  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
645  "Provided type must derive UsdAPISchemaBase.");
646  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
647  "Provided type must not be UsdAPISchemaBase.");
648  static_assert(SchemaType::schemaKind == UsdSchemaKind::SingleApplyAPI,
649  "Provided schema type must be a single apply API schema.");
650 
651  static const TfType schemaType = TfType::Find<SchemaType>();
652  return _CanApplyAPI(schemaType, whyNot);
653  }
654 
661  USD_API
662  bool CanApplyAPI(const TfType& schemaType,
663  std::string *whyNot = nullptr) const;
664 
678  template <typename SchemaType>
679  bool CanApplyAPI(const TfToken &instanceName,
680  std::string *whyNot = nullptr) const {
681  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
682  "Provided type must derive UsdAPISchemaBase.");
683  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
684  "Provided type must not be UsdAPISchemaBase.");
685  static_assert(SchemaType::schemaKind == UsdSchemaKind::MultipleApplyAPI,
686  "Provided schema type must be a multiple apply API schema.");
687 
688  static const TfType schemaType = TfType::Find<SchemaType>();
689  return _CanApplyAPI(schemaType, instanceName, whyNot);
690  }
691 
698  USD_API
699  bool CanApplyAPI(const TfType& schemaType,
700  const TfToken& instanceName,
701  std::string *whyNot = nullptr) const;
702 
718  template <typename SchemaType>
719  bool ApplyAPI() const {
720  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
721  "Provided type must derive UsdAPISchemaBase.");
722  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
723  "Provided type must not be UsdAPISchemaBase.");
724  static_assert(SchemaType::schemaKind == UsdSchemaKind::SingleApplyAPI,
725  "Provided schema type must be a single apply API schema.");
726 
727  static const TfType schemaType = TfType::Find<SchemaType>();
728  return _ApplyAPI(schemaType);
729  }
730 
737  USD_API
738  bool ApplyAPI(const TfType& schemaType) const;
739 
760  template <typename SchemaType>
761  bool ApplyAPI(const TfToken &instanceName) const {
762  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
763  "Provided type must derive UsdAPISchemaBase.");
764  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
765  "Provided type must not be UsdAPISchemaBase.");
766  static_assert(SchemaType::schemaKind == UsdSchemaKind::MultipleApplyAPI,
767  "Provided schema type must be a multiple apply API schema.");
768 
769  static const TfType schemaType = TfType::Find<SchemaType>();
770  return _ApplyAPI(schemaType, instanceName);
771  }
772 
779  USD_API
780  bool ApplyAPI(const TfType& schemaType, const TfToken& instanceName) const;
781 
798  template <typename SchemaType>
799  bool RemoveAPI() const {
800  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
801  "Provided type must derive UsdAPISchemaBase.");
802  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
803  "Provided type must not be UsdAPISchemaBase.");
804  static_assert(SchemaType::schemaKind == UsdSchemaKind::SingleApplyAPI,
805  "Provided schema type must be a single apply API schema.");
806 
807  static const TfType schemaType = TfType::Find<SchemaType>();
808  return _RemoveAPI(schemaType);
809  }
810 
817  USD_API
818  bool RemoveAPI(const TfType& schemaType) const;
819 
841  template <typename SchemaType>
842  bool RemoveAPI(const TfToken &instanceName) const {
843  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
844  "Provided type must derive UsdAPISchemaBase.");
845  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
846  "Provided type must not be UsdAPISchemaBase.");
847  static_assert(SchemaType::schemaKind == UsdSchemaKind::MultipleApplyAPI,
848  "Provided schema type must be a multiple apply API schema.");
849 
850  static const TfType schemaType = TfType::Find<SchemaType>();
851  return _RemoveAPI(schemaType, instanceName);
852  }
853 
860  USD_API
861  bool RemoveAPI(const TfType& schemaType,
862  const TfToken& instanceName) const;
863 
887  USD_API
888  bool AddAppliedSchema(const TfToken &appliedSchemaName) const;
889 
914  USD_API
915  bool RemoveAppliedSchema(const TfToken &appliedSchemaName) const;
916 
917  // --------------------------------------------------------------------- //
919  // --------------------------------------------------------------------- //
920 
926  USD_API
927  UsdPrim GetChild(const TfToken &name) const;
928 
937  inline SiblingRange GetChildren() const;
938 
940  inline SiblingRange GetAllChildren() const;
941 
961  inline SiblingRange
962  GetFilteredChildren(const Usd_PrimFlagsPredicate &predicate) const;
963 
966  USD_API
968 
971  USD_API
973 
976  USD_API
978  const Usd_PrimFlagsPredicate &predicate) const;
979 
992  inline SubtreeRange GetDescendants() const;
993 
1002  inline SubtreeRange GetAllDescendants() const;
1003 
1027  inline SubtreeRange
1028  GetFilteredDescendants(const Usd_PrimFlagsPredicate &predicate) const;
1029 
1035  USD_API
1037 
1040  void SetChildrenReorder(const TfTokenVector &order) const {
1041  SetMetadata(SdfFieldKeys->PrimOrder, order);
1042  }
1043 
1046  void ClearChildrenReorder() const {
1047  ClearMetadata(SdfFieldKeys->PrimOrder);
1048  }
1049 
1050 public:
1051  // --------------------------------------------------------------------- //
1053  // --------------------------------------------------------------------- //
1054 
1057  UsdPrim GetParent() const {
1058  Usd_PrimDataConstPtr prim = get_pointer(_Prim());
1059  SdfPath proxyPrimPath = _ProxyPrimPath();
1060  Usd_MoveToParent(prim, proxyPrimPath);
1061  return UsdPrim(prim, proxyPrimPath);
1062  }
1063 
1072  USD_API
1073  UsdPrim GetNextSibling() const;
1074 
1080  USD_API
1082  const Usd_PrimFlagsPredicate &predicate) const;
1083 
1090  USD_API
1091  bool IsPseudoRoot() const;
1092 
1096  USD_API UsdPrim GetPrimAtPath(const SdfPath& path) const;
1097 
1101  USD_API UsdObject GetObjectAtPath(const SdfPath& path) const;
1102 
1111  USD_API UsdProperty GetPropertyAtPath(const SdfPath& path) const;
1112 
1121  USD_API UsdAttribute GetAttributeAtPath(const SdfPath& path) const;
1122 
1131  USD_API UsdRelationship GetRelationshipAtPath(const SdfPath& path) const;
1132 
1133  // --------------------------------------------------------------------- //
1135  // --------------------------------------------------------------------- //
1136 
1142  USD_API
1144 
1152  USD_API
1153  UsdVariantSet GetVariantSet(const std::string& variantSetName) const;
1154 
1160  USD_API
1161  bool HasVariantSets() const;
1162 
1163  // --------------------------------------------------------------------- //
1165  // --------------------------------------------------------------------- //
1166 
1206  USD_API
1207  UsdAttribute
1208  CreateAttribute(const TfToken& name,
1209  const SdfValueTypeName &typeName,
1210  bool custom,
1211  SdfVariability variability = SdfVariabilityVarying) const;
1214  USD_API
1215  UsdAttribute
1216  CreateAttribute(const TfToken& name,
1217  const SdfValueTypeName &typeName,
1218  SdfVariability variability = SdfVariabilityVarying) const;
1219 
1224  USD_API
1226  const std::vector<std::string> &nameElts,
1227  const SdfValueTypeName &typeName,
1228  bool custom,
1229  SdfVariability variability = SdfVariabilityVarying) const;
1233  USD_API
1235  const std::vector<std::string> &nameElts,
1236  const SdfValueTypeName &typeName,
1237  SdfVariability variability = SdfVariabilityVarying) const;
1238 
1240  USD_API
1241  std::vector<UsdAttribute> GetAttributes() const;
1242 
1245  USD_API
1246  std::vector<UsdAttribute> GetAuthoredAttributes() const;
1247 
1260  USD_API
1261  UsdAttribute GetAttribute(const TfToken& attrName) const;
1262 
1265  USD_API
1266  bool HasAttribute(const TfToken& attrName) const;
1267 
1273  USD_API
1274  SdfPathVector
1276  std::function<bool (UsdAttribute const &)> const &pred = nullptr,
1277  bool recurseOnSources = false) const;
1278 
1279  // --------------------------------------------------------------------- //
1281  // --------------------------------------------------------------------- //
1282 
1319  USD_API
1321  bool custom=true) const;
1322 
1327  USD_API
1328  UsdRelationship CreateRelationship(const std::vector<std::string> &nameElts,
1329  bool custom=true)
1330  const;
1331 
1333  USD_API
1334  std::vector<UsdRelationship> GetRelationships() const;
1335 
1338  USD_API
1339  std::vector<UsdRelationship> GetAuthoredRelationships() const;
1340 
1353  USD_API
1354  UsdRelationship GetRelationship(const TfToken& relName) const;
1355 
1358  USD_API
1359  bool HasRelationship(const TfToken& relName) const;
1360 
1367  USD_API
1368  SdfPathVector
1370  std::function<bool (UsdRelationship const &)> const &pred = nullptr,
1371  bool recurseOnTargets = false) const;
1372 
1373  // --------------------------------------------------------------------- //
1380  // --------------------------------------------------------------------- //
1381 
1385  USD_API
1386  bool ClearPayload() const;
1387 
1392  USD_API
1393  bool HasPayload() const;
1394 
1400  USD_API
1401  bool SetPayload(const SdfPayload& payload) const;
1402 
1405  USD_API
1406  bool SetPayload(
1407  const std::string& assetPath, const SdfPath& primPath) const;
1408 
1412  USD_API
1413  bool SetPayload(const SdfLayerHandle& layer, const SdfPath& primPath) const;
1414 
1416 
1417  // --------------------------------------------------------------------- //
1419  // --------------------------------------------------------------------- //
1420 
1428  USD_API
1429  UsdPayloads GetPayloads() const;
1430 
1432  USD_API
1433  bool HasAuthoredPayloads() const;
1434 
1440  USD_API
1441  void Load(UsdLoadPolicy policy = UsdLoadWithDescendants) const;
1442 
1446  USD_API
1447  void Unload() const;
1448 
1449  // --------------------------------------------------------------------- //
1451  // --------------------------------------------------------------------- //
1452 
1462  USD_API
1463  UsdReferences GetReferences() const;
1464 
1466  USD_API
1467  bool HasAuthoredReferences() const;
1468 
1469  // --------------------------------------------------------------------- //
1471  // --------------------------------------------------------------------- //
1472 
1482  USD_API
1483  UsdInherits GetInherits() const;
1484 
1486  USD_API
1487  bool HasAuthoredInherits() const;
1488 
1489  // --------------------------------------------------------------------- //
1491  // --------------------------------------------------------------------- //
1492 
1500  USD_API
1502 
1504  USD_API
1505  bool HasAuthoredSpecializes() const;
1506 
1507  // --------------------------------------------------------------------- //
1511  // --------------------------------------------------------------------- //
1512 
1519  bool IsInstanceable() const {
1520  bool instanceable = false;
1521  return GetMetadata(SdfFieldKeys->Instanceable, &instanceable) &&
1522  instanceable;
1523  }
1524 
1527  bool SetInstanceable(bool instanceable) const {
1528  return SetMetadata(SdfFieldKeys->Instanceable, instanceable);
1529  }
1530 
1533  bool ClearInstanceable() const {
1534  return ClearMetadata(SdfFieldKeys->Instanceable);
1535  }
1536 
1540  return HasAuthoredMetadata(SdfFieldKeys->Instanceable);
1541  }
1542 
1548  bool IsInstance() const { return _Prim()->IsInstance(); }
1549 
1553  bool IsInstanceProxy() const {
1554  return Usd_IsInstanceProxy(_Prim(), _ProxyPrimPath());
1555  }
1556 
1564  USD_API
1565  static bool IsPrototypePath(const SdfPath& path);
1566 
1571  USD_API
1572  static bool IsPathInPrototype(const SdfPath& path);
1573 
1578  bool IsPrototype() const { return _Prim()->IsPrototype(); }
1579 
1584  bool IsInPrototype() const {
1585  return (IsInstanceProxy() ?
1586  IsPathInPrototype(GetPrimPath()) : _Prim()->IsInPrototype());
1587  }
1588 
1591  USD_API
1592  UsdPrim GetPrototype() const;
1593 
1598  if (IsInstanceProxy()) {
1599  return UsdPrim(_Prim(), SdfPath());
1600  }
1601  return UsdPrim();
1602  }
1603 
1609  USD_API
1610  std::vector<UsdPrim> GetInstances() const;
1612 
1613  // --------------------------------------------------------------------- //
1616  // --------------------------------------------------------------------- //
1617 
1640  const PcpPrimIndex &GetPrimIndex() const { return _Prim()->GetPrimIndex(); }
1641 
1655  USD_API
1657 
1659 
1660 private:
1661  friend class UsdObject;
1662  friend class UsdPrimSiblingIterator;
1663  friend class UsdPrimSubtreeIterator;
1664  friend class UsdProperty;
1665  friend class UsdSchemaBase;
1666  friend class UsdAPISchemaBase;
1667  friend class UsdStage;
1668  friend class UsdPrimRange;
1669  friend class Usd_PrimData;
1670  friend class Usd_PrimFlagsPredicate;
1671  friend struct UsdPrim_RelTargetFinder;
1672  friend struct UsdPrim_AttrConnectionFinder;
1673 
1674  // Prim constructor.
1675  UsdPrim(const Usd_PrimDataHandle &primData,
1676  const SdfPath &proxyPrimPath)
1677  : UsdObject(primData, proxyPrimPath) { }
1678 
1679  // General constructor.
1680  UsdPrim(UsdObjType objType,
1681  const Usd_PrimDataHandle &prim,
1682  const SdfPath &proxyPrimPath,
1683  const TfToken &propName)
1684  : UsdObject(objType, prim, proxyPrimPath, propName) {}
1685 
1686  // Helper to make a sibling range.
1687  inline SiblingRange
1688  _MakeSiblingRange(const Usd_PrimFlagsPredicate &pred) const;
1689 
1690  // Helper to make a range of descendants.
1691  inline SubtreeRange
1692  _MakeDescendantsRange(const Usd_PrimFlagsPredicate &pred) const;
1693 
1694  // Helper to make a vector of properties from names.
1695  std::vector<UsdProperty>
1696  _MakeProperties(const TfTokenVector &names) const;
1697 
1698  // Helper for Get{Authored}{PropertyNames,Properties}
1699  TfTokenVector _GetPropertyNames(
1700  bool onlyAuthored,
1701  bool applyOrder=true,
1702  const PropertyPredicateFunc &predicate={}) const;
1703 
1704  // Helper for Get(Authored)PropertiesInNamespace.
1705  std::vector<UsdProperty>
1706  _GetPropertiesInNamespace(const std::string &namespaces,
1707  bool onlyAuthored) const;
1708 
1709  // Helper for Get(Authored)Attributes.
1710  std::vector<UsdAttribute>
1711  _GetAttributes(bool onlyAuthored, bool applyOrder=false) const;
1712 
1713  // Helper for Get(Authored)Relationships.
1714  std::vector<UsdRelationship>
1715  _GetRelationships(bool onlyAuthored, bool applyOrder=false) const;
1716 
1717  friend const PcpPrimIndex &Usd_PrimGetSourcePrimIndex(const UsdPrim&);
1718  // Return a const reference to the source PcpPrimIndex for this prim.
1719  //
1720  // For all prims in prototypes (which includes the prototype prim itself),
1721  // this is the prim index for the instance that was chosen to serve
1722  // as the prototype for all other instances. This prim index will not
1723  // have the same path as the prim's path.
1724  //
1725  // This is a private helper but is also wrapped out to Python
1726  // for testing and debugging purposes.
1727  const PcpPrimIndex &_GetSourcePrimIndex() const
1728  { return _Prim()->GetSourcePrimIndex(); }
1729 };
1730 
1731 #ifdef doxygen
1732 
1736 public:
1742  typedef unspecified-integral-type difference_type;
1744  reference operator*() const;
1746  unspecified-type operator->() const;
1751 private:
1753  friend bool operator==(const UsdPrimSiblingIterator &lhs,
1754  const UsdPrimSiblingIterator &rhs);
1756  friend bool operator!=(const UsdPrimSiblingIterator &lhs,
1757  const UsdPrimSiblingIterator &rhs);
1758 };
1759 
1765 public:
1771  typedef unspecified-integral-type difference_type;
1776 
1780 
1782  template <class ForwardRange>
1783  UsdPrimSiblingRange(const ForwardRange &r);
1784 
1786  template <class ForwardRange>
1787  UsdPrimSiblingRange &operator=(const ForwardRange &r);
1788 
1790  iterator begin() const;
1791 
1793  iterator end() const;
1794 
1796  operator unspecified_bool_type() const;
1797 
1799  bool equal(const iterator_range&) const;
1800 
1802  reference front() const;
1803 
1805  iterator_range& advance_begin(difference_type n);
1806 
1808  iterator_range& advance_end(difference_type n);
1809 
1810  ;
1811  bool empty() const;
1812 
1813 private:
1815  friend bool operator==(const UsdPrimSiblingRange &lhs,
1816  const UsdPrimSiblingRange &rhs);
1818  friend bool operator!=(const UsdPrimSiblingRange &lhs,
1819  const UsdPrimSiblingRange &rhs);
1820 };
1821 
1822 #else
1823 
1824 // Sibling iterator class. Converts ref to weak and filters according to a
1825 // supplied predicate.
1826 class UsdPrimSiblingIterator : public boost::iterator_adaptor<
1827  UsdPrimSiblingIterator, // crtp base.
1828  const Usd_PrimData *, // base iterator.
1829  UsdPrim, // value type.
1830  boost::forward_traversal_tag, // traversal
1831  UsdPrim> // reference type.
1832 {
1833 public:
1834  // Default ctor.
1836 
1837 private:
1838  friend class UsdPrim;
1839 
1840  // Constructor used by Prim.
1841  UsdPrimSiblingIterator(const base_type &i, const SdfPath& proxyPrimPath,
1842  const Usd_PrimFlagsPredicate &predicate)
1843  : iterator_adaptor_(i)
1844  , _proxyPrimPath(proxyPrimPath)
1845  , _predicate(predicate) {
1846  // Need to advance iterator to first matching element.
1847  if (base() && !Usd_EvalPredicate(_predicate, base(), _proxyPrimPath))
1848  increment();
1849  }
1850 
1851  // Core implementation invoked by iterator_adaptor.
1852  friend class boost::iterator_core_access;
1853  bool equal(const UsdPrimSiblingIterator &other) const {
1854  return base() == other.base() &&
1855  _proxyPrimPath == other._proxyPrimPath &&
1856  _predicate == other._predicate;
1857  }
1858 
1859  void increment() {
1860  base_type &base = base_reference();
1861  if (Usd_MoveToNextSiblingOrParent(base, _proxyPrimPath, _predicate)) {
1862  base = nullptr;
1863  _proxyPrimPath = SdfPath();
1864  }
1865  }
1866 
1867  reference dereference() const {
1868  return UsdPrim(base(), _proxyPrimPath);
1869  }
1870 
1871  SdfPath _proxyPrimPath;
1872  Usd_PrimFlagsPredicate _predicate;
1873 };
1874 
1875 // Typedef iterator range.
1876 typedef boost::iterator_range<UsdPrimSiblingIterator> UsdPrimSiblingRange;
1877 
1878 // Inform TfIterator it should feel free to make copies of the range type.
1879 template <>
1880 struct Tf_ShouldIterateOverCopy<
1881  UsdPrimSiblingRange> : boost::true_type {};
1882 template <>
1883 struct Tf_ShouldIterateOverCopy<
1884  const UsdPrimSiblingRange> : boost::true_type {};
1885 
1886 #endif // doxygen
1887 
1888 
1890 UsdPrim::GetFilteredChildren(const Usd_PrimFlagsPredicate &pred) const
1891 {
1892  return _MakeSiblingRange(
1893  Usd_CreatePredicateForTraversal(_Prim(), _ProxyPrimPath(), pred));
1894 }
1895 
1898 {
1900 }
1901 
1904 {
1906 }
1907 
1908 // Helper to make a sibling range.
1910 UsdPrim::_MakeSiblingRange(const Usd_PrimFlagsPredicate &pred) const {
1911  Usd_PrimDataConstPtr firstChild = get_pointer(_Prim());
1912  SdfPath firstChildPath = _ProxyPrimPath();
1913  if (!Usd_MoveToChild(firstChild, firstChildPath, pred)) {
1914  firstChild = nullptr;
1915  firstChildPath = SdfPath();
1916  }
1917 
1918  return SiblingRange(
1919  SiblingIterator(firstChild, firstChildPath, pred),
1920  SiblingIterator(nullptr, SdfPath(), pred));
1921 }
1922 
1923 #ifdef doxygen
1924 
1928 public:
1934  typedef unspecified-integral-type difference_type;
1936  reference operator*() const;
1938  unspecified-type operator->() const;
1943 private:
1945  friend bool operator==(const UsdPrimSubtreeIterator &lhs,
1946  const UsdPrimSubtreeIterator &rhs);
1948  friend bool operator!=(const UsdPrimSubtreeIterator &lhs,
1949  const UsdPrimSubtreeIterator &rhs);
1950 };
1951 
1957 public:
1963  typedef unspecified-integral-type difference_type;
1968 
1972 
1974  template <class ForwardRange>
1975  UsdPrimSubtreeRange(const ForwardRange &r);
1976 
1978  template <class ForwardRange>
1979  UsdPrimSubtreeRange &operator=(const ForwardRange &r);
1980 
1982  iterator begin() const;
1983 
1985  iterator end() const;
1986 
1988  operator unspecified_bool_type() const;
1989 
1991  bool equal(const iterator_range&) const;
1992 
1994  reference front() const;
1995 
1997  iterator_range& advance_begin(difference_type n);
1998 
2000  iterator_range& advance_end(difference_type n);
2001 
2003  bool empty() const;
2004 
2005 private:
2007  friend bool operator==(const UsdPrimSubtreeRange &lhs,
2008  const UsdPrimSubtreeRange &rhs);
2010  friend bool operator!=(const UsdPrimSubtreeRange &lhs,
2011  const UsdPrimSubtreeRange &rhs);
2012 };
2013 
2014 #else
2015 
2016 // Subtree iterator class. Converts ref to weak and filters according to a
2017 // supplied predicate.
2018 class UsdPrimSubtreeIterator : public boost::iterator_adaptor<
2019  UsdPrimSubtreeIterator, // crtp base.
2020  const Usd_PrimData *, // base iterator.
2021  UsdPrim, // value type.
2022  boost::forward_traversal_tag, // traversal
2023  UsdPrim> // reference type.
2024 {
2025 public:
2026  // Default ctor.
2028 
2029 private:
2030  friend class UsdPrim;
2031 
2032  // Constructor used by Prim.
2033  UsdPrimSubtreeIterator(const base_type &i, const SdfPath &proxyPrimPath,
2034  const Usd_PrimFlagsPredicate &predicate)
2035  : iterator_adaptor_(i)
2036  , _proxyPrimPath(proxyPrimPath)
2037  , _predicate(predicate) {
2038  // Need to advance iterator to first matching element.
2039  base_type &base = base_reference();
2040  if (base && !Usd_EvalPredicate(_predicate, base, _proxyPrimPath)) {
2041  if (Usd_MoveToNextSiblingOrParent(base, _proxyPrimPath,
2042  _predicate)) {
2043  base = nullptr;
2044  _proxyPrimPath = SdfPath();
2045  }
2046  }
2047  }
2048 
2049  // Core implementation invoked by iterator_adaptor.
2050  friend class boost::iterator_core_access;
2051  bool equal(const UsdPrimSubtreeIterator &other) const {
2052  return base() == other.base() &&
2053  _proxyPrimPath == other._proxyPrimPath &&
2054  _predicate == other._predicate;
2055  }
2056 
2057  void increment() {
2058  base_type &base = base_reference();
2059  if (!Usd_MoveToChild(base, _proxyPrimPath, _predicate)) {
2060  while (Usd_MoveToNextSiblingOrParent(base, _proxyPrimPath,
2061  _predicate)) {}
2062  }
2063  }
2064 
2065  reference dereference() const {
2066  return UsdPrim(base(), _proxyPrimPath);
2067  }
2068 
2069  SdfPath _proxyPrimPath;
2070  Usd_PrimFlagsPredicate _predicate;
2071 };
2072 
2073 // Typedef iterator range.
2074 typedef boost::iterator_range<UsdPrimSubtreeIterator> UsdPrimSubtreeRange;
2075 
2076 // Inform TfIterator it should feel free to make copies of the range type.
2077 template <>
2078 struct Tf_ShouldIterateOverCopy<
2079  UsdPrimSubtreeRange> : boost::true_type {};
2080 template <>
2081 struct Tf_ShouldIterateOverCopy<
2082  const UsdPrimSubtreeRange> : boost::true_type {};
2083 
2084 #endif // doxygen
2085 
2087 UsdPrim::GetFilteredDescendants(const Usd_PrimFlagsPredicate &pred) const
2088 {
2089  return _MakeDescendantsRange(
2090  Usd_CreatePredicateForTraversal(_Prim(), _ProxyPrimPath(), pred));
2091 }
2092 
2095 {
2097 }
2098 
2101 {
2103 }
2104 
2105 // Helper to make a sibling range.
2107 UsdPrim::_MakeDescendantsRange(const Usd_PrimFlagsPredicate &pred) const {
2108  Usd_PrimDataConstPtr firstChild = get_pointer(_Prim());
2109  SdfPath firstChildPath = _ProxyPrimPath();
2110  Usd_PrimDataConstPtr endChild = firstChild;
2111  SdfPath endChildPath = firstChildPath;
2112  if (Usd_MoveToChild(firstChild, firstChildPath, pred)) {
2113  while (Usd_MoveToNextSiblingOrParent(endChild, endChildPath, pred)) {}
2114  }
2115 
2116  return SubtreeRange(
2117  SubtreeIterator(firstChild, firstChildPath, pred),
2118  SubtreeIterator(endChild, endChildPath, pred));
2119 }
2120 
2121 
2123 // UsdObject methods that require UsdPrim be a complete type.
2124 
2125 inline UsdPrim
2127 {
2128  return UsdPrim(_prim, _proxyPrimPath);
2129 }
2130 
2131 PXR_NAMESPACE_CLOSE_SCOPE
2132 
2133 #endif // PXR_USD_USD_PRIM_H
2134 
const UsdPrimTypeInfo & GetPrimTypeInfo() const
Return the prim's full type info composed from its type name, applied API schemas,...
Definition: prim.h:156
void ClearPropertyOrder() const
Remove the opinion for propertyOrder metadata on this prim at the current EditTarget.
Definition: prim.h:439
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:1965
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:1934
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:188
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
}@
Definition: prim.h:643
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:2087
value_type reference
Iterator reference type, in this case the same as value_type.
Definition: prim.h:1932
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:679
bool IsGroup() const
Return true if this prim is a model group based on its kind metadata, false otherwise.
Definition: prim.h:260
SdfSpecifier GetSpecifier() const
Return this prim's composed specifier.
Definition: prim.h:168
UsdPrimSiblingIterator iterator
Iterator type.
Definition: prim.h:1767
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:1040
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:1738
bool IsActive() const
Return true if this prim is active, meaning neither it nor any of its ancestors have active=false.
Definition: prim.h:221
bool ClearInstanceable() const
Remove the authored 'instanceable' opinion at the current EditTarget.
Definition: prim.h:1533
bool HasAuthoredInstanceable() const
Return true if this prim has an authored opinion for 'instanceable', false otherwise.
Definition: prim.h:1539
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:2100
The outermost container for scene description, which owns and presents composed prims as a scenegraph...
Definition: stage.h:146
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:1519
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:1771
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:1548
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:1584
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:1764
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:1959
iterator::value_type value_type
Iterator value_type.
Definition: prim.h:1773
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:433
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:1527
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:799
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:601
reference operator *() const
Dereference.
unspecified integral type difference_type
Iterator difference type.
Definition: prim.h:1742
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:163
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:1640
UsdPrimSubtreeIterator & operator++()
Postincrement.
bool IsAbstract() const
Return true if this prim or any of its ancestors is a class.
Definition: prim.h:263
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:719
Forward iterator range of sibling UsdPrim s.
Definition: prim.h:1956
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:1057
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:1890
SiblingRange GetChildren() const
Return this prim's active, loaded, defined, non-abstract children as an iterable range.
Definition: prim.h:1903
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:525
SdfSpecifier
An enum that identifies the possible specifiers for an SdfPrimSpec.
Definition: types.h:123
UsdPrim value_type
Iterator value type.
Definition: prim.h:1930
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:1553
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:199
SubtreeRange GetAllDescendants() const
Return all this prim's descendants as an iterable range.
Definition: prim.h:2094
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:1967
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:244
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:208
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:1897
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:842
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:1597
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:236
bool SetTypeName(const TfToken &typeName) const
Author this Prim's typeName at the current EditTarget.
Definition: prim.h:202
An forward-iterable range that traverses a subtree of prims rooted at a given prim in depth-first ord...
Definition: primRange.h: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:213
void ClearChildrenReorder() const
Remove the opinion for the metadata used to reorder children of this prim at the current EditTarget.
Definition: prim.h:1046
bool IsModel() const
Return true if this prim is a model based on its kind metadata, false otherwise.
Definition: prim.h:255
bool IsLoaded() const
Return true if this prim is active, and either it is loadable and it is loaded, or its nearest loadab...
Definition: prim.h:251
unspecified integral type difference_type
Iterator difference type.
Definition: prim.h:1963
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:1578
Forward traversal iterator of sibling UsdPrim s.
Definition: prim.h:1927
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:287
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:267
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:1769
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:227
UsdPrimSubtreeIterator const_iterator
Const iterator type.
Definition: prim.h:1961
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:1775
Forward traversal iterator of sibling UsdPrim s.
Definition: prim.h:1735
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:2126
std::enable_if< T::schemaKind !=UsdSchemaKind::MultipleApplyAPI, bool >::type HasAPI() const
Using HasAPI in C++
Definition: prim.h:574
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:1740
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:761
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:271
USD_API std::vector< UsdProperty > GetAuthoredProperties(const PropertyPredicateFunc &predicate={}) const
Return this prim's properties (attributes and relationships) that have authored scene description,...