24 #ifndef PXR_USD_USD_PRIM_DEFINITION_H 25 #define PXR_USD_USD_PRIM_DEFINITION_H 28 #include "pxr/usd/usd/api.h" 29 #include "pxr/usd/usd/schemaRegistry.h" 37 #include <unordered_map> 39 PXR_NAMESPACE_OPEN_SCOPE
59 return _appliedAPISchemas;
67 if (
const _LayerAndPath *layerAndPath =
68 _GetPropertyLayerAndPath(propName)) {
69 return layerAndPath->GetSpecType();
71 return SdfSpecTypeUnknown;
103 return _HasField(attrName, SdfFieldKeys->Default, value);
110 return _ListMetadataFields(
TfToken());
125 return _HasField(
TfToken(), key, value);
138 const TfToken &keyPath, T* value)
const 143 return _HasFieldDictKey(
TfToken(), key, keyPath, value);
173 return _HasField(propName, key, value);
187 const TfToken &keyPath, T* value)
const 192 return _HasFieldDictKey(propName, key, keyPath, value);
224 bool FlattenTo(
const SdfLayerHandle &layer,
226 SdfSpecifier newSpecSpecifier = SdfSpecifierOver)
const;
235 SdfSpecifier newSpecSpecifier = SdfSpecifierOver)
const;
242 SdfSpecifier newSpecSpecifier = SdfSpecifierOver)
const;
263 primDef._HasField(propName, fieldName, value) :
264 primDef._HasFieldDictKey(propName, fieldName, keyPath, value);
269 struct _LayerAndPath {
285 bool HasField(
const TfToken& fieldName, T* value)
const {
286 return layer->
HasField(path, fieldName, value);
290 bool HasFieldDictKey(
291 const TfToken& fieldName,
const TfToken& keyPath, T* value)
const {
303 bool _HasField(
const TfToken& propName,
307 if (
const _LayerAndPath *layerAndPath =
308 _GetPropertyLayerAndPath(propName)) {
309 return layerAndPath->HasField(fieldName, value);
315 bool _HasFieldDictKey(
const TfToken& propName,
320 if (
const _LayerAndPath *layerAndPath =
321 _GetPropertyLayerAndPath(propName)) {
322 return layerAndPath->HasFieldDictKey(fieldName, keyPath, value);
330 void _IntializeForTypedSchema(
331 const SdfLayerHandle &schematicsLayer,
332 const SdfPath &schematicsPrimPath,
333 const VtTokenArray &propertiesToIgnore);
336 void _IntializeForAPISchema(
338 const SdfLayerHandle &schematicsLayer,
339 const SdfPath &schematicsPrimPath,
340 const VtTokenArray &propertiesToIgnore);
343 bool _MapSchematicsPropertyPaths(
344 const VtTokenArray &propertiesToIgnore);
347 const _LayerAndPath *_GetPropertyLayerAndPath(
const TfToken& propName)
const 352 _LayerAndPath *_GetPropertyLayerAndPath(
const TfToken& propName)
362 void _ComposePropertiesFromPrimDef(
364 bool useWeakerPropertyForTypeConflict =
false);
367 void _ComposePropertiesFromPrimDefInstance(
369 const std::string &instanceName);
372 void _ComposeOverAndReplaceExistingProperty(
377 using _FamilyAndInstanceToVersionMap =
378 std::unordered_map<std::pair<TfToken, TfToken>, UsdSchemaVersion,
TfHash>;
381 bool _ComposeWeakerAPIPrimDefinition(
384 _FamilyAndInstanceToVersionMap *alreadyAppliedSchemaFamilyVersions,
385 bool allowDupes =
false);
388 static bool _PropertyTypesMatch(
389 const _LayerAndPath &strongerProp,
390 const _LayerAndPath &weakerProp);
393 _LayerAndPath _primLayerAndPath;
397 using _PrimTypePropNameToPathMap =
398 std::unordered_map<TfToken, _LayerAndPath, TfToken::HashFunctor>;
399 _PrimTypePropNameToPathMap _propLayerAndPathMap;
406 PXR_NAMESPACE_CLOSE_SCOPE
408 #endif //PXR_USD_USD_PRIM_DEFINITION_H A scene description container that can combine with other such containers to form simple component as...
bool IsEmpty() const
Returns true iff this token contains the empty string "".
const TfTokenVector & GetPropertyNames() const
Return the list of names of builtin properties for this prim definition.
SdfSpecType GetSpecType(const TfToken &propName) const
Return the SdfSpecType for propName if it is a builtin property of the prim type represented by this ...
TfTokenVector ListPropertyMetadataFields(const TfToken &propName) const
Returns the list of names of metadata fields that are defined by this prim definition for property pr...
SDF_API bool HasFieldDictKey(const SdfPath &path, const TfToken &fieldName, const TfToken &keyPath, VtValue *value=NULL) const
Return whether a value exists for the given path and fieldName and keyPath.
bool GetPropertyMetadataByDictKey(const TfToken &propName, const TfToken &key, const TfToken &keyPath, T *value) const
Retrieves the value at keyPath from the fallback dictionary value for the dictionary metadata field n...
USD_API std::string GetPropertyDocumentation(const TfToken &propName) const
Returns the documentation metadata defined by the prim definition for the property named propName if ...
A user-extensible hashing mechanism for use with runtime hash tables.
Token for efficient comparison, assignment, and hashing of known strings.
const TfTokenVector & GetAppliedAPISchemas() const
Return the list of names of the API schemas that have been applied to this prim definition in order.
USD_API std::string GetDocumentation() const
Returns the documentation metadata defined by the prim definition for the prim itself.
SDF_API bool HasField(const SdfPath &path, const TfToken &fieldName, VtValue *value=NULL) const
Return whether a value exists for the given path and fieldName.
USD_API bool FlattenTo(const SdfLayerHandle &layer, const SdfPath &path, SdfSpecifier newSpecSpecifier=SdfSpecifierOver) const
Copies the contents of this prim definition to a prim spec on the given layer at the given path.
bool GetPropertyMetadata(const TfToken &propName, const TfToken &key, T *value) const
Retrieves the fallback value for the metadata field named key, that is defined by this prim definitio...
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
SdfSpecifier
An enum that identifies the possible specifiers for an SdfPrimSpec.
std::vector< TfToken > TfTokenVector
Convenience types.
A path value used to locate objects in layers or scenegraphs.
USD_API SdfPropertySpecHandle GetSchemaPropertySpec(const TfToken &propName) const
Return the property spec that defines the fallback for the property named propName on prims of this p...
bool GetMetadataByDictKey(const TfToken &key, const TfToken &keyPath, T *value) const
Retrieves the value at keyPath from the fallback dictionary value for the dictionary metadata field n...
bool GetMetadata(const TfToken &key, T *value) const
Retrieves the fallback value for the metadata field named key, that is defined by this prim definitio...
static USD_API bool IsDisallowedField(const TfToken &fieldName)
Returns true if the field fieldName cannot have fallback values specified in schemas.
SdfSpecType
An enum that specifies the type of an object.
USD_API SdfRelationshipSpecHandle GetSchemaRelationshipSpec(const TfToken &relName) const
This is a convenience method.
Class representing the builtin definition of a prim given the schemas registered in the schema regist...
Container::mapped_type * TfMapLookupPtr(Container &map, Key const &key)
Checks if an item exists in a map or TfHashMap, without copying it.
TfTokenVector ListMetadataFields() const
Returns the list of names of metadata fields that are defined by this prim definition for the prim it...
USD_API SdfAttributeSpecHandle GetSchemaAttributeSpec(const TfToken &attrName) const
This is a convenience method.
Singleton registry that provides access to schema type information and the prim definitions for regis...
SDF_API SdfSpecType GetSpecType(const SdfPath &path) const
Return the spec type for path.
bool GetAttributeFallbackValue(const TfToken &attrName, T *value) const
Retrieves the fallback value for the attribute named attrName and stores it in value if possible.