7 #ifndef PXR_USD_SDF_SCHEMA_H
8 #define PXR_USD_SDF_SCHEMA_H
36 class Sdf_ValueTypeRegistry;
63 typedef std::vector< std::pair<TfToken, JsValue> >
InfoVec;
80 return (_valueValidator ?
81 _valueValidator(_schema,
VtValue(value)) :
88 return (_listValueValidator ?
89 _listValueValidator(_schema,
VtValue(value)) :
96 return (_mapKeyValidator ?
97 _mapKeyValidator(_schema,
VtValue(value)) :
104 return (_mapValueValidator ?
105 _mapValueValidator(_schema,
VtValue(value)) :
168 return _requiredFields;
212 #ifdef PXR_PREFER_SAFETY_OVER_SPEED
216 return _IssueErrorForInvalidSpecType(specType);
218 #endif // PXR_PREFER_SAFETY_OVER_SPEED
220 return _specDefinitions[specType].second ?
221 &_specDefinitions[specType].first :
nullptr;
261 TfToken const &metadataField)
const;
271 for (
TfToken const &fname: _requiredFieldNames) {
272 if (fname == fieldName) {
373 const TfToken& name,
bool required =
false);
376 bool required =
false);
385 , _definition(definition)
436 const VtValue& defaultArrayValue);
439 std::unique_ptr<_Impl> _impl;
448 Sdf_ValueTypeRegistry* _registry;
469 const TfToken &fieldKey,
const T &fallback,
bool plugin =
false)
471 return _CreateField(fieldKey,
VtValue(fallback), plugin);
478 _specDefinitions[
type].second =
true;
505 typedef std::function<VtValue(const std::string&, const JsValue&)>
510 const std::vector<const SdfSchemaBase::FieldDefinition *>
512 const std::string& metadataTag =
529 const SpecDefinition* _CheckAndGetSpecDefinition(
SdfSpecType type)
const;
532 const SpecDefinition* _IssueErrorForInvalidSpecType(
SdfSpecType specType)
const;
536 const TfToken &fieldKey,
const VtValue &fallback,
bool plugin =
false);
541 return _DoRegisterField(fieldKey,
VtValue(fallback));
544 FieldDefinition& _DoRegisterField(
551 _FieldDefinitionMap _fieldDefinitions;
554 std::pair<SdfSchemaBase::SpecDefinition, bool>
557 std::unique_ptr<Sdf_ValueTypeRegistry> _valueTypeRegistry;
585 #define SDF_FIELD_KEYS \
586 ((Active, "active")) \
587 ((AllowedTokens, "allowedTokens")) \
588 ((ArraySizeConstraint, "arraySizeConstraint")) \
589 ((AssetInfo, "assetInfo")) \
591 ((ClipSets, "clipSets")) \
592 ((ColorConfiguration, "colorConfiguration")) \
593 ((ColorManagementSystem, "colorManagementSystem")) \
594 ((ColorSpace, "colorSpace")) \
595 ((Comment, "comment")) \
596 ((ConnectionPaths, "connectionPaths")) \
597 ((Custom, "custom")) \
598 ((CustomData, "customData")) \
599 ((CustomLayerData, "customLayerData")) \
600 ((Default, "default")) \
601 ((DefaultPrim, "defaultPrim")) \
602 ((DisplayGroup, "displayGroup")) \
603 ((DisplayGroupOrder, "displayGroupOrder")) \
604 ((DisplayName, "displayName")) \
605 ((DisplayUnit, "displayUnit")) \
606 ((Documentation, "documentation")) \
607 ((EndTimeCode, "endTimeCode")) \
608 ((ExpressionVariables, "expressionVariables")) \
609 ((FramePrecision, "framePrecision")) \
610 ((FramesPerSecond, "framesPerSecond")) \
611 ((Hidden, "hidden")) \
612 ((HasOwnedSubLayers, "hasOwnedSubLayers")) \
613 ((InheritPaths, "inheritPaths")) \
614 ((Instanceable, "instanceable")) \
616 ((LayerRelocates, "layerRelocates")) \
617 ((Limits, "limits")) \
618 ((PrimOrder, "primOrder")) \
619 ((NoLoadHint, "noLoadHint")) \
621 ((Payload, "payload")) \
622 ((Permission, "permission")) \
623 ((Prefix, "prefix")) \
624 ((PrefixSubstitutions, "prefixSubstitutions")) \
625 ((PropertyOrder, "propertyOrder")) \
626 ((References, "references")) \
627 ((Relocates, "relocates")) \
628 ((SessionOwner, "sessionOwner")) \
629 ((Specializes, "specializes")) \
630 ((Specifier, "specifier")) \
631 ((Spline, "spline")) \
632 ((StartTimeCode, "startTimeCode")) \
633 ((SubLayers, "subLayers")) \
634 ((SubLayerOffsets, "subLayerOffsets")) \
635 ((Suffix, "suffix")) \
636 ((SuffixSubstitutions, "suffixSubstitutions")) \
637 ((SymmetricPeer, "symmetricPeer")) \
638 ((SymmetryArgs, "symmetryArgs")) \
639 ((SymmetryArguments, "symmetryArguments")) \
640 ((SymmetryFunction, "symmetryFunction")) \
641 ((TargetPaths, "targetPaths")) \
642 ((TimeSamples, "timeSamples")) \
643 ((TimeCodesPerSecond, "timeCodesPerSecond")) \
644 ((TypeName, "typeName")) \
645 ((VariantSelection, "variantSelection")) \
646 ((Variability, "variability")) \
647 ((VariantSetNames, "variantSetNames")) \
650 ((EndFrame, "endFrame")) \
651 ((StartFrame, "startFrame"))
653 #define SDF_CHILDREN_KEYS \
654 ((ConnectionChildren, "connectionChildren")) \
655 ((ExpressionChildren, "expressionChildren")) \
656 ((MapperArgChildren, "mapperArgChildren")) \
657 ((MapperChildren, "mapperChildren")) \
658 ((PrimChildren, "primChildren")) \
659 ((PropertyChildren, "properties")) \
660 ((RelationshipTargetChildren, "targetChildren")) \
661 ((VariantChildren, "variantChildren")) \
662 ((VariantSetChildren, "variantSetChildren"))
669 #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)
#define PXR_NAMESPACE_OPEN_SCOPE
GLsizei const GLfloat * value
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)
static SDF_API SdfAllowed IsValidRelocatesTargetPath(const SdfPath &path)
Type(char const *name, const T &defaultValue)
GLint GLint GLsizei GLint GLenum GLenum type
SDF_API bool IsMetadataField(const TfToken &name) const
Returns whether the given field is metadata for this spec.
FieldDefinition & Plugin()
static SDF_API SdfAllowed IsValidRelocate(const SdfRelocate &relocate)
_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
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
static SDF_API SdfAllowed IsValidRelocatesSourcePath(const SdfPath &path)
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)
std::pair< SdfPath, SdfPath > SdfRelocate
SDF_API bool IsReadOnly() const
TF_DECLARE_PUBLIC_TOKENS(SdfFieldKeys, SDF_API, SDF_FIELD_KEYS)