7#ifndef PXR_USD_USD_PRIM_DEFINITION_H
8#define PXR_USD_USD_PRIM_DEFINITION_H
11#include "pxr/usd/usd/api.h"
12#include "pxr/usd/usd/schemaRegistry.h"
20#include <unordered_map>
22PXR_NAMESPACE_OPEN_SCOPE
43 return _appliedAPISchemas;
74 explicit operator bool()
const
148 _name(name), _layerAndPath(layerAndPath) {}
149 Property(
const _LayerAndPath *layerAndPath):
150 _layerAndPath(layerAndPath) {}
153 const _LayerAndPath *_layerAndPath =
nullptr;
182 explicit operator bool()
const {
248 explicit operator bool()
const{
286 const TfToken& propName)
const;
295 const TfToken& attrName)
const;
314 return _HasField(attrName, SdfFieldKeys->Default, value);
334 return _HasField(
TfToken(), key, value);
347 const TfToken &keyPath, T* value)
const
352 return _HasFieldDictKey(
TfToken(), key, keyPath, value);
377 return prop.GetMetadata(key, value);
393 const TfToken &keyPath, T* value)
const
396 return prop.GetMetadataByDictKey(key, keyPath, value);
432 SdfSpecifier newSpecSpecifier = SdfSpecifierOver)
const;
441 SdfSpecifier newSpecSpecifier = SdfSpecifierOver)
const;
448 SdfSpecifier newSpecSpecifier = SdfSpecifierOver)
const;
468 primDef._HasField(propName, fieldName, value) :
469 primDef._HasFieldDictKey(propName, fieldName, keyPath, value);
474 struct _LayerAndPath {
485 bool HasField(
const TfToken& fieldName, T* value)
const {
486 return layer->
HasField(path, fieldName, value);
490 bool HasFieldDictKey(
491 const TfToken& fieldName,
const TfToken& keyPath, T* value)
const {
496 return layer->
GetField(path, fieldName);
499 explicit operator bool() const noexcept {
508 bool _HasField(
const TfToken& propName,
512 if (
const _LayerAndPath *layerAndPath =
513 _GetPropertyLayerAndPath(propName)) {
514 return layerAndPath->
HasField(fieldName, value);
520 bool _HasFieldDictKey(
const TfToken& propName,
525 if (
const _LayerAndPath *layerAndPath =
526 _GetPropertyLayerAndPath(propName)) {
527 return layerAndPath->HasFieldDictKey(fieldName, keyPath, value);
535 void _ApplyPropertyOrder();
538 void _IntializeForTypedSchema(
539 const SdfLayerHandle &schematicsLayer,
540 const SdfPath &schematicsPrimPath,
541 const VtTokenArray &propertiesToIgnore);
544 void _IntializeForAPISchema(
546 const SdfLayerHandle &schematicsLayer,
547 const SdfPath &schematicsPrimPath,
548 const VtTokenArray &propertiesToIgnore);
551 bool _MapSchematicsPropertyPaths(
552 const VtTokenArray &propertiesToIgnore);
555 const _LayerAndPath *_GetPropertyLayerAndPath(
const TfToken& propName)
const
560 _LayerAndPath *_GetPropertyLayerAndPath(
const TfToken& propName)
566 void _ComposePropertiesFromPrimDef(
569 void _ComposePropertiesFromPrimDefInstance(
571 const std::string &instanceName);
573 void _AddOrComposeProperty(
575 const _LayerAndPath &layerAndPath);
577 SdfSpecHandle _FindOrCreateSpecForComposition(
579 const _LayerAndPath &srcLayerAndPath);
581 SdfSpecHandle _CreateComposedPrimOrPropertyIfNeeded(
583 const _LayerAndPath &strongProp,
584 const _LayerAndPath &weakProp);
587 void _ComposeOverAndReplaceExistingProperty(
592 using _FamilyAndInstanceToVersionMap =
593 std::unordered_map<std::pair<TfToken, TfToken>, UsdSchemaVersion,
TfHash>;
596 bool _ComposeWeakerAPIPrimDefinition(
599 _FamilyAndInstanceToVersionMap *alreadyAppliedSchemaFamilyVersions);
601 static bool _PropertyTypesMatch(
602 const Property &strongProp,
603 const Property &weakProp);
606 _LayerAndPath _primLayerAndPath;
610 using _PrimTypePropNameToPathMap =
611 std::unordered_map<TfToken, _LayerAndPath, TfToken::HashFunctor>;
612 _PrimTypePropNameToPathMap _propLayerAndPathMap;
631 return _layerAndPath->HasField(key, value);
642 return _layerAndPath->HasFieldDictKey(key, keyPath, value);
649 return _layerAndPath->HasField(SdfFieldKeys->Default, value);
653PXR_NAMESPACE_CLOSE_SCOPE
A scene description container that can combine with other such containers to form simple component as...
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.
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.
SDF_API VtValue GetField(const SdfPath &path, const TfToken &fieldName) const
Return the value for the given path and fieldName.
A path value used to locate objects in layers or scenegraphs.
Represents a value type name, i.e.
A user-extensible hashing mechanism for use with runtime hash tables.
Token for efficient comparison, assignment, and hashing of known strings.
bool IsEmpty() const
Returns true iff this token contains the empty string "".
Accessor to a attribute's definition in the prim definition.
USD_API Attribute(const Property &property)
Copy constructor from a Property to allow implicit conversion.
USD_API Attribute(Property &&property)
Move constructor from a Property to allow implicit conversion.
Attribute()=default
Default constructor returns an invalid attribute.
USD_API SdfValueTypeName GetTypeName() const
Returns the value type name of this attribute in the prim definition.
USD_API TfToken GetTypeNameToken() const
Returns the token value of the type name of this attribute in the prim definition.
bool GetFallbackValue(T *value) const
Retrieves the fallback value of type T for this attribute and stores it in value if possible.
Accessor to a property's definition in the prim definition.
USD_API const TfToken & GetName() const
Returns the name of the requested property.
Property()=default
Default constructor returns an invalid property.
USD_API SdfSpecType GetSpecType() const
Returns the spec type of this property in the prim definition.
USD_API bool IsRelationship() const
Return true if the property is a valid is a valid property in the prim definition and is a relationsh...
USD_API SdfVariability GetVariability() const
Returns the variability of this property in the prim definition.
bool GetMetadataByDictKey(const TfToken &key, const TfToken &keyPath, T *value) const
Retrieves the value at keyPath from the dictionary value for the dictionary metadata field named key,...
USD_API bool IsAttribute() const
Return true if the property is a valid is a valid property in the prim definition and is an attribute...
bool GetMetadata(const TfToken &key, T *value) const
Retrieves the fallback value for the metadata field named key, that is defined for this property in t...
USD_API TfTokenVector ListMetadataFields() const
Returns the list of names of metadata fields that are defined for this property in the prim definitio...
USD_API std::string GetDocumentation() const
Returns the documentation metadata defined by the prim definition for this property.
Accessor to a relationship's definition in the prim definition.
Relationship()=default
Default constructor returns an invalid relationship.
USD_API Relationship(Property &&property)
Move constructor from a Property to allow implicit conversion.
USD_API Relationship(const Property &property)
Copy constructor from a Property to allow implicit conversion.
Class representing the builtin definition of a prim given the schemas registered in the schema regist...
USD_API SdfRelationshipSpecHandle GetSchemaRelationshipSpec(const TfToken &relName) const
USD_API TfTokenVector ListPropertyMetadataFields(const TfToken &propName) const
Returns the list of names of metadata fields that are defined by this prim definition for property pr...
USD_API SdfSpecType GetSpecType(const TfToken &propName) const
Return the SdfSpecType for propName if it is a builtin property of the prim type represented by this ...
USD_API Attribute GetAttributeDefinition(const TfToken &attrName) const
Returns an attribute accessor the property named attrName if it is defined by this this prim definiti...
USD_API SdfPropertySpecHandle GetSchemaPropertySpec(const TfToken &propName) const
const TfTokenVector & GetPropertyNames() const
Return the list of names of builtin properties for this prim definition, ordered by this prim definit...
USD_API Relationship GetRelationshipDefinition(const TfToken &relName) const
Returns a relationship accessor the property named relName if it is defined by this this prim definit...
USD_API Property GetPropertyDefinition(const TfToken &propName) const
Returns a property accessor the property named propName if it is defined by this this prim definition...
USD_API UsdPrim FlattenTo(const UsdPrim &prim, SdfSpecifier newSpecSpecifier=SdfSpecifierOver) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
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...
USD_API UsdPrim FlattenTo(const UsdPrim &parent, const TfToken &name, SdfSpecifier newSpecSpecifier=SdfSpecifierOver) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
USD_API SdfAttributeSpecHandle GetSchemaAttributeSpec(const TfToken &attrName) const
bool GetAttributeFallbackValue(const TfToken &attrName, T *value) const
Retrieves the fallback value for the attribute named attrName and stores it in value if possible.
const TfTokenVector & GetAppliedAPISchemas() const
Return the list of names of the API schemas that have been applied to this prim definition in order.
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 ...
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...
USD_API TfTokenVector ListMetadataFields() const
Returns the list of names of metadata fields that are defined by this prim definition for the prim it...
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.
USD_API std::string GetDocumentation() const
Returns the documentation metadata defined by the prim definition for the prim itself.
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Singleton registry that provides access to schema type information and the prim definitions for regis...
static USD_API bool IsDisallowedField(const TfToken &fieldName)
Returns true if the field fieldName cannot have fallback values specified in schemas.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Container::mapped_type * TfMapLookupPtr(Container &map, Key const &key)
Checks if an item exists in a map or TfHashMap, without copying it.
std::vector< TfToken > TfTokenVector
Convenience types.
SdfSpecType
An enum that specifies the type of an object.
SdfSpecifier
An enum that identifies the possible specifiers for an SdfPrimSpec.
SdfVariability
An enum that identifies variability types for attributes.