All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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  // The non-templated implementation of UsdPrim::HasAPI using the
480  // TfType system.
481  //
482  // \p validateSchemaType is provided for python clients
483  // because they can't use compile time assertions on the input type.
484  //
485  // \p instanceName is used to determine whether a particular instance
486  // of a multiple-apply API schema has been applied to the prim.
487  USD_API
488  bool _HasAPI(const TfType& schemaType, bool validateSchemaType,
489  const TfToken &instanceName) const;
490 
491  // Private implementation for all ApplyAPI, CanApplyAPI, and RemoveAPI
492  // methods for both single apply and multiple apply APIs. The multiple
493  // apply API methods validate that the instance name is non-empty, but
494  // otherwise all of these methods do no other input validation as the
495  // public methods are expected to have already done either compile time or
496  // runtime validation already.
497  USD_API
498  bool _CanApplyAPI(const TfType& schemaType,
499  std::string *whyNot) const;
500 
501  USD_API
502  bool _CanApplyAPI(const TfType& schemaType,
503  const TfToken& instanceName,
504  std::string *whyNot) const;
505 
506  USD_API
507  bool _ApplyAPI(const TfType& schemaType) const;
508 
509  USD_API
510  bool _ApplyAPI(const TfType& schemaType,
511  const TfToken& instanceName) const;
512 
513  USD_API
514  bool _RemoveAPI(const TfType& schemaType) const;
515 
516  USD_API
517  bool _RemoveAPI(const TfType& schemaType,
518  const TfToken& instanceName) const;
519 
520 public:
525  template <typename T>
526  bool IsA() const {
527  static_assert(std::is_base_of<UsdSchemaBase, T>::value,
528  "Provided type must derive UsdSchemaBase.");
529  return _IsA(TfType::Find<T>(), /*validateSchemaType=*/false);
530  };
531 
536  USD_API
537  bool IsA(const TfType& schemaType) const;
538 
576  template <typename T>
577  bool HasAPI(const TfToken &instanceName=TfToken()) const {
578  static_assert(std::is_base_of<UsdAPISchemaBase, T>::value,
579  "Provided type must derive UsdAPISchemaBase.");
580  static_assert(!std::is_same<UsdAPISchemaBase, T>::value,
581  "Provided type must not be UsdAPISchemaBase.");
582  static_assert(
583  (T::schemaKind == UsdSchemaKind::SingleApplyAPI
584  || T::schemaKind == UsdSchemaKind::MultipleApplyAPI),
585  "Provided schema type must be an applied API schema.");
586 
587  if (T::schemaKind != UsdSchemaKind::MultipleApplyAPI
588  && !instanceName.IsEmpty()) {
589  TF_CODING_ERROR("HasAPI: single application API schemas like %s do "
590  "not contain an application instanceName ( %s ).",
591  TfType::GetCanonicalTypeName(typeid(T)).c_str(),
592  instanceName.GetText());
593  return false;
594  }
595 
596  return _HasAPI(TfType::Find<T>(), /*validateSchemaType=*/false,
597  instanceName);
598  }
599 
607  USD_API
608  bool HasAPI(const TfType& schemaType,
609  const TfToken& instanceName=TfToken()) const;
610 
623  template <typename SchemaType>
624  bool CanApplyAPI(std::string *whyNot = nullptr) const {
625  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
626  "Provided type must derive UsdAPISchemaBase.");
627  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
628  "Provided type must not be UsdAPISchemaBase.");
629  static_assert(SchemaType::schemaKind == UsdSchemaKind::SingleApplyAPI,
630  "Provided schema type must be a single apply API schema.");
631 
632  static const TfType schemaType = TfType::Find<SchemaType>();
633  return _CanApplyAPI(schemaType, whyNot);
634  }
635 
642  USD_API
643  bool CanApplyAPI(const TfType& schemaType,
644  std::string *whyNot = nullptr) const;
645 
659  template <typename SchemaType>
660  bool CanApplyAPI(const TfToken &instanceName,
661  std::string *whyNot = nullptr) const {
662  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
663  "Provided type must derive UsdAPISchemaBase.");
664  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
665  "Provided type must not be UsdAPISchemaBase.");
666  static_assert(SchemaType::schemaKind == UsdSchemaKind::MultipleApplyAPI,
667  "Provided schema type must be a multiple apply API schema.");
668 
669  static const TfType schemaType = TfType::Find<SchemaType>();
670  return _CanApplyAPI(schemaType, instanceName, whyNot);
671  }
672 
679  USD_API
680  bool CanApplyAPI(const TfType& schemaType,
681  const TfToken& instanceName,
682  std::string *whyNot = nullptr) const;
683 
699  template <typename SchemaType>
700  bool ApplyAPI() const {
701  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
702  "Provided type must derive UsdAPISchemaBase.");
703  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
704  "Provided type must not be UsdAPISchemaBase.");
705  static_assert(SchemaType::schemaKind == UsdSchemaKind::SingleApplyAPI,
706  "Provided schema type must be a single apply API schema.");
707 
708  static const TfType schemaType = TfType::Find<SchemaType>();
709  return _ApplyAPI(schemaType);
710  }
711 
718  USD_API
719  bool ApplyAPI(const TfType& schemaType) const;
720 
741  template <typename SchemaType>
742  bool ApplyAPI(const TfToken &instanceName) const {
743  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
744  "Provided type must derive UsdAPISchemaBase.");
745  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
746  "Provided type must not be UsdAPISchemaBase.");
747  static_assert(SchemaType::schemaKind == UsdSchemaKind::MultipleApplyAPI,
748  "Provided schema type must be a multiple apply API schema.");
749 
750  static const TfType schemaType = TfType::Find<SchemaType>();
751  return _ApplyAPI(schemaType, instanceName);
752  }
753 
760  USD_API
761  bool ApplyAPI(const TfType& schemaType, const TfToken& instanceName) const;
762 
779  template <typename SchemaType>
780  bool RemoveAPI() const {
781  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
782  "Provided type must derive UsdAPISchemaBase.");
783  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
784  "Provided type must not be UsdAPISchemaBase.");
785  static_assert(SchemaType::schemaKind == UsdSchemaKind::SingleApplyAPI,
786  "Provided schema type must be a single apply API schema.");
787 
788  static const TfType schemaType = TfType::Find<SchemaType>();
789  return _RemoveAPI(schemaType);
790  }
791 
798  USD_API
799  bool RemoveAPI(const TfType& schemaType) const;
800 
822  template <typename SchemaType>
823  bool RemoveAPI(const TfToken &instanceName) const {
824  static_assert(std::is_base_of<UsdAPISchemaBase, SchemaType>::value,
825  "Provided type must derive UsdAPISchemaBase.");
826  static_assert(!std::is_same<UsdAPISchemaBase, SchemaType>::value,
827  "Provided type must not be UsdAPISchemaBase.");
828  static_assert(SchemaType::schemaKind == UsdSchemaKind::MultipleApplyAPI,
829  "Provided schema type must be a multiple apply API schema.");
830 
831  static const TfType schemaType = TfType::Find<SchemaType>();
832  return _RemoveAPI(schemaType, instanceName);
833  }
834 
841  USD_API
842  bool RemoveAPI(const TfType& schemaType,
843  const TfToken& instanceName) const;
844 
868  USD_API
869  bool AddAppliedSchema(const TfToken &appliedSchemaName) const;
870 
895  USD_API
896  bool RemoveAppliedSchema(const TfToken &appliedSchemaName) const;
897 
898  // --------------------------------------------------------------------- //
900  // --------------------------------------------------------------------- //
901 
907  USD_API
908  UsdPrim GetChild(const TfToken &name) const;
909 
918  inline SiblingRange GetChildren() const;
919 
921  inline SiblingRange GetAllChildren() const;
922 
942  inline SiblingRange
943  GetFilteredChildren(const Usd_PrimFlagsPredicate &predicate) const;
944 
947  USD_API
949 
952  USD_API
954 
957  USD_API
959  const Usd_PrimFlagsPredicate &predicate) const;
960 
973  inline SubtreeRange GetDescendants() const;
974 
983  inline SubtreeRange GetAllDescendants() const;
984 
1008  inline SubtreeRange
1009  GetFilteredDescendants(const Usd_PrimFlagsPredicate &predicate) const;
1010 
1016  USD_API
1018 
1021  void SetChildrenReorder(const TfTokenVector &order) const {
1022  SetMetadata(SdfFieldKeys->PrimOrder, order);
1023  }
1024 
1027  void ClearChildrenReorder() const {
1028  ClearMetadata(SdfFieldKeys->PrimOrder);
1029  }
1030 
1031 public:
1032  // --------------------------------------------------------------------- //
1034  // --------------------------------------------------------------------- //
1035 
1038  UsdPrim GetParent() const {
1039  Usd_PrimDataConstPtr prim = get_pointer(_Prim());
1040  SdfPath proxyPrimPath = _ProxyPrimPath();
1041  Usd_MoveToParent(prim, proxyPrimPath);
1042  return UsdPrim(prim, proxyPrimPath);
1043  }
1044 
1053  USD_API
1054  UsdPrim GetNextSibling() const;
1055 
1061  USD_API
1063  const Usd_PrimFlagsPredicate &predicate) const;
1064 
1071  USD_API
1072  bool IsPseudoRoot() const;
1073 
1077  USD_API UsdPrim GetPrimAtPath(const SdfPath& path) const;
1078 
1082  USD_API UsdObject GetObjectAtPath(const SdfPath& path) const;
1083 
1092  USD_API UsdProperty GetPropertyAtPath(const SdfPath& path) const;
1093 
1102  USD_API UsdAttribute GetAttributeAtPath(const SdfPath& path) const;
1103 
1112  USD_API UsdRelationship GetRelationshipAtPath(const SdfPath& path) const;
1113 
1114  // --------------------------------------------------------------------- //
1116  // --------------------------------------------------------------------- //
1117 
1123  USD_API
1125 
1133  USD_API
1134  UsdVariantSet GetVariantSet(const std::string& variantSetName) const;
1135 
1141  USD_API
1142  bool HasVariantSets() const;
1143 
1144  // --------------------------------------------------------------------- //
1146  // --------------------------------------------------------------------- //
1147 
1187  USD_API
1188  UsdAttribute
1189  CreateAttribute(const TfToken& name,
1190  const SdfValueTypeName &typeName,
1191  bool custom,
1192  SdfVariability variability = SdfVariabilityVarying) const;
1195  USD_API
1196  UsdAttribute
1197  CreateAttribute(const TfToken& name,
1198  const SdfValueTypeName &typeName,
1199  SdfVariability variability = SdfVariabilityVarying) const;
1200 
1205  USD_API
1207  const std::vector<std::string> &nameElts,
1208  const SdfValueTypeName &typeName,
1209  bool custom,
1210  SdfVariability variability = SdfVariabilityVarying) const;
1214  USD_API
1216  const std::vector<std::string> &nameElts,
1217  const SdfValueTypeName &typeName,
1218  SdfVariability variability = SdfVariabilityVarying) const;
1219 
1221  USD_API
1222  std::vector<UsdAttribute> GetAttributes() const;
1223 
1226  USD_API
1227  std::vector<UsdAttribute> GetAuthoredAttributes() const;
1228 
1241  USD_API
1242  UsdAttribute GetAttribute(const TfToken& attrName) const;
1243 
1246  USD_API
1247  bool HasAttribute(const TfToken& attrName) const;
1248 
1254  USD_API
1255  SdfPathVector
1257  std::function<bool (UsdAttribute const &)> const &pred = nullptr,
1258  bool recurseOnSources = false) const;
1259 
1260  // --------------------------------------------------------------------- //
1262  // --------------------------------------------------------------------- //
1263 
1300  USD_API
1302  bool custom=true) const;
1303 
1308  USD_API
1309  UsdRelationship CreateRelationship(const std::vector<std::string> &nameElts,
1310  bool custom=true)
1311  const;
1312 
1314  USD_API
1315  std::vector<UsdRelationship> GetRelationships() const;
1316 
1319  USD_API
1320  std::vector<UsdRelationship> GetAuthoredRelationships() const;
1321 
1334  USD_API
1335  UsdRelationship GetRelationship(const TfToken& relName) const;
1336 
1339  USD_API
1340  bool HasRelationship(const TfToken& relName) const;
1341 
1348  USD_API
1349  SdfPathVector
1351  std::function<bool (UsdRelationship const &)> const &pred = nullptr,
1352  bool recurseOnTargets = false) const;
1353 
1354  // --------------------------------------------------------------------- //
1361  // --------------------------------------------------------------------- //
1362 
1366  USD_API
1367  bool ClearPayload() const;
1368 
1373  USD_API
1374  bool HasPayload() const;
1375 
1381  USD_API
1382  bool SetPayload(const SdfPayload& payload) const;
1383 
1386  USD_API
1387  bool SetPayload(
1388  const std::string& assetPath, const SdfPath& primPath) const;
1389 
1393  USD_API
1394  bool SetPayload(const SdfLayerHandle& layer, const SdfPath& primPath) const;
1395 
1397 
1398  // --------------------------------------------------------------------- //
1400  // --------------------------------------------------------------------- //
1401 
1409  USD_API
1410  UsdPayloads GetPayloads() const;
1411 
1413  USD_API
1414  bool HasAuthoredPayloads() const;
1415 
1421  USD_API
1422  void Load(UsdLoadPolicy policy = UsdLoadWithDescendants) const;
1423 
1427  USD_API
1428  void Unload() const;
1429 
1430  // --------------------------------------------------------------------- //
1432  // --------------------------------------------------------------------- //
1433 
1443  USD_API
1444  UsdReferences GetReferences() const;
1445 
1447  USD_API
1448  bool HasAuthoredReferences() const;
1449 
1450  // --------------------------------------------------------------------- //
1452  // --------------------------------------------------------------------- //
1453 
1463  USD_API
1464  UsdInherits GetInherits() const;
1465 
1467  USD_API
1468  bool HasAuthoredInherits() const;
1469 
1470  // --------------------------------------------------------------------- //
1472  // --------------------------------------------------------------------- //
1473 
1481  USD_API
1483 
1485  USD_API
1486  bool HasAuthoredSpecializes() const;
1487 
1488  // --------------------------------------------------------------------- //
1492  // --------------------------------------------------------------------- //
1493 
1500  bool IsInstanceable() const {
1501  bool instanceable = false;
1502  return GetMetadata(SdfFieldKeys->Instanceable, &instanceable) &&
1503  instanceable;
1504  }
1505 
1508  bool SetInstanceable(bool instanceable) const {
1509  return SetMetadata(SdfFieldKeys->Instanceable, instanceable);
1510  }
1511 
1514  bool ClearInstanceable() const {
1515  return ClearMetadata(SdfFieldKeys->Instanceable);
1516  }
1517 
1521  return HasAuthoredMetadata(SdfFieldKeys->Instanceable);
1522  }
1523 
1529  bool IsInstance() const { return _Prim()->IsInstance(); }
1530 
1534  bool IsInstanceProxy() const {
1535  return Usd_IsInstanceProxy(_Prim(), _ProxyPrimPath());
1536  }
1537 
1545  USD_API
1546  static bool IsPrototypePath(const SdfPath& path);
1547 
1552  USD_API
1553  static bool IsPathInPrototype(const SdfPath& path);
1554 
1559  bool IsPrototype() const { return _Prim()->IsPrototype(); }
1560 
1565  bool IsInPrototype() const {
1566  return (IsInstanceProxy() ?
1567  IsPathInPrototype(GetPrimPath()) : _Prim()->IsInPrototype());
1568  }
1569 
1572  USD_API
1573  UsdPrim GetPrototype() const;
1574 
1579  if (IsInstanceProxy()) {
1580  return UsdPrim(_Prim(), SdfPath());
1581  }
1582  return UsdPrim();
1583  }
1584 
1590  USD_API
1591  std::vector<UsdPrim> GetInstances() const;
1593 
1594  // --------------------------------------------------------------------- //
1597  // --------------------------------------------------------------------- //
1598 
1621  const PcpPrimIndex &GetPrimIndex() const { return _Prim()->GetPrimIndex(); }
1622 
1636  USD_API
1638 
1640 
1641 private:
1642  friend class UsdObject;
1643  friend class UsdPrimSiblingIterator;
1644  friend class UsdPrimSubtreeIterator;
1645  friend class UsdProperty;
1646  friend class UsdSchemaBase;
1647  friend class UsdAPISchemaBase;
1648  friend class UsdStage;
1649  friend class UsdPrimRange;
1650  friend class Usd_PrimData;
1651  friend class Usd_PrimFlagsPredicate;
1652  friend struct UsdPrim_RelTargetFinder;
1653  friend struct UsdPrim_AttrConnectionFinder;
1654 
1655  // Prim constructor.
1656  UsdPrim(const Usd_PrimDataHandle &primData,
1657  const SdfPath &proxyPrimPath)
1658  : UsdObject(primData, proxyPrimPath) { }
1659 
1660  // General constructor.
1661  UsdPrim(UsdObjType objType,
1662  const Usd_PrimDataHandle &prim,
1663  const SdfPath &proxyPrimPath,
1664  const TfToken &propName)
1665  : UsdObject(objType, prim, proxyPrimPath, propName) {}
1666 
1667  // Helper to make a sibling range.
1668  inline SiblingRange
1669  _MakeSiblingRange(const Usd_PrimFlagsPredicate &pred) const;
1670 
1671  // Helper to make a range of descendants.
1672  inline SubtreeRange
1673  _MakeDescendantsRange(const Usd_PrimFlagsPredicate &pred) const;
1674 
1675  // Helper to make a vector of properties from names.
1676  std::vector<UsdProperty>
1677  _MakeProperties(const TfTokenVector &names) const;
1678 
1679  // Helper for Get{Authored}{PropertyNames,Properties}
1680  TfTokenVector _GetPropertyNames(
1681  bool onlyAuthored,
1682  bool applyOrder=true,
1683  const PropertyPredicateFunc &predicate={}) const;
1684 
1685  // Helper for Get(Authored)PropertiesInNamespace.
1686  std::vector<UsdProperty>
1687  _GetPropertiesInNamespace(const std::string &namespaces,
1688  bool onlyAuthored) const;
1689 
1690  // Helper for Get(Authored)Attributes.
1691  std::vector<UsdAttribute>
1692  _GetAttributes(bool onlyAuthored, bool applyOrder=false) const;
1693 
1694  // Helper for Get(Authored)Relationships.
1695  std::vector<UsdRelationship>
1696  _GetRelationships(bool onlyAuthored, bool applyOrder=false) const;
1697 
1698  friend const PcpPrimIndex &Usd_PrimGetSourcePrimIndex(const UsdPrim&);
1699  // Return a const reference to the source PcpPrimIndex for this prim.
1700  //
1701  // For all prims in prototypes (which includes the prototype prim itself),
1702  // this is the prim index for the instance that was chosen to serve
1703  // as the prototype for all other instances. This prim index will not
1704  // have the same path as the prim's path.
1705  //
1706  // This is a private helper but is also wrapped out to Python
1707  // for testing and debugging purposes.
1708  const PcpPrimIndex &_GetSourcePrimIndex() const
1709  { return _Prim()->GetSourcePrimIndex(); }
1710 };
1711 
1712 #ifdef doxygen
1713 
1717 public:
1723  typedef unspecified-integral-type difference_type;
1725  reference operator*() const;
1727  unspecified-type operator->() const;
1732 private:
1734  friend bool operator==(const UsdPrimSiblingIterator &lhs,
1735  const UsdPrimSiblingIterator &rhs);
1737  friend bool operator!=(const UsdPrimSiblingIterator &lhs,
1738  const UsdPrimSiblingIterator &rhs);
1739 };
1740 
1746 public:
1752  typedef unspecified-integral-type difference_type;
1757 
1761 
1763  template <class ForwardRange>
1764  UsdPrimSiblingRange(const ForwardRange &r);
1765 
1767  template <class ForwardRange>
1768  UsdPrimSiblingRange &operator=(const ForwardRange &r);
1769 
1771  iterator begin() const;
1772 
1774  iterator end() const;
1775 
1777  operator unspecified_bool_type() const;
1778 
1780  bool equal(const iterator_range&) const;
1781 
1783  reference front() const;
1784 
1786  iterator_range& advance_begin(difference_type n);
1787 
1789  iterator_range& advance_end(difference_type n);
1790 
1791  ;
1792  bool empty() const;
1793 
1794 private:
1796  friend bool operator==(const UsdPrimSiblingRange &lhs,
1797  const UsdPrimSiblingRange &rhs);
1799  friend bool operator!=(const UsdPrimSiblingRange &lhs,
1800  const UsdPrimSiblingRange &rhs);
1801 };
1802 
1803 #else
1804 
1805 // Sibling iterator class. Converts ref to weak and filters according to a
1806 // supplied predicate.
1807 class UsdPrimSiblingIterator : public boost::iterator_adaptor<
1808  UsdPrimSiblingIterator, // crtp base.
1809  const Usd_PrimData *, // base iterator.
1810  UsdPrim, // value type.
1811  boost::forward_traversal_tag, // traversal
1812  UsdPrim> // reference type.
1813 {
1814 public:
1815  // Default ctor.
1817 
1818 private:
1819  friend class UsdPrim;
1820 
1821  // Constructor used by Prim.
1822  UsdPrimSiblingIterator(const base_type &i, const SdfPath& proxyPrimPath,
1823  const Usd_PrimFlagsPredicate &predicate)
1824  : iterator_adaptor_(i)
1825  , _proxyPrimPath(proxyPrimPath)
1826  , _predicate(predicate) {
1827  // Need to advance iterator to first matching element.
1828  if (base() && !Usd_EvalPredicate(_predicate, base(), _proxyPrimPath))
1829  increment();
1830  }
1831 
1832  // Core implementation invoked by iterator_adaptor.
1833  friend class boost::iterator_core_access;
1834  bool equal(const UsdPrimSiblingIterator &other) const {
1835  return base() == other.base() &&
1836  _proxyPrimPath == other._proxyPrimPath &&
1837  _predicate == other._predicate;
1838  }
1839 
1840  void increment() {
1841  base_type &base = base_reference();
1842  if (Usd_MoveToNextSiblingOrParent(base, _proxyPrimPath, _predicate)) {
1843  base = nullptr;
1844  _proxyPrimPath = SdfPath();
1845  }
1846  }
1847 
1848  reference dereference() const {
1849  return UsdPrim(base(), _proxyPrimPath);
1850  }
1851 
1852  SdfPath _proxyPrimPath;
1853  Usd_PrimFlagsPredicate _predicate;
1854 };
1855 
1856 // Typedef iterator range.
1857 typedef boost::iterator_range<UsdPrimSiblingIterator> UsdPrimSiblingRange;
1858 
1859 // Inform TfIterator it should feel free to make copies of the range type.
1860 template <>
1861 struct Tf_ShouldIterateOverCopy<
1862  UsdPrimSiblingRange> : boost::true_type {};
1863 template <>
1864 struct Tf_ShouldIterateOverCopy<
1865  const UsdPrimSiblingRange> : boost::true_type {};
1866 
1867 #endif // doxygen
1868 
1869 
1870 UsdPrimSiblingRange
1871 UsdPrim::GetFilteredChildren(const Usd_PrimFlagsPredicate &pred) const
1872 {
1873  return _MakeSiblingRange(
1874  Usd_CreatePredicateForTraversal(_Prim(), _ProxyPrimPath(), pred));
1875 }
1876 
1877 UsdPrimSiblingRange
1879 {
1881 }
1882 
1883 UsdPrimSiblingRange
1885 {
1887 }
1888 
1889 // Helper to make a sibling range.
1891 UsdPrim::_MakeSiblingRange(const Usd_PrimFlagsPredicate &pred) const {
1892  Usd_PrimDataConstPtr firstChild = get_pointer(_Prim());
1893  SdfPath firstChildPath = _ProxyPrimPath();
1894  if (!Usd_MoveToChild(firstChild, firstChildPath, pred)) {
1895  firstChild = nullptr;
1896  firstChildPath = SdfPath();
1897  }
1898 
1899  return SiblingRange(
1900  SiblingIterator(firstChild, firstChildPath, pred),
1901  SiblingIterator(nullptr, SdfPath(), pred));
1902 }
1903 
1904 #ifdef doxygen
1905 
1909 public:
1915  typedef unspecified-integral-type difference_type;
1917  reference operator*() const;
1919  unspecified-type operator->() const;
1924 private:
1926  friend bool operator==(const UsdPrimSubtreeIterator &lhs,
1927  const UsdPrimSubtreeIterator &rhs);
1929  friend bool operator!=(const UsdPrimSubtreeIterator &lhs,
1930  const UsdPrimSubtreeIterator &rhs);
1931 };
1932 
1938 public:
1944  typedef unspecified-integral-type difference_type;
1949 
1953 
1955  template <class ForwardRange>
1956  UsdPrimSubtreeRange(const ForwardRange &r);
1957 
1959  template <class ForwardRange>
1960  UsdPrimSubtreeRange &operator=(const ForwardRange &r);
1961 
1963  iterator begin() const;
1964 
1966  iterator end() const;
1967 
1969  operator unspecified_bool_type() const;
1970 
1972  bool equal(const iterator_range&) const;
1973 
1975  reference front() const;
1976 
1978  iterator_range& advance_begin(difference_type n);
1979 
1981  iterator_range& advance_end(difference_type n);
1982 
1984  bool empty() const;
1985 
1986 private:
1988  friend bool operator==(const UsdPrimSubtreeRange &lhs,
1989  const UsdPrimSubtreeRange &rhs);
1991  friend bool operator!=(const UsdPrimSubtreeRange &lhs,
1992  const UsdPrimSubtreeRange &rhs);
1993 };
1994 
1995 #else
1996 
1997 // Subtree iterator class. Converts ref to weak and filters according to a
1998 // supplied predicate.
1999 class UsdPrimSubtreeIterator : public boost::iterator_adaptor<
2000  UsdPrimSubtreeIterator, // crtp base.
2001  const Usd_PrimData *, // base iterator.
2002  UsdPrim, // value type.
2003  boost::forward_traversal_tag, // traversal
2004  UsdPrim> // reference type.
2005 {
2006 public:
2007  // Default ctor.
2009 
2010 private:
2011  friend class UsdPrim;
2012 
2013  // Constructor used by Prim.
2014  UsdPrimSubtreeIterator(const base_type &i, const SdfPath &proxyPrimPath,
2015  const Usd_PrimFlagsPredicate &predicate)
2016  : iterator_adaptor_(i)
2017  , _proxyPrimPath(proxyPrimPath)
2018  , _predicate(predicate) {
2019  // Need to advance iterator to first matching element.
2020  base_type &base = base_reference();
2021  if (base && !Usd_EvalPredicate(_predicate, base, _proxyPrimPath)) {
2022  if (Usd_MoveToNextSiblingOrParent(base, _proxyPrimPath,
2023  _predicate)) {
2024  base = nullptr;
2025  _proxyPrimPath = SdfPath();
2026  }
2027  }
2028  }
2029 
2030  // Core implementation invoked by iterator_adaptor.
2031  friend class boost::iterator_core_access;
2032  bool equal(const UsdPrimSubtreeIterator &other) const {
2033  return base() == other.base() &&
2034  _proxyPrimPath == other._proxyPrimPath &&
2035  _predicate == other._predicate;
2036  }
2037 
2038  void increment() {
2039  base_type &base = base_reference();
2040  if (!Usd_MoveToChild(base, _proxyPrimPath, _predicate)) {
2041  while (Usd_MoveToNextSiblingOrParent(base, _proxyPrimPath,
2042  _predicate)) {}
2043  }
2044  }
2045 
2046  reference dereference() const {
2047  return UsdPrim(base(), _proxyPrimPath);
2048  }
2049 
2050  SdfPath _proxyPrimPath;
2051  Usd_PrimFlagsPredicate _predicate;
2052 };
2053 
2054 // Typedef iterator range.
2055 typedef boost::iterator_range<UsdPrimSubtreeIterator> UsdPrimSubtreeRange;
2056 
2057 // Inform TfIterator it should feel free to make copies of the range type.
2058 template <>
2059 struct Tf_ShouldIterateOverCopy<
2060  UsdPrimSubtreeRange> : boost::true_type {};
2061 template <>
2062 struct Tf_ShouldIterateOverCopy<
2063  const UsdPrimSubtreeRange> : boost::true_type {};
2064 
2065 #endif // doxygen
2066 
2067 UsdPrimSubtreeRange
2068 UsdPrim::GetFilteredDescendants(const Usd_PrimFlagsPredicate &pred) const
2069 {
2070  return _MakeDescendantsRange(
2071  Usd_CreatePredicateForTraversal(_Prim(), _ProxyPrimPath(), pred));
2072 }
2073 
2074 UsdPrimSubtreeRange
2076 {
2078 }
2079 
2080 UsdPrimSubtreeRange
2082 {
2084 }
2085 
2086 // Helper to make a sibling range.
2088 UsdPrim::_MakeDescendantsRange(const Usd_PrimFlagsPredicate &pred) const {
2089  Usd_PrimDataConstPtr firstChild = get_pointer(_Prim());
2090  SdfPath firstChildPath = _ProxyPrimPath();
2091  Usd_PrimDataConstPtr endChild = firstChild;
2092  SdfPath endChildPath = firstChildPath;
2093  if (Usd_MoveToChild(firstChild, firstChildPath, pred)) {
2094  while (Usd_MoveToNextSiblingOrParent(endChild, endChildPath, pred)) {}
2095  }
2096 
2097  return SubtreeRange(
2098  SubtreeIterator(firstChild, firstChildPath, pred),
2099  SubtreeIterator(endChild, endChildPath, pred));
2100 }
2101 
2102 
2104 // UsdObject methods that require UsdPrim be a complete type.
2105 
2106 inline UsdPrim
2108 {
2109  return UsdPrim(_prim, _proxyPrimPath);
2110 }
2111 
2112 PXR_NAMESPACE_CLOSE_SCOPE
2113 
2114 #endif // PXR_USD_USD_PRIM_H
2115 
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 bool HasAuthoredPayloads() const
Return true if this prim has any authored payloads.
A proxy class for applying listOp edits to the specializes list for a prim.
Definition: specializes.h:51
USD_API UsdAttribute CreateAttribute(const TfToken &name, const SdfValueTypeName &typeName, bool custom, SdfVariability variability=SdfVariabilityVarying) const
Author scene description for the attribute named attrName at the current EditTarget if none already e...
USD_API TfTokenVector GetPropertyOrder() const
Return the strongest propertyOrder metadata value authored on this prim.
SdfSpecifier GetSpecifier() const
Return this prim&#39;s composed specifier.
Definition: prim.h:166
iterator::value_type value_type
Iterator value_type.
Definition: prim.h:1946
SiblingRange GetAllChildren() const
Return all this prim&#39;s children as an iterable range.
Definition: prim.h:1878
USD_API UsdProperty GetPropertyAtPath(const SdfPath &path) const
Returns the property at path on the same stage as this prim.
USD_API UsdPayloads GetPayloads() const
Return a UsdPayloads object that allows one to add, remove, or mutate payloads at the currently set U...
unspecified integral type difference_type
Iterator difference type.
Definition: prim.h:1915
UsdObjType
Enum values to represent the various Usd object types.
Definition: object.h:49
USD_API bool IsPseudoRoot() const
Returns true if the prim is the pseudo root.
USD_API TfTokenVector GetAuthoredPropertyNames(const PropertyPredicateFunc &predicate={}) const
Return this prim&#39;s property names (attributes and relationships) that have authored scene description...
USD_API TfTokenVector GetChildrenNames() const
Return the names of the child prims in the order they appear when iterating over GetChildren.
bool HasAuthoredInstanceable() const
Return true if this prim has an authored opinion for &#39;instanceable&#39;, false otherwise.
Definition: prim.h:1520
USD_API bool HasVariantSets() const
Return true if this prim has any authored VariantSets.
PcpPrimIndex is an index of the all sites of scene description that contribute opinions to a specific...
Definition: primIndex.h:75
SubtreeRange GetDescendants() const
Return this prim&#39;s active, loaded, defined, non-abstract descendants as an iterable range...
Definition: prim.h:2081
unspecified UsdPrimDefaultPredicate
The default predicate used for prim traversals in methods like UsdPrim::GetChildren, UsdStage::Traverse, and by UsdPrimRange.
bool ApplyAPI(const TfToken &instanceName) const
Applies a multiple-apply API schema with the given C++ type &#39;SchemaType&#39; and instance name instanceNa...
Definition: prim.h:742
Standard pointer typedefs.
friend bool operator!=(const UsdPrimSubtreeIterator &lhs, const UsdPrimSubtreeIterator &rhs)
Inequality.
bool ClearInstanceable() const
Remove the authored &#39;instanceable&#39; opinion at the current EditTarget.
Definition: prim.h:1514
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...
iterator begin() const
First iterator.
bool IsAbstract() const
Return true if this prim or any of its ancestors is a class.
Definition: prim.h:261
value_type reference
Iterator reference type, in this case the same as value_type.
Definition: prim.h:1913
friend bool operator==(const UsdPrimSiblingIterator &lhs, const UsdPrimSiblingIterator &rhs)
Equality.
reference operator*() const
Dereference.
bool IsA() const
Return true if the prim&#39;s schema type, is or inherits schema type T.
Definition: prim.h:526
UsdPrimSiblingIterator iterator
Iterator type.
Definition: prim.h:1748
friend bool operator!=(const UsdPrimSiblingRange &lhs, const UsdPrimSiblingRange &rhs)
Inequality comparison.
bool IsInstanceProxy() const
Return true if this prim is an instance proxy, false otherwise.
Definition: prim.h:1534
UsdPrim GetParent() const
Return this prim&#39;s parent prim.
Definition: prim.h:1038
bool ApplyAPI() const
Applies a single-apply API schema with the given C++ type &#39;SchemaType&#39; to this prim in the current ed...
Definition: prim.h:700
void ClearChildrenReorder() const
Remove the opinion for the metadata used to reorder children of this prim at the current EditTarget...
Definition: prim.h:1027
iterator end() const
Past-the-end iterator.
UsdPrim value_type
Iterator value type.
Definition: prim.h:1719
USD_API UsdVariantSet GetVariantSet(const std::string &variantSetName) const
Retrieve a specifically named VariantSet for editing or constructing a UsdEditTarget.
UsdPrim GetPrimInPrototype() const
If this prim is an instance proxy, return the UsdPrim for the corresponding prim in the instance&#39;s pr...
Definition: prim.h:1578
USD_API std::vector< UsdRelationship > GetAuthoredRelationships() const
Like GetRelationships(), but exclude relationships without authored scene description from the result...
USD_API std::vector< UsdProperty > GetPropertiesInNamespace(const std::vector< std::string > &namespaces) const
Return this prim&#39;s properties that are inside the given property namespace ordered according to the s...
bool IsModel() const
Return true if this prim is a model based on its kind metadata, false otherwise.
Definition: prim.h:253
USD_API UsdRelationship GetRelationship(const TfToken &relName) const
Return a UsdRelationship with the name relName.
USD_API TfTokenVector GetAppliedSchemas() const
Return a vector containing the names of API schemas which have been applied to this prim...
friend bool operator!=(const UsdPrimSiblingIterator &lhs, const UsdPrimSiblingIterator &rhs)
Inequality.
#define TF_CODING_ERROR(fmt, args)
Issue an internal programming error, but continue execution.
Definition: diagnostic.h:85
bool ClearTypeName() const
Clear the opinion for this Prim&#39;s typeName at the current edit target.
Definition: prim.h:206
bool HasDefiningSpecifier() const
Return true if this prim has a specifier of type SdfSpecifierDef or SdfSpecifierClass.
Definition: prim.h:269
USD_API bool ClearMetadata(const TfToken &key) const
Clears the authored key&#39;s value at the current EditTarget, returning false on error.
USD_API bool HasAttribute(const TfToken &attrName) const
Return true if this prim has an attribute named attrName, false otherwise.
USD_API bool AddAppliedSchema(const TfToken &appliedSchemaName) const
Adds the applied API schema name token appliedSchemaName to the apiSchemas metadata for this prim at ...
The outermost container for scene description, which owns and presents composed prims as a scenegraph...
Definition: stage.h:145
reference front() const
Return *begin(). This range must not be empty.
friend bool operator==(const UsdPrimSiblingRange &lhs, const UsdPrimSiblingRange &rhs)
Equality comparison.
Represents a value type name, i.e.
Definition: valueTypeName.h:87
void ClearPropertyOrder() const
Remove the opinion for propertyOrder metadata on this prim at the current EditTarget.
Definition: prim.h:437
Load a prim plus all its descendants.
Definition: common.h:118
A proxy class for applying listOp edits to the inherit paths list for a prim.
Definition: inherits.h:51
friend bool operator!=(const UsdPrimSubtreeRange &lhs, const UsdPrimSubtreeRange &rhs)
Inequality comparison.
static USD_API bool IsPathInPrototype(const SdfPath &path)
Return true if the given path identifies a prototype prim or a prim or property descendant of a proto...
UsdPrimSiblingIterator & operator++()
Postincrement.
bool GetMetadata(const TfToken &key, T *value) const
Resolve the requested metadatum named key into value, returning true on success.
Definition: object.h:723
unspecified integral type difference_type
Iterator difference type.
Definition: prim.h:1752
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(...
The base class for all API schemas.
Scenegraph object for authoring and retrieving numeric, string, and array valued data, sampled over time.
Definition: attribute.h:176
USD_API bool HasAuthoredReferences() const
Return true if this prim has any authored references.
USD_API bool RemoveProperty(const TfToken &propName)
Remove all scene description for the property with the given propName in the current UsdEditTarget...
bool IsPrototype() const
Return true if this prim is an instancing prototype prim, false otherwise.
Definition: prim.h:1559
USD_API UsdPrim GetPrototype() const
If this prim is an instance, return the UsdPrim for the corresponding prototype.
Forward iterator range of sibling UsdPrim s.
Definition: prim.h:1745
USD_API void Load(UsdLoadPolicy policy=UsdLoadWithDescendants) const
Load this prim, all its ancestors, and by default all its descendants.
UsdReferences provides an interface to authoring and introspecting references in Usd.
Definition: references.h:214
bool RemoveAPI(const TfToken &instanceName) const
Removes a multiple-apply API schema with the given C++ type &#39;SchemaType&#39; and instance name instanceNa...
Definition: prim.h:823
USD_API std::vector< UsdPrim > GetInstances() const
If this prim is a prototype prim, returns all prims that are instances of this prototype.
UsdPrimSubtreeIterator iterator
Iterator type.
Definition: prim.h:1940
iterator::value_type value_type
Iterator value_type.
Definition: prim.h:1754
bool HasAuthoredActive() const
Return true if this prim has an authored opinion for &#39;active&#39;, false otherwise.
Definition: prim.h:242
Single Apply API schema.
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:1021
bool IsInPrototype() const
Return true if this prim is a prototype prim or a descendant of a prototype prim, false otherwise...
Definition: prim.h:1565
const UsdPrimTypeInfo & GetPrimTypeInfo() const
Return the prim&#39;s full type info composed from its type name, applied API schemas, and any fallback types defined on the stage for unrecognized prim type names.
Definition: prim.h:154
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:87
SiblingRange GetFilteredChildren(const Usd_PrimFlagsPredicate &predicate) const
Return a subset of all of this prim&#39;s children filtered by predicate as an iterable range...
Definition: prim.h:1871
USD_API bool HasPayload() const
bool SetMetadata(const TfToken &key, const T &value) const
Set metadatum key&#39;s value to value.
Definition: object.h:731
unspecified integral type difference_type
Iterator difference type.
Definition: prim.h:1723
iterator_range & advance_end(difference_type n)
Advance this range&#39;s end iterator.
USD_API UsdPrim GetChild(const TfToken &name) const
Return this prim&#39;s direct child named name if it has one, otherwise return an invalid UsdPrim...
UsdPrimSiblingRange(UsdPrimSiblingIterator begin, UsdPrimSiblingIterator end)
Construct with a pair of iterators.
USD_API std::vector< UsdAttribute > GetAttributes() const
Like GetProperties(), but exclude all relationships from the result.
USD_API UsdPrim GetNextSibling() const
Return this prim&#39;s next active, loaded, defined, non-abstract sibling if it has one, otherwise return an invalid UsdPrim.
USD_API std::vector< UsdRelationship > GetRelationships() const
Like GetProperties(), but exclude all attributes from the result.
void SetPropertyOrder(const TfTokenVector &order) const
Author an opinion for propertyOrder metadata on this prim at the current EditTarget.
Definition: prim.h:431
UsdPrimSubtreeIterator & operator++()
Postincrement.
USD_API SdfPrimSpecHandleVector GetPrimStack() const
Return all the authored SdfPrimSpecs that may contain opinions for this prim in order from strong to ...
bool SetSpecifier(SdfSpecifier specifier) const
Author an opinion for this Prim&#39;s specifier at the current edit target.
Definition: prim.h:186
static TF_API std::string GetCanonicalTypeName(const std::type_info &)
Return the canonical typeName used for a given std::type_info.
USD_API std::vector< UsdProperty > GetAuthoredProperties(const PropertyPredicateFunc &predicate={}) const
Return this prim&#39;s properties (attributes and relationships) that have authored scene description...
A UsdVariantSet represents a single VariantSet in USD (e.g.
Definition: variantSets.h:56
bool SetTypeName(const TfToken &typeName) const
Author this Prim&#39;s typeName at the current EditTarget.
Definition: prim.h:200
USD_API UsdRelationship GetRelationshipAtPath(const SdfPath &path) const
Returns the relationship at path on the same stage as this prim.
UsdPrim GetPrim() const
Return this object if it is a prim, otherwise return this object&#39;s nearest owning prim...
Definition: prim.h:2107
Forward iterator range of sibling UsdPrim s.
Definition: prim.h:1937
bool CanApplyAPI(const TfToken &instanceName, std::string *whyNot=nullptr) const
Returns whether a multiple-apply API schema with the given C++ type &#39;SchemaType&#39; can be applied to th...
Definition: prim.h:660
bool CanApplyAPI(std::string *whyNot=nullptr) const
Returns whether a single-apply API schema with the given C++ type &#39;SchemaType&#39; can be applied to this...
Definition: prim.h:624
const TfToken & GetTypeName() const
Return this prim&#39;s composed type name.
Definition: prim.h:197
Base class for Usd scenegraph objects, providing common API.
Definition: object.h:130
USD_API std::vector< UsdAttribute > GetAuthoredAttributes() const
Like GetAttributes(), but exclude attributes without authored scene description from the result...
Represents a payload and all its meta data.
Definition: payload.h:60
bool empty() const
Return begin() == end().
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a &quot;Prim&quot; as ...
Definition: prim.h:132
UsdPrimSiblingRange & operator=(const ForwardRange &r)
Assign from another compatible range type.
USD_API TfTokenVector GetAllChildrenNames() const
Return the names of the child prims in the order they appear when iterating over GetAllChildren.
SdfSpecifier
An enum that identifies the possible specifiers for an SdfPrimSpec.
Definition: types.h:123
UsdPrim value_type
Iterator value type.
Definition: prim.h:1911
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
friend bool operator==(const UsdPrimSubtreeRange &lhs, const UsdPrimSubtreeRange &rhs)
Equality comparison.
UsdPrimSubtreeRange & operator=(const ForwardRange &r)
Assign from another compatible range type.
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:288
bool HasAuthoredTypeName() const
Return true if a typeName has been authored.
Definition: prim.h:211
USD_API bool RemoveAppliedSchema(const TfToken &appliedSchemaName) const
Removes the applied API schema name token appliedSchemaName from the apiSchemas metadata for this pri...
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
iterator_range & advance_begin(difference_type n)
Advance this range&#39;s begin iterator.
USD_API UsdReferences GetReferences() const
Return a UsdReferences object that allows one to add, remove, or mutate references at the currently s...
iterator::reference reference
Iterator reference_type.
Definition: prim.h:1948
SubtreeRange GetFilteredDescendants(const Usd_PrimFlagsPredicate &predicate) const
Return a subset of all of this prim&#39;s descendants filtered by predicate as an iterable range...
Definition: prim.h:2068
USD_API UsdAttribute GetAttributeAtPath(const SdfPath &path) const
Returns the attribute at path on the same stage as this prim.
UsdPayloads provides an interface to authoring and introspecting payloads.
Definition: payloads.h:43
A UsdRelationship creates dependencies between scenegraph objects by allowing a prim to target other ...
Definition: relationship.h:128
USD_API PcpPrimIndex ComputeExpandedPrimIndex() const
Compute the prim index containing all sites that could contribute opinions to this prim...
USD_API TfTokenVector GetPropertyNames(const PropertyPredicateFunc &predicate={}) const
Return all of this prim&#39;s property names (attributes and relationships), including all builtin proper...
SdfVariability
An enum that identifies variability types for attributes.
Definition: types.h:179
USD_API bool SetPayload(const SdfPayload &payload) const
iterator begin() const
First iterator.
bool SetActive(bool active) const
Author &#39;active&#39; metadata for this prim at the current EditTarget.
Definition: prim.h:225
Class that holds the full type information for a prim.
Definition: primTypeInfo.h:47
bool IsDefined() const
Return true if this prim and all its ancestors have defining specifiers, false otherwise.
Definition: prim.h:265
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
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...
Multiple Apply API Schema.
Base class for UsdAttribute and UsdRelationship scenegraph objects.
Definition: property.h:55
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
USD_API bool HasAuthoredInherits() const
Return true if this prim has any authored inherits.
An forward-iterable range that traverses a subtree of prims rooted at a given prim in depth-first ord...
Definition: primRange.h:118
reference operator*() const
Dereference.
USD_API UsdObject GetObjectAtPath(const SdfPath &path) const
Returns the object at path on the same stage as this prim.
unspecified integral type difference_type
Iterator difference type.
Definition: prim.h:1944
bool RemoveAPI() const
Removes a single-apply API schema with the given C++ type &#39;SchemaType&#39; from this prim in the current ...
Definition: prim.h:780
USD_API UsdVariantSets GetVariantSets() const
Return a UsdVariantSets object representing all the VariantSets present on this prim.
Class representing the builtin definition of a prim given the schemas registered in the schema regist...
USD_API UsdPrim GetPrimAtPath(const SdfPath &path) const
Returns the prim at path on the same stage as this prim.
bool IsInstance() const
Return true if this prim is an instance of a prototype, false otherwise.
Definition: prim.h:1529
unspecified type operator->() const
Indirection.
USD_API bool HasRelationship(const TfToken &relName) const
Return true if this prim has a relationship named relName, false otherwise.
Forward traversal iterator of sibling UsdPrim s.
Definition: prim.h:1908
unspecified UsdPrimAllPrimsPredicate
Predicate that includes all prims.
UsdPrim()
Construct an invalid prim.
Definition: prim.h:144
std::function< bool(const TfToken &propertyName)> PropertyPredicateFunc
Alias for the &quot;predicate&quot; function parameter passed into the various Get{Authored}{PropertyNames,Properties} methods.
Definition: prim.h:285
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...
TfType represents a dynamic runtime type.
Definition: type.h:64
UsdPrimSubtreeIterator SubtreeIterator
Convenience typedefs.
Definition: prim.h:140
const SdfPath & GetPrimPath() const
Return this object&#39;s path if this object is a prim, otherwise this object&#39;s nearest owning prim&#39;s pat...
Definition: object.h:209
reference front() const
Return *begin(). This range must not be empty.
USD_API bool HasProperty(const TfToken &propName) const
Return true if this prim has an property named propName, false otherwise.
USD_API UsdSpecializes GetSpecializes() const
Return a UsdSpecializes object that allows one to add, remove, or mutate specializes at the currently...
bool equal(const iterator_range &) const
Equality compare.
USD_API UsdAttribute GetAttribute(const TfToken &attrName) const
Return a UsdAttribute with the name attrName.
UsdPrimSiblingIterator SiblingIterator
Convenience typedefs.
Definition: prim.h:136
USD_API std::vector< UsdProperty > GetProperties(const PropertyPredicateFunc &predicate={}) const
Return all of this prim&#39;s properties (attributes and relationships), including all builtin properties...
USD_API void Unload() const
Unloads this prim and all its descendants.
UsdPrimSiblingIterator const_iterator
Const iterator type.
Definition: prim.h:1750
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...
bool empty() const
Return begin() == end().
UsdVariantSets represents the collection of VariantSets that are present on a UsdPrim.
Definition: variantSets.h:222
USD_API bool ClearPayload() const
bool SetInstanceable(bool instanceable) const
Author &#39;instanceable&#39; metadata for this prim at the current EditTarget.
Definition: prim.h:1508
UsdPrimSubtreeIterator const_iterator
Const iterator type.
Definition: prim.h:1942
The base class for all schema types in Usd.
Definition: schemaBase.h:56
SiblingRange GetChildren() const
Return this prim&#39;s active, loaded, defined, non-abstract children as an iterable range.
Definition: prim.h:1884
iterator::reference reference
Iterator reference_type.
Definition: prim.h:1756
USD_API UsdInherits GetInherits() const
Return a UsdInherits object that allows one to add, remove, or mutate inherits at the currently set U...
unspecified type operator->() const
Indirection.
Forward traversal iterator of sibling UsdPrim s.
Definition: prim.h:1716
iterator end() const
Past-the-end iterator.
bool equal(const iterator_range &) const
Equality compare.
const UsdPrimDefinition & GetPrimDefinition() const
Return this prim&#39;s definition based on the prim&#39;s type if the type is a registered prim type...
Definition: prim.h:161
SubtreeRange GetAllDescendants() const
Return all this prim&#39;s descendants as an iterable range.
Definition: prim.h:2075
USD_API bool HasAuthoredSpecializes() const
Returns true if this prim has any authored specializes.
iterator_range & advance_end(difference_type n)
Advance this range&#39;s end iterator.
USD_API UsdProperty GetProperty(const TfToken &propName) const
Return a UsdProperty with the name propName.
bool IsGroup() const
Return true if this prim is a model group based on its kind metadata, false otherwise.
Definition: prim.h:258
UsdPrimSubtreeRange(UsdPrimSubtreeIterator begin, UsdPrimSubtreeIterator 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:1621
static USD_API bool IsPrototypePath(const SdfPath &path)
Return true if the given path identifies a prototype prim, false otherwise.
bool ClearActive() const
Remove the authored &#39;active&#39; opinion at the current EditTarget.
Definition: prim.h:234
USD_API TfTokenVector GetChildrenReorder() const
Return the strongest opinion for the metadata used to reorder children of this prim.
value_type reference
Iterator reference type, in this case the same as value_type.
Definition: prim.h:1721
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
bool HasAPI(const TfToken &instanceName=TfToken()) const
Return true if the UsdPrim has had an API schema represented by the C++ class type T applied to it th...
Definition: prim.h:577
bool IsInstanceable() const
Return true if this prim has been marked as instanceable.
Definition: prim.h:1500
iterator_range & advance_begin(difference_type n)
Advance this range&#39;s begin iterator.
USD_API UsdPrim GetFilteredNextSibling(const Usd_PrimFlagsPredicate &predicate) const
Return this prim&#39;s next sibling that matches predicate if it has one, otherwise return the invalid Us...