24 #ifndef PXR_USD_USD_SCHEMA_REGISTRY_H 25 #define PXR_USD_USD_SCHEMA_REGISTRY_H 28 #include "pxr/usd/usd/api.h" 37 #include <unordered_map> 40 PXR_NAMESPACE_OPEN_SCOPE
49 using UsdSchemaVersion =
unsigned int;
74 using TokenToTokenVectorMap =
75 std::unordered_map<TfToken, TfTokenVector, TfHash>;
125 UsdSchemaVersion schemaVersion);
145 static std::pair<TfToken, UsdSchemaVersion>
176 static const SchemaInfo *
187 template <
class SchemaType>
188 static const SchemaInfo *
190 static_assert(std::is_base_of<UsdSchemaBase, SchemaType>::value,
191 "Provided type must derive UsdSchemaBase.");
199 static const SchemaInfo *
206 static const SchemaInfo *
222 static const std::vector<const SchemaInfo *> &
230 static std::vector<const SchemaInfo *>
233 UsdSchemaVersion schemaVersion,
243 template <
class SchemaType>
444 TokenToTokenVectorMap *autoApplyAPISchemas);
465 const std::string &namespacePrefix,
466 const std::string &baseName);
484 const std::string &nameTemplate,
485 const std::string &instanceName);
498 const std::string &nameTemplate);
510 const std::string &nameTemplate);
516 const TfToken &typeName)
const {
517 const auto it = _concreteTypedPrimDefinitions.find(typeName);
518 return it != _concreteTypedPrimDefinitions.end() ?
519 it->second.get() :
nullptr;
526 const TfToken &typeName)
const {
527 const auto it = _appliedAPIPrimDefinitions.find(typeName);
528 return it != _appliedAPIPrimDefinitions.end() ?
529 it->second.primDef.get() :
nullptr;
534 return _emptyPrimDefinition;
542 std::unique_ptr<UsdPrimDefinition>
558 return _fallbackPrimTypes;
566 using _FamilyAndInstanceToVersionMap =
567 std::unordered_map<std::pair<TfToken, TfToken>, UsdSchemaVersion,
TfHash>;
569 void _ComposeAPISchemasIntoPrimDefinition(
572 _FamilyAndInstanceToVersionMap *seenSchemaFamilyVersions,
573 bool allowDupes =
false)
const;
578 class _SchemaDefInitHelper;
580 std::vector<SdfLayerRefPtr> _schematicsLayers;
582 std::unordered_map<TfToken, const std::unique_ptr<UsdPrimDefinition>,
583 TfHash> _concreteTypedPrimDefinitions;
585 struct _APISchemaDefinitionInfo {
586 std::unique_ptr<UsdPrimDefinition> primDef;
587 bool applyExpectsInstanceName;
589 std::unordered_map<TfToken, const _APISchemaDefinitionInfo, TfHash>
590 _appliedAPIPrimDefinitions;
605 void Usd_GetAPISchemaPluginApplyToInfoForType(
606 const TfType &apiSchemaType,
608 UsdSchemaRegistry::TokenToTokenVectorMap *autoApplyAPISchemasMap,
609 UsdSchemaRegistry::TokenToTokenVectorMap *canOnlyApplyAPISchemasMap,
610 TfHashMap<TfToken, TfToken::Set, TfHash> *allowedInstanceNamesMap);
615 void Usd_SortAutoAppliedAPISchemas(
618 PXR_NAMESPACE_CLOSE_SCOPE
620 #endif //PXR_USD_USD_SCHEMA_REGISTRY_H TfType type
The schema's type as registered with the TfType registry.
static USD_API bool IsMultipleApplyAPISchema(const TfType &apiSchemaType)
Returns true if apiSchemaType is a multiple-apply API schema type.
static USD_API bool IsAbstract(const TfType &primType)
Returns true if the prim type primType is an abstract schema type and, unlike a concrete type,...
Manage a single instance of an object.
static USD_API const TfTokenVector & GetAPISchemaCanOnlyApplyToTypeNames(const TfToken &apiSchemaName, const TfToken &instanceName=TfToken())
Returns a list of prim type names that the given apiSchemaName can only be applied to.
Manage a single instance of an object (see.
static USD_API TfToken GetAPISchemaTypeName(const TfType &schemaType)
Return the type name in the USD schema for API schema types only from the given registered schemaType...
A map with string keys and VtValue values.
USD_API std::unique_ptr< UsdPrimDefinition > BuildComposedPrimDefinition(const TfToken &primType, const TfTokenVector &appliedAPISchemas) const
Composes and returns a new UsdPrimDefinition from the given primType and list of appliedSchemas.
static USD_API const TokenToTokenVectorMap & GetAutoApplyAPISchemas()
Returns a map of the names of all registered auto apply API schemas to the list of type names each is...
static const SchemaInfo * FindSchemaInfo()
Finds and returns the schema info for a registered schema with the C++ schema class SchemaType.
static USD_API bool IsAllowedSchemaIdentifier(const TfToken &schemaIdentifier)
Returns whether the given schemaIdentifier is an allowed schema identifier.
const UsdPrimDefinition * GetEmptyPrimDefinition() const
Returns the empty prim definition.
static USD_API bool IsMultipleApplyNameTemplate(const std::string &nameTemplate)
Returns true if nameTemplate is a multiple apply schema name template.
A user-extensible hashing mechanism for use with runtime hash tables.
UsdSchemaVersion version
The version number of the schema within its schema family.
UsdSchemaKind
An enum representing which kind of schema a given schema class belongs to.
static USD_API TfToken MakeSchemaIdentifierForFamilyAndVersion(const TfToken &schemaFamily, UsdSchemaVersion schemaVersion)
Creates the schema identifier that would be used to define a schema of the given schemaFamily with th...
static USD_API const std::vector< const SchemaInfo * > & FindSchemaInfosInFamily(const TfToken &schemaFamily)
Finds all schemas in the given schemaFamily and returns their their schema info ordered from highest ...
static USD_API bool IsAppliedAPISchema(const TfType &apiSchemaType)
Returns true if apiSchemaType is an applied API schema type.
static USD_API bool IsAllowedAPISchemaInstanceName(const TfToken &apiSchemaName, const TfToken &instanceName)
Returns true if the given instanceName is an allowed instance name for the multiple apply API schema ...
Token for efficient comparison, assignment, and hashing of known strings.
TfToken family
The name of the family of schema's which the schema is a version of.
A subclass of SdfPropertySpec that holds typed data.
static USD_API std::pair< TfToken, TfToken > GetTypeNameAndInstance(const TfToken &apiSchemaName)
Returns the schema type name and the instance name parsed from the given apiSchemaName.
static USD_API std::pair< TfToken, UsdSchemaVersion > ParseSchemaFamilyAndVersionFromIdentifier(const TfToken &schemaIdentifier)
Parses and returns the schema family and version values from the given schemaIdentifier.
const VtDictionary & GetFallbackPrimTypes() const
Returns a dictionary mapping concrete schema prim type names to a VtTokenArray of fallback prim type ...
TfToken identifier
The schema's identifier which is how the schema type is referred to in scene description and is also ...
static USD_API UsdSchemaKind GetSchemaKind(const TfType &schemaType)
Returns the kind of the schema the given schemaType represents.
std::vector< TfToken > TfTokenVector
Convenience types.
static T & GetInstance()
Return a reference to an object of type T, creating it if necessary.
static USD_API TfToken GetMultipleApplyNameTemplateBaseName(const std::string &nameTemplate)
Returns the base name for the multiple apply schema name template nameTemplate.
VersionPolicy
A policy for filtering by schema version when querying for schemas in a particular schema family.
static USD_API bool IsAllowedSchemaFamily(const TfToken &schemaFamily)
Returns whether the given schemaFamily is an allowed schema family name.
static USD_API TfToken MakeMultipleApplyNameTemplate(const std::string &namespacePrefix, const std::string &baseName)
Creates a name template that can represent a property or API schema that belongs to a multiple apply ...
static USD_API TfType GetTypeFromSchemaTypeName(const TfToken &typeName)
Return the TfType of the schema corresponding to the given prim or API schema name typeName.
static USD_API bool IsDisallowedField(const TfToken &fieldName)
Returns true if the field fieldName cannot have fallback values specified in schemas.
A property that contains a reference to one or more SdfPrimSpec instances.
static USD_API bool IsConcrete(const TfType &primType)
Returns true if the prim type primType is instantiable in scene description.
static USD_API TfType GetConcreteTypeFromSchemaTypeName(const TfToken &typeName)
Return the TfType of the schema corresponding to the given concrete prim type name typeName.
Class representing the builtin definition of a prim given the schemas registered in the schema regist...
const UsdPrimDefinition * FindConcretePrimDefinition(const TfToken &typeName) const
Finds the prim definition for the given typeName token if typeName is a registered concrete typed sch...
static USD_API void CollectAddtionalAutoApplyAPISchemasFromPlugins(TokenToTokenVectorMap *autoApplyAPISchemas)
Collects all the additional auto apply schemas that can be defined in a plugin through "AutoApplyAPIS...
static USD_API TfType GetAPITypeFromSchemaTypeName(const TfToken &typeName)
Return the TfType of the schema corresponding to the given API schema type name typeName.
static TfToken GetSchemaTypeName()
Return the type name in the USD schema for prims or API schemas of the given registered SchemaType.
static USD_API bool IsTyped(const TfType &primType)
Returns true if the prim type primType inherits from UsdTyped.
static USD_API TfType GetTypeFromName(const TfToken &typeName)
Finds the TfType of a schema with typeName.
TfType represents a dynamic runtime type.
Singleton registry that provides access to schema type information and the prim definitions for regis...
UsdSchemaKind kind
The schema's kind: ConcreteTyped, SingleApplyAPI, etc.
const UsdPrimDefinition * FindAppliedAPIPrimDefinition(const TfToken &typeName) const
Finds the prim definition for the given typeName token if typeName is a registered applied API schema...
static USD_API TfToken GetConcreteSchemaTypeName(const TfType &schemaType)
Return the type name in the USD schema for concrete prim types only from the given registered schemaT...
The base class for all schema types in Usd.
Enable a concrete base class for use with TfWeakPtr.
Structure that holds the information about a schema that is registered with the schema registry.
static USD_API TfToken MakeMultipleApplyNameInstance(const std::string &nameTemplate, const std::string &instanceName)
Returns an instance of a multiple apply schema name from the given nameTemplate for the given instanc...