24 #ifndef PXR_USD_SDF_SCHEMA_H
25 #define PXR_USD_SDF_SCHEMA_H
53 class Sdf_ValueTypeRegistry;
80 typedef std::vector< std::pair<TfToken, JsValue> >
InfoVec;
97 return (_valueValidator ?
98 _valueValidator(_schema,
VtValue(value)) :
105 return (_listValueValidator ?
106 _listValueValidator(_schema,
VtValue(value)) :
113 return (_mapKeyValidator ?
114 _mapKeyValidator(_schema,
VtValue(value)) :
121 return (_mapValueValidator ?
122 _mapValueValidator(_schema,
VtValue(value)) :
185 return _requiredFields;
229 return _specDefinitions[specType].second ?
230 &_specDefinitions[specType].first :
nullptr;
270 TfToken const &metadataField)
const;
280 for (
TfToken const &fname: _requiredFieldNames) {
281 if (fname == fieldName) {
378 const TfToken& name,
bool required =
false);
381 bool required =
false);
390 , _definition(definition)
441 const VtValue& defaultArrayValue);
444 std::unique_ptr<_Impl> _impl;
453 Sdf_ValueTypeRegistry* _registry;
474 const TfToken &fieldKey,
const T &fallback,
bool plugin =
false)
476 return _CreateField(fieldKey,
VtValue(fallback), plugin);
483 _specDefinitions[
type].second =
true;
510 typedef std::function<VtValue(const std::string&, const JsValue&)>
515 const std::vector<const SdfSchemaBase::FieldDefinition *>
534 const SpecDefinition* _CheckAndGetSpecDefinition(
SdfSpecType type)
const;
538 const TfToken &fieldKey,
const VtValue &fallback,
bool plugin =
false);
543 return _DoRegisterField(fieldKey,
VtValue(fallback));
546 FieldDefinition& _DoRegisterField(
553 _FieldDefinitionMap _fieldDefinitions;
556 std::pair<SdfSchemaBase::SpecDefinition, bool>
559 std::unique_ptr<Sdf_ValueTypeRegistry> _valueTypeRegistry;
587 #define SDF_FIELD_KEYS \
588 ((Active, "active")) \
589 ((AllowedTokens, "allowedTokens")) \
590 ((AssetInfo, "assetInfo")) \
591 ((ColorConfiguration, "colorConfiguration")) \
592 ((ColorManagementSystem, "colorManagementSystem")) \
593 ((ColorSpace, "colorSpace")) \
594 ((Comment, "comment")) \
595 ((ConnectionPaths, "connectionPaths")) \
596 ((Custom, "custom")) \
597 ((CustomData, "customData")) \
598 ((CustomLayerData, "customLayerData")) \
599 ((Default, "default")) \
600 ((DefaultPrim, "defaultPrim")) \
601 ((DisplayGroup, "displayGroup")) \
602 ((DisplayGroupOrder, "displayGroupOrder")) \
603 ((DisplayName, "displayName")) \
604 ((DisplayUnit, "displayUnit")) \
605 ((Documentation, "documentation")) \
606 ((EndTimeCode, "endTimeCode")) \
607 ((ExpressionVariables, "expressionVariables")) \
608 ((FramePrecision, "framePrecision")) \
609 ((FramesPerSecond, "framesPerSecond")) \
610 ((Hidden, "hidden")) \
611 ((HasOwnedSubLayers, "hasOwnedSubLayers")) \
612 ((InheritPaths, "inheritPaths")) \
613 ((Instanceable, "instanceable")) \
615 ((PrimOrder, "primOrder")) \
616 ((NoLoadHint, "noLoadHint")) \
618 ((Payload, "payload")) \
619 ((Permission, "permission")) \
620 ((Prefix, "prefix")) \
621 ((PrefixSubstitutions, "prefixSubstitutions")) \
622 ((PropertyOrder, "propertyOrder")) \
623 ((References, "references")) \
624 ((Relocates, "relocates")) \
625 ((SessionOwner, "sessionOwner")) \
626 ((Specializes, "specializes")) \
627 ((Specifier, "specifier")) \
628 ((StartTimeCode, "startTimeCode")) \
629 ((SubLayers, "subLayers")) \
630 ((SubLayerOffsets, "subLayerOffsets")) \
631 ((Suffix, "suffix")) \
632 ((SuffixSubstitutions, "suffixSubstitutions")) \
633 ((SymmetricPeer, "symmetricPeer")) \
634 ((SymmetryArgs, "symmetryArgs")) \
635 ((SymmetryArguments, "symmetryArguments")) \
636 ((SymmetryFunction, "symmetryFunction")) \
637 ((TargetPaths, "targetPaths")) \
638 ((TimeSamples, "timeSamples")) \
639 ((TimeCodesPerSecond, "timeCodesPerSecond")) \
640 ((TypeName, "typeName")) \
641 ((VariantSelection, "variantSelection")) \
642 ((Variability, "variability")) \
643 ((VariantSetNames, "variantSetNames")) \
646 ((EndFrame, "endFrame")) \
647 ((StartFrame, "startFrame"))
649 #define SDF_CHILDREN_KEYS \
650 ((ConnectionChildren, "connectionChildren")) \
651 ((ExpressionChildren, "expressionChildren")) \
652 ((MapperArgChildren, "mapperArgChildren")) \
653 ((MapperChildren, "mapperChildren")) \
654 ((PrimChildren, "primChildren")) \
655 ((PropertyChildren, "properties")) \
656 ((RelationshipTargetChildren, "targetChildren")) \
657 ((VariantChildren, "variantChildren")) \
658 ((VariantSetChildren, "variantSetChildren"))
665 #endif // PXR_USD_SDF_SCHEMA_H
SDF_API const VtValue & GetFallback(const TfToken &fieldKey) const
static SDF_API SdfAllowed IsValidAttributeConnectionPath(const SdfPath &path)
Type(const TfToken &name, const T &defaultValue)
static SDF_API SdfAllowed IsValidVariantIdentifier(const std::string &name)
FieldDefinition & Children()
void _RegisterStandardFields()
Registers the standard fields.
void _RegisterPluginFields()
static SDF_API SdfAllowed IsValidRelationshipTargetPath(const SdfPath &path)
static SDF_API SdfAllowed IsValidVariantSelection(const std::string &sel)
SDF_API SdfAllowed IsValidValue(const VtValue &value) const
FieldDefinition & ReadOnly()
FieldDefinition & _RegisterField(const TfToken &fieldKey, const T &fallback, bool plugin=false)
#define SDF_CHILDREN_KEYS
SDF_API bool HoldsChildren(const TfToken &fieldKey) const
FieldDefinition(const SdfSchemaBase &schema, const TfToken &name, const VtValue &fallbackValue)
SDF_API bool IsPlugin() const
Type & DefaultUnit(TfEnum unit)
GLsizei const GLchar *const * string
Type & CPPTypeName(const std::string &cppTypeName)
GLsizei const GLchar *const * path
FieldDefinition & FallbackValue(const VtValue &v)
_SpecDefiner _Define(SdfSpecType type)
SDF_API const VtValue & GetFallbackValue() const
Functor to use for hash maps from tokens to other things.
SDF_API TfTokenVector GetMetadataFields(SdfSpecType specType) const
Returns all metadata fields registered for the given spec type.
SdfAllowed IsValidMapKey(const T &value) const
TfToken metadataDisplayGroup
std::function< VtValue(const std::string &, const JsValue &)> _DefaultValueFactoryFn
_SpecDefiner & MetadataField(const TfToken &name, bool required=false)
_SpecDefiner _ExtendSpecDefinition(SdfSpecType specType)
TfTokenVector const & GetRequiredFields() const
Returns all value fields marked as required for this spec.
static SDF_API SdfAllowed IsValidSubLayer(const std::string &sublayer)
SDF_API bool IsRequiredField(const TfToken &name) const
Returns whether the given field is required for this spec.
SDF_API_TEMPLATE_CLASS(TfSingleton< SdfSchema >)
SdfAllowed(*)(const SdfSchemaBase &, const VtValue &) Validator
Type & Dimensions(const SdfTupleDimensions &dims)
friend class _SpecDefiner
FieldDefinition & AddInfo(const TfToken &tok, const JsValue &val)
std::vector< std::pair< TfToken, JsValue > > InfoVec
FieldDefinition & MapValueValidator(Validator v)
static SDF_API SdfAllowed IsValidInheritPath(const SdfPath &path)
Type(char const *name, const T &defaultValue)
SDF_API bool IsMetadataField(const TfToken &name) const
Returns whether the given field is metadata for this spec.
FieldDefinition & Plugin()
_ValueTypeRegistrar(Sdf_ValueTypeRegistry *)
SDF_API const TfTokenVector & GetRequiredFields(SdfSpecType specType) const
Returns all required fields registered for the given spec type.
static SDF_API SdfAllowed IsValidSpecializesPath(const SdfPath &path)
_SpecDefiner & CopyFrom(const SpecDefinition &other)
_SpecDefiner & Field(const TfToken &name, bool required=false)
SDF_API bool IsValidFieldForSpec(const TfToken &fieldKey, SdfSpecType specType) const
Return whether the given field is valid for the given spec type.
SDF_API bool IsValidField(const TfToken &name) const
Returns whether the given field is valid for this spec.
FieldDefinition & MapKeyValidator(Validator v)
png_const_structrp png_const_inforp int * unit
SDF_API bool IsRegistered(const TfToken &fieldKey, VtValue *fallback=NULL) const
std::vector< TfToken > TfTokenVector
Convenience types.
TF_DECLARE_WEAK_PTRS(PlugPlugin)
SDF_API std::vector< SdfValueTypeName > GetAllTypes() const
Returns all registered type names.
GLuint const GLchar * name
friend struct Sdf_SchemaFieldTypeRegistrar
bool IsRequiredFieldName(const TfToken &fieldName) const
const std::vector< const SdfSchemaBase::FieldDefinition * > _UpdateMetadataFromPlugins(const PlugPluginPtrVector &plugins, const std::string &metadataTag=std::string(), const _DefaultValueFactoryFn &defFactory=_DefaultValueFactoryFn())
static SDF_API const SdfSchema & GetInstance()
A helper for registering value types.
SDF_API const FieldDefinition * GetFieldDefinition(const TfToken &fieldKey) const
_ValueTypeRegistrar _GetTypeRegistrar() const
Returns a type registrar.
static SDF_API SdfAllowed IsValidIdentifier(const std::string &name)
SDF_API SdfValueTypeName FindOrCreateType(const TfToken &typeName) const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
static SDF_API SdfAllowed IsValidRelocatesPath(const SdfPath &path)
static SDF_API SdfAllowed IsValidPayload(const SdfPayload &payload)
SdfAllowed IsValidListValue(const T &value) const
Type & Role(const TfToken &role)
#define PXR_NAMESPACE_CLOSE_SCOPE
SdfAllowed IsValidMapValue(const T &value) const
SdfAllowed IsValidValue(const T &value) const
void _RegisterStandardTypes()
Registers standard attribute value types.
void AddType(const Type &type)
Register a value type and its corresponding array value type.
SDF_API TfTokenVector GetMetadataFields() const
Returns all value fields marked as metadata for this spec.
SDF_API TfToken GetMetadataFieldDisplayGroup(const TfToken &name) const
SDF_API TfTokenVector GetFields(SdfSpecType specType) const
Returns all fields registered for the given spec type.
SDF_API const TfToken & GetName() const
static SDF_API SdfAllowed IsValidNamespacedIdentifier(const std::string &name)
SDF_API const InfoVec & GetInfo() const
static SDF_API SdfAllowed IsValidReference(const SdfReference &ref)
SDF_API TfToken GetMetadataFieldDisplayGroup(SdfSpecType specType, TfToken const &metadataField) const
void _RegisterLegacyTypes()
Registers legacy attribute value types.
SDF_API VtValue CastToTypeOf(const TfToken &fieldKey, const VtValue &value) const
Coerce value to the correct type for the specified field.
FieldDefinition & ListValueValidator(Validator v)
const SpecDefinition * GetSpecDefinition(SdfSpecType specType) const
SDF_API TfTokenVector GetFields() const
Returns all fields for this spec.
SDF_API bool HoldsChildren() const
SDF_API SdfValueTypeName FindType(const TfToken &typeName) const
Return the type name object for the given type name token.
FieldDefinition & ValueValidator(Validator v)
SDF_API bool IsReadOnly() const
TF_DECLARE_PUBLIC_TOKENS(SdfFieldKeys, SDF_API, SDF_FIELD_KEYS)