HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
schema.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef PXR_USD_SDF_SCHEMA_H
25 #define PXR_USD_SDF_SCHEMA_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/usd/sdf/api.h"
29 #include "pxr/usd/sdf/allowed.h"
30 #include "pxr/usd/sdf/types.h"
32 
33 #include "pxr/base/plug/notice.h"
34 #include "pxr/base/tf/hash.h"
35 #include "pxr/base/tf/hashmap.h"
36 #include "pxr/base/tf/singleton.h"
38 #include "pxr/base/tf/token.h"
39 #include "pxr/base/tf/type.h"
40 #include "pxr/base/tf/weakBase.h"
41 #include "pxr/base/vt/value.h"
42 
43 #include <memory>
44 #include <string>
45 #include <vector>
46 
48 
49 class JsValue;
50 class SdfPath;
51 class SdfPayload;
52 class SdfReference;
53 class Sdf_ValueTypeRegistry;
54 
56 
57 /// \class SdfSchemaBase
58 ///
59 /// Generic class that provides information about scene description fields
60 /// but doesn't actually provide any fields.
61 ///
62 class SdfSchemaBase : public TfWeakBase {
63  SdfSchemaBase(const SdfSchemaBase&) = delete;
64  SdfSchemaBase& operator=(const SdfSchemaBase&) = delete;
65 protected:
66  class _SpecDefiner;
67 
68 public:
69  /// \class FieldDefinition
70  ///
71  /// Class defining various attributes for a field.
72  ///
74  public:
76  const SdfSchemaBase& schema,
77  const TfToken& name,
78  const VtValue& fallbackValue);
79 
80  typedef std::vector< std::pair<TfToken, JsValue> > InfoVec;
81 
82  SDF_API const TfToken& GetName() const;
83  SDF_API const VtValue& GetFallbackValue() const;
84  SDF_API const InfoVec& GetInfo() const;
85 
86  SDF_API bool IsPlugin() const;
87  SDF_API bool IsReadOnly() const;
88  SDF_API bool HoldsChildren() const;
89 
90  /// Validation functions that return true if a given value passes
91  /// the registered validator or if no validator has been set.
92  /// @{
93 
94  template <class T>
96  {
97  return (_valueValidator ?
98  _valueValidator(_schema, VtValue(value)) :
99  SdfAllowed(true));
100  }
101 
102  template <class T>
104  {
105  return (_listValueValidator ?
106  _listValueValidator(_schema, VtValue(value)) :
107  SdfAllowed(true));
108  }
109 
110  template <class T>
112  {
113  return (_mapKeyValidator ?
114  _mapKeyValidator(_schema, VtValue(value)) :
115  SdfAllowed(true));
116  }
117 
118  template <class T>
120  {
121  return (_mapValueValidator ?
122  _mapValueValidator(_schema, VtValue(value)) :
123  SdfAllowed(true));
124  }
125 
126  /// @}
127 
128  /// Functions for setting field attributes during registration.
129  /// @{
130 
132 
136  FieldDefinition& AddInfo(const TfToken& tok, const JsValue& val);
137 
138  using Validator =
139  SdfAllowed (*) (const SdfSchemaBase&, const VtValue&);
144 
145  /// @}
146 
147  private:
148  const SdfSchemaBase& _schema;
149  TfToken _name;
150  VtValue _fallbackValue;
151  InfoVec _info;
152 
153  bool _isPlugin;
154  bool _isReadOnly;
155  bool _holdsChildren;
156 
157  Validator _valueValidator;
158  Validator _listValueValidator;
159  Validator _mapKeyValidator;
160  Validator _mapValueValidator;
161  };
162 
163  // Structure containing information about a field as it pertains to the
164  // spec this object defines.
165  struct _FieldInfo {
166  _FieldInfo(): required(false), metadata(false) { }
167  bool required;
168  bool metadata;
170  };
171 
172  class SpecDefinition;
173 
174  /// \class SpecDefinition
175  ///
176  /// Class representing fields and other information for a spec type.
177  ///
179  public:
180  /// Returns all fields for this spec.
182 
183  /// Returns all value fields marked as required for this spec.
185  return _requiredFields;
186  }
187 
188  /// Returns all value fields marked as metadata for this spec.
190 
191  /// Returns whether the given field is valid for this spec.
192  SDF_API bool IsValidField(const TfToken& name) const;
193 
194  /// Returns whether the given field is metadata for this spec.
195  SDF_API bool IsMetadataField(const TfToken& name) const;
196 
197  /// Returns the display group for this metadata field. Returns the
198  /// empty token if this field is not a metadata field or if this
199  /// metadata field has no display group.
200  SDF_API
202 
203  /// Returns whether the given field is required for this spec.
204  SDF_API bool IsRequiredField(const TfToken& name) const;
205 
206 
207  private:
209  _FieldMap;
210  _FieldMap _fields;
211 
212  // A separate vector of required field names from _fields. Access to
213  // these is in a hot path, so we cache them separately.
214  TfTokenVector _requiredFields;
215 
216  private:
217  friend class _SpecDefiner;
218  void _AddField(const TfToken& name, const _FieldInfo& fieldInfo);
219  };
220 
221  /// Returns the field definition for the given field.
222  /// Returns NULL if no definition exists for given field.
223  SDF_API
224  const FieldDefinition* GetFieldDefinition(const TfToken &fieldKey) const;
225 
226  /// Returns the spec definition for the given spec type.
227  /// Returns NULL if no definition exists for the given spec type.
228  inline const SpecDefinition* GetSpecDefinition(SdfSpecType specType) const {
229  return _specDefinitions[specType].second ?
230  &_specDefinitions[specType].first : nullptr;
231  }
232 
233  /// Convenience functions for accessing specific field information.
234  /// @{
235 
236  /// Return whether the specified field has been registered. Also
237  /// optionally return the fallback value.
238  SDF_API
239  bool IsRegistered(const TfToken &fieldKey, VtValue *fallback=NULL) const;
240 
241  /// Returns whether the given field is a 'children' field -- that is, it
242  /// indexes certain children beneath the owning spec.
243  SDF_API
244  bool HoldsChildren(const TfToken &fieldKey) const;
245 
246  /// Return the fallback value for the specified \p fieldKey or the
247  /// empty value if \p fieldKey is not registered.
248  SDF_API
249  const VtValue& GetFallback(const TfToken &fieldKey) const;
250 
251  /// Coerce \p value to the correct type for the specified field.
252  SDF_API
253  VtValue CastToTypeOf(const TfToken &fieldKey, const VtValue &value) const;
254 
255  /// Return whether the given field is valid for the given spec type.
256  SDF_API
257  bool IsValidFieldForSpec(const TfToken &fieldKey, SdfSpecType specType) const;
258 
259  /// Returns all fields registered for the given spec type.
260  SDF_API TfTokenVector GetFields(SdfSpecType specType) const;
261 
262  /// Returns all metadata fields registered for the given spec type.
264 
265  /// Return the metadata field display group for metadata \a metadataField on
266  /// \a specType. Return the empty token if \a metadataField is not a
267  /// metadata field, or if it has no display group.
268  SDF_API
270  TfToken const &metadataField) const;
271 
272  /// Returns all required fields registered for the given spec type.
273  SDF_API const TfTokenVector &GetRequiredFields(SdfSpecType specType) const;
274 
275  /// Return true if \p fieldName is a required field name for at least one
276  /// spec type, return false otherwise. The main use of this function is to
277  /// quickly rule out field names that aren't required (and thus don't need
278  /// special handling).
279  inline bool IsRequiredFieldName(const TfToken &fieldName) const {
280  for (TfToken const &fname: _requiredFieldNames) {
281  if (fname == fieldName) {
282  return true;
283  }
284  }
285  return false;
286  }
287 
288  /// @}
289 
290  /// Specific validation functions for various fields. These are internally
291  /// registered as validators for the associated field, but can also be
292  /// used directly.
293  /// @{
294 
295  SDF_API
297  SDF_API
299  SDF_API
301  SDF_API
302  static SdfAllowed IsValidInheritPath(const SdfPath& path);
303  SDF_API
304  static SdfAllowed IsValidPayload(const SdfPayload& payload);
305  SDF_API
307  SDF_API
309  SDF_API
311  SDF_API
313  SDF_API
314  static SdfAllowed IsValidSubLayer(const std::string& sublayer);
315  SDF_API
317  SDF_API
319 
320  /// @}
321 
322  /// Scene description value types
323  /// @{
324 
325  /// Given a value, check if it is a valid value type.
326  /// This function only checks that the type of the value is valid
327  /// for this schema. It does not imply that the value is valid for
328  /// a particular field -- the field's validation function must be
329  /// used for that.
330  SDF_API
331  SdfAllowed IsValidValue(const VtValue& value) const;
332 
333  /// Returns all registered type names.
334  SDF_API
335  std::vector<SdfValueTypeName> GetAllTypes() const;
336 
337  /// Return the type name object for the given type name token.
338  SDF_API
339  SdfValueTypeName FindType(const TfToken& typeName) const;
340  /// \overload
341  SDF_API
342  SdfValueTypeName FindType(const char *typeName) const;
343  /// \overload
344  SDF_API
345  SdfValueTypeName FindType(std::string const &typeName) const;
346 
347  /// Return the type name object for the given type and optional role.
348  SDF_API
350  const TfToken& role = TfToken()) const;
351 
352  /// Return the type name object for the value's type and optional role.
353  SDF_API
355  const TfToken& role = TfToken()) const;
356 
357  /// Return the type name object for the given type name string if it
358  /// exists otherwise create a temporary type name object. Clients
359  /// should not normally need to call this.
360  SDF_API
361  SdfValueTypeName FindOrCreateType(const TfToken& typeName) const;
362 
363  /// @}
364 
365 protected:
366  /// \class _SpecDefiner
367  ///
368  /// Class that defines fields for a spec type.
369  ///
370  class _SpecDefiner {
371  public:
372  /// Functions for setting spec attributes during registration
373  /// @{
374 
376  const TfToken& name, bool required = false);
378  const TfToken& name, bool required = false);
380  const TfToken& name, const TfToken& displayGroup,
381  bool required = false);
382 
383  _SpecDefiner &CopyFrom(const SpecDefinition &other);
384 
385  /// @}
386  private:
387  friend class SdfSchemaBase;
388  explicit _SpecDefiner(SdfSchemaBase *schema, SpecDefinition *definition)
389  : _schema(schema)
390  , _definition(definition)
391  {}
392  SdfSchemaBase *_schema;
393  SpecDefinition *_definition;
394  };
395 
396  /// A helper for registering value types.
398  public:
399  explicit _ValueTypeRegistrar(Sdf_ValueTypeRegistry*);
400 
401  class Type
402  {
403  public:
404  ~Type();
405 
406  // Specify a type with the given name, default value, and default
407  // array value of VtArray<T>.
408  template <class T>
409  Type(const TfToken& name, const T& defaultValue)
410  : Type(name, VtValue(defaultValue), VtValue(VtArray<T>()))
411  { }
412  template <class T>
413  Type(char const *name, const T& defaultValue)
414  : Type(TfToken(name),
415  VtValue(defaultValue), VtValue(VtArray<T>()))
416  { }
417 
418  // Specify a type with the given name and underlying C++ type.
419  // No default value or array value will be registered.
420  Type(const TfToken& name, const TfType& type);
421 
422  // Set C++ type name string for this type. Defaults to type name
423  // from TfType.
424  Type& CPPTypeName(const std::string& cppTypeName);
425 
426  // Set shape for this type. Defaults to shapeless.
427  Type& Dimensions(const SdfTupleDimensions& dims);
428 
429  // Set default unit for this type. Defaults to dimensionless unit.
431 
432  // Set role for this type. Defaults to no role.
433  Type& Role(const TfToken& role);
434 
435  // Indicate that arrays of this type are not supported.
436  Type& NoArrays();
437 
438  private:
439  Type(const TfToken& name,
440  const VtValue& defaultValue,
441  const VtValue& defaultArrayValue);
442 
443  class _Impl;
444  std::unique_ptr<_Impl> _impl;
445 
446  friend class _ValueTypeRegistrar;
447  };
448 
449  /// Register a value type and its corresponding array value type.
450  void AddType(const Type& type);
451 
452  private:
453  Sdf_ValueTypeRegistry* _registry;
454  };
455 
456  SdfSchemaBase();
457 
458  /// Construct an SdfSchemaBase but does not populate it with standard
459  /// fields and types.
460  class EmptyTag {};
462 
463  virtual ~SdfSchemaBase();
464 
465  /// Creates and registers a new field named \p fieldKey with the fallback
466  /// value \p fallback. If \p plugin is specified, it indicates that this
467  /// field is not a built-in field from this schema, but rather a field
468  /// that was externally registered.
469  ///
470  /// It is a fatal error to call this function with a key that has already
471  /// been used for another field.
472  template <class T>
474  const TfToken &fieldKey, const T &fallback, bool plugin = false)
475  {
476  return _CreateField(fieldKey, VtValue(fallback), plugin);
477  }
478 
479  /// Registers the given spec \p type with this schema and return a
480  /// _SpecDefiner for specifying additional fields.
482  // Mark the definition as valid and return a pointer to it.
483  _specDefinitions[type].second = true;
484  return _SpecDefiner(this, &_specDefinitions[type].first);
485  }
486 
487  /// Returns a _SpecDefiner for the previously-defined spec \p type
488  /// for specifying additional fields.
490 
491  /// Registers the standard fields.
493 
494  /// Registers plugin fields and sets up handling so that fields will
495  /// be added when additional plugins are registered.
496  void _RegisterPluginFields();
497 
498  /// Registers standard attribute value types.
499  void _RegisterStandardTypes();
500 
501  /// Registers legacy attribute value types.
502  void _RegisterLegacyTypes();
503 
504  /// Returns a type registrar.
505  _ValueTypeRegistrar _GetTypeRegistrar() const;
506 
507  /// Factory function for creating a default value for a metadata
508  /// field. The parameters are the value type name and default
509  /// value (if any) specified in the defining plugin.
510  typedef std::function<VtValue(const std::string&, const JsValue&)>
512 
513  /// Registers all metadata fields specified in the given plugins
514  /// under the given metadata tag.
515  const std::vector<const SdfSchemaBase::FieldDefinition *>
516  _UpdateMetadataFromPlugins(const PlugPluginPtrVector& plugins,
517  const std::string& metadataTag =
518  std::string(),
519  const _DefaultValueFactoryFn& defFactory =
521 
522 private:
523  friend class _SpecDefiner;
524 
525  void _OnDidRegisterPlugins(const PlugNotice::DidRegisterPlugins& n);
526 
527  // Return a _SpecDefiner for an existing spec definition, \p local.
529  return _SpecDefiner(this, local);
530  }
531 
532  void _AddRequiredFieldName(const TfToken &name);
533 
534  const SpecDefinition* _CheckAndGetSpecDefinition(SdfSpecType type) const;
535 
537  FieldDefinition& _CreateField(
538  const TfToken &fieldKey, const VtValue &fallback, bool plugin = false);
539 
540  template <class T>
541  FieldDefinition& _DoRegisterField(const TfToken &fieldKey, const T &fallback)
542  {
543  return _DoRegisterField(fieldKey, VtValue(fallback));
544  }
545 
546  FieldDefinition& _DoRegisterField(
547  const TfToken &fieldKey, const VtValue &fallback);
548 
549 private:
552  _FieldDefinitionMap;
553  _FieldDefinitionMap _fieldDefinitions;
554 
555  // Pair of definition and flag indicating validity.
556  std::pair<SdfSchemaBase::SpecDefinition, bool>
557  _specDefinitions[SdfNumSpecTypes];
558 
559  std::unique_ptr<Sdf_ValueTypeRegistry> _valueTypeRegistry;
560  TfTokenVector _requiredFieldNames;
561 };
562 
563 /// \class SdfSchema
564 ///
565 /// Class that provides information about the various scene description
566 /// fields.
567 ///
568 class SdfSchema : public SdfSchemaBase {
569 public:
570  SDF_API
571  static const SdfSchema& GetInstance()
572  {
574  }
575 
576 private:
577  friend class TfSingleton<SdfSchema>;
578  SdfSchema();
579  virtual ~SdfSchema();
580 };
581 
583 
584 ///
585 /// The following fields are pre-registered by Sdf.
586 /// \showinitializer
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")) \
614  ((Kind, "kind")) \
615  ((PrimOrder, "primOrder")) \
616  ((NoLoadHint, "noLoadHint")) \
617  ((Owner, "owner")) \
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")) \
644  \
645  /* XXX: These fields should move into Sd. See bug 123508. */ \
646  ((EndFrame, "endFrame")) \
647  ((StartFrame, "startFrame"))
648 
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"))
659 
662 
664 
665 #endif // PXR_USD_SDF_SCHEMA_H
SDF_API const VtValue & GetFallback(const TfToken &fieldKey) const
GLint first
Definition: glcorearb.h:405
static SDF_API SdfAllowed IsValidAttributeConnectionPath(const SdfPath &path)
Type(const TfToken &name, const T &defaultValue)
Definition: schema.h:409
static SDF_API SdfAllowed IsValidVariantIdentifier(const std::string &name)
static T & GetInstance()
Definition: singleton.h:137
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)
Definition: schema.h:473
#define SDF_CHILDREN_KEYS
Definition: schema.h:649
SDF_API bool HoldsChildren(const TfToken &fieldKey) const
FieldDefinition(const SdfSchemaBase &schema, const TfToken &name, const VtValue &fallbackValue)
virtual ~SdfSchemaBase()
SDF_API bool IsPlugin() const
const GLdouble * v
Definition: glcorearb.h:837
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
Type & CPPTypeName(const std::string &cppTypeName)
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
FieldDefinition & FallbackValue(const VtValue &v)
_SpecDefiner _Define(SdfSpecType type)
Definition: schema.h:481
SDF_API const VtValue & GetFallbackValue() const
Definition: enum.h:137
Functor to use for hash maps from tokens to other things.
Definition: token.h:166
SDF_API TfTokenVector GetMetadataFields(SdfSpecType specType) const
Returns all metadata fields registered for the given spec type.
SdfAllowed IsValidMapKey(const T &value) const
Definition: schema.h:111
TfToken metadataDisplayGroup
Definition: schema.h:169
std::function< VtValue(const std::string &, const JsValue &)> _DefaultValueFactoryFn
Definition: schema.h:511
_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.
Definition: schema.h:184
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
Definition: schema.h:139
Type & Dimensions(const SdfTupleDimensions &dims)
friend class _SpecDefiner
Definition: schema.h:523
FieldDefinition & AddInfo(const TfToken &tok, const JsValue &val)
std::vector< std::pair< TfToken, JsValue > > InfoVec
Definition: schema.h:80
FieldDefinition & MapValueValidator(Validator v)
static SDF_API SdfAllowed IsValidInheritPath(const SdfPath &path)
Type(char const *name, const T &defaultValue)
Definition: schema.h:413
GLdouble n
Definition: glcorearb.h:2008
Definition: token.h:87
SDF_API bool IsMetadataField(const TfToken &name) const
Returns whether the given field is metadata for this spec.
FieldDefinition & Plugin()
_ValueTypeRegistrar(Sdf_ValueTypeRegistry *)
GLint ref
Definition: glcorearb.h:124
SDF_API const TfTokenVector & GetRequiredFields(SdfSpecType specType) const
Returns all required fields registered for the given spec type.
Definition: value.h:61
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
Definition: png.h:2161
SDF_API bool IsRegistered(const TfToken &fieldKey, VtValue *fallback=NULL) const
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:442
TF_DECLARE_WEAK_PTRS(PlugPlugin)
SDF_API std::vector< SdfValueTypeName > GetAllTypes() const
Returns all registered type names.
GLuint const GLchar * name
Definition: glcorearb.h:786
Definition: types.h:173
Definition: path.h:291
friend struct Sdf_SchemaFieldTypeRegistrar
Definition: schema.h:536
bool IsRequiredFieldName(const TfToken &fieldName) const
Definition: schema.h:279
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()
Definition: schema.h:571
A helper for registering value types.
Definition: schema.h:397
SDF_API const FieldDefinition * GetFieldDefinition(const TfToken &fieldKey) const
_ValueTypeRegistrar _GetTypeRegistrar() const
Returns a type registrar.
#define SDF_API
Definition: api.h:40
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
Definition: path.h:1441
SdfSpecType
Definition: types.h:90
static SDF_API SdfAllowed IsValidRelocatesPath(const SdfPath &path)
static SDF_API SdfAllowed IsValidPayload(const SdfPayload &payload)
SdfAllowed IsValidListValue(const T &value) const
Definition: schema.h:103
Type & Role(const TfToken &role)
GLuint GLfloat * val
Definition: glcorearb.h:1608
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
SdfAllowed IsValidMapValue(const T &value) const
Definition: schema.h:119
SdfAllowed IsValidValue(const T &value) const
Definition: schema.h:95
void _RegisterStandardTypes()
Registers standard attribute value types.
Definition: type.h:64
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
Definition: core.h:1131
SDF_API TfTokenVector GetFields(SdfSpecType specType) const
Returns all fields registered for the given spec type.
SDF_API const TfToken & GetName() const
#define SDF_FIELD_KEYS
Definition: schema.h:587
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.
type
Definition: core.h:1059
FieldDefinition & ListValueValidator(Validator v)
const SpecDefinition * GetSpecDefinition(SdfSpecType specType) const
Definition: schema.h:228
SDF_API TfTokenVector GetFields() const
Returns all fields for this spec.
Definition: value.h:167
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)