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 terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_USD_SDF_SCHEMA_H
8 #define PXR_USD_SDF_SCHEMA_H
9 
10 #include "pxr/pxr.h"
11 #include "pxr/usd/sdf/api.h"
12 #include "pxr/usd/sdf/allowed.h"
13 #include "pxr/usd/sdf/types.h"
15 
16 #include "pxr/base/plug/notice.h"
17 #include "pxr/base/tf/hash.h"
18 #include "pxr/base/tf/hashmap.h"
19 #include "pxr/base/tf/singleton.h"
21 #include "pxr/base/tf/token.h"
22 #include "pxr/base/tf/type.h"
23 #include "pxr/base/tf/weakBase.h"
24 #include "pxr/base/vt/value.h"
25 
26 #include <memory>
27 #include <string>
28 #include <vector>
29 
31 
32 class JsValue;
33 class SdfPath;
34 class SdfPayload;
35 class SdfReference;
36 class Sdf_ValueTypeRegistry;
37 
39 
40 /// \class SdfSchemaBase
41 ///
42 /// Generic class that provides information about scene description fields
43 /// but doesn't actually provide any fields.
44 ///
45 class SdfSchemaBase : public TfWeakBase {
46  SdfSchemaBase(const SdfSchemaBase&) = delete;
47  SdfSchemaBase& operator=(const SdfSchemaBase&) = delete;
48 protected:
49  class _SpecDefiner;
50 
51 public:
52  /// \class FieldDefinition
53  ///
54  /// Class defining various attributes for a field.
55  ///
57  public:
59  const SdfSchemaBase& schema,
60  const TfToken& name,
61  const VtValue& fallbackValue);
62 
63  typedef std::vector< std::pair<TfToken, JsValue> > InfoVec;
64 
65  SDF_API const TfToken& GetName() const;
66  SDF_API const VtValue& GetFallbackValue() const;
67  SDF_API const InfoVec& GetInfo() const;
68 
69  SDF_API bool IsPlugin() const;
70  SDF_API bool IsReadOnly() const;
71  SDF_API bool HoldsChildren() const;
72 
73  /// Validation functions that return true if a given value passes
74  /// the registered validator or if no validator has been set.
75  /// @{
76 
77  template <class T>
79  {
80  return (_valueValidator ?
81  _valueValidator(_schema, VtValue(value)) :
82  SdfAllowed(true));
83  }
84 
85  template <class T>
87  {
88  return (_listValueValidator ?
89  _listValueValidator(_schema, VtValue(value)) :
90  SdfAllowed(true));
91  }
92 
93  template <class T>
95  {
96  return (_mapKeyValidator ?
97  _mapKeyValidator(_schema, VtValue(value)) :
98  SdfAllowed(true));
99  }
100 
101  template <class T>
103  {
104  return (_mapValueValidator ?
105  _mapValueValidator(_schema, VtValue(value)) :
106  SdfAllowed(true));
107  }
108 
109  /// @}
110 
111  /// Functions for setting field attributes during registration.
112  /// @{
113 
115 
119  FieldDefinition& AddInfo(const TfToken& tok, const JsValue& val);
120 
121  using Validator =
122  SdfAllowed (*) (const SdfSchemaBase&, const VtValue&);
127 
128  /// @}
129 
130  private:
131  const SdfSchemaBase& _schema;
132  TfToken _name;
133  VtValue _fallbackValue;
134  InfoVec _info;
135 
136  bool _isPlugin;
137  bool _isReadOnly;
138  bool _holdsChildren;
139 
140  Validator _valueValidator;
141  Validator _listValueValidator;
142  Validator _mapKeyValidator;
143  Validator _mapValueValidator;
144  };
145 
146  // Structure containing information about a field as it pertains to the
147  // spec this object defines.
148  struct _FieldInfo {
149  _FieldInfo(): required(false), metadata(false) { }
150  bool required;
151  bool metadata;
153  };
154 
155  class SpecDefinition;
156 
157  /// \class SpecDefinition
158  ///
159  /// Class representing fields and other information for a spec type.
160  ///
162  public:
163  /// Returns all fields for this spec.
165 
166  /// Returns all value fields marked as required for this spec.
168  return _requiredFields;
169  }
170 
171  /// Returns all value fields marked as metadata for this spec.
173 
174  /// Returns whether the given field is valid for this spec.
175  SDF_API bool IsValidField(const TfToken& name) const;
176 
177  /// Returns whether the given field is metadata for this spec.
178  SDF_API bool IsMetadataField(const TfToken& name) const;
179 
180  /// Returns the display group for this metadata field. Returns the
181  /// empty token if this field is not a metadata field or if this
182  /// metadata field has no display group.
183  SDF_API
185 
186  /// Returns whether the given field is required for this spec.
187  SDF_API bool IsRequiredField(const TfToken& name) const;
188 
189 
190  private:
192  _FieldMap;
193  _FieldMap _fields;
194 
195  // A separate vector of required field names from _fields. Access to
196  // these is in a hot path, so we cache them separately.
197  TfTokenVector _requiredFields;
198 
199  private:
200  friend class _SpecDefiner;
201  void _AddField(const TfToken& name, const _FieldInfo& fieldInfo);
202  };
203 
204  /// Returns the field definition for the given field.
205  /// Returns NULL if no definition exists for given field.
206  SDF_API
207  const FieldDefinition* GetFieldDefinition(const TfToken &fieldKey) const;
208 
209  /// Returns the spec definition for the given spec type.
210  /// Returns NULL if no definition exists for the given spec type.
211  inline const SpecDefinition* GetSpecDefinition(SdfSpecType specType) const {
212  #ifdef PXR_PREFER_SAFETY_OVER_SPEED
213  if (ARCH_UNLIKELY(specType < SdfSpecTypeUnknown ||
214  specType >= SdfNumSpecTypes))
215  {
216  return _IssueErrorForInvalidSpecType(specType);
217  }
218  #endif // PXR_PREFER_SAFETY_OVER_SPEED
219 
220  return _specDefinitions[specType].second ?
221  &_specDefinitions[specType].first : nullptr;
222  }
223 
224  /// Convenience functions for accessing specific field information.
225  /// @{
226 
227  /// Return whether the specified field has been registered. Also
228  /// optionally return the fallback value.
229  SDF_API
230  bool IsRegistered(const TfToken &fieldKey, VtValue *fallback=NULL) const;
231 
232  /// Returns whether the given field is a 'children' field -- that is, it
233  /// indexes certain children beneath the owning spec.
234  SDF_API
235  bool HoldsChildren(const TfToken &fieldKey) const;
236 
237  /// Return the fallback value for the specified \p fieldKey or the
238  /// empty value if \p fieldKey is not registered.
239  SDF_API
240  const VtValue& GetFallback(const TfToken &fieldKey) const;
241 
242  /// Coerce \p value to the correct type for the specified field.
243  SDF_API
244  VtValue CastToTypeOf(const TfToken &fieldKey, const VtValue &value) const;
245 
246  /// Return whether the given field is valid for the given spec type.
247  SDF_API
248  bool IsValidFieldForSpec(const TfToken &fieldKey, SdfSpecType specType) const;
249 
250  /// Returns all fields registered for the given spec type.
251  SDF_API TfTokenVector GetFields(SdfSpecType specType) const;
252 
253  /// Returns all metadata fields registered for the given spec type.
255 
256  /// Return the metadata field display group for metadata \a metadataField on
257  /// \a specType. Return the empty token if \a metadataField is not a
258  /// metadata field, or if it has no display group.
259  SDF_API
261  TfToken const &metadataField) const;
262 
263  /// Returns all required fields registered for the given spec type.
264  SDF_API const TfTokenVector &GetRequiredFields(SdfSpecType specType) const;
265 
266  /// Return true if \p fieldName is a required field name for at least one
267  /// spec type, return false otherwise. The main use of this function is to
268  /// quickly rule out field names that aren't required (and thus don't need
269  /// special handling).
270  inline bool IsRequiredFieldName(const TfToken &fieldName) const {
271  for (TfToken const &fname: _requiredFieldNames) {
272  if (fname == fieldName) {
273  return true;
274  }
275  }
276  return false;
277  }
278 
279  /// @}
280 
281  /// Specific validation functions for various fields. These are internally
282  /// registered as validators for the associated field, but can also be
283  /// used directly.
284  /// @{
285 
286  SDF_API
288  SDF_API
289  static SdfAllowed IsValidIdentifier(const std::string& name);
290  SDF_API
291  static SdfAllowed IsValidNamespacedIdentifier(const std::string& name);
292  SDF_API
293  static SdfAllowed IsValidInheritPath(const SdfPath& path);
294  SDF_API
295  static SdfAllowed IsValidPayload(const SdfPayload& payload);
296  SDF_API
298  SDF_API
300  SDF_API
302  SDF_API
304  SDF_API
305  static SdfAllowed IsValidRelocate(const SdfRelocate& relocate);
306  SDF_API
308  SDF_API
309  static SdfAllowed IsValidSubLayer(const std::string& sublayer);
310  SDF_API
311  static SdfAllowed IsValidVariantIdentifier(const std::string& name);
312  SDF_API
313  static SdfAllowed IsValidVariantSelection(const std::string& sel);
314 
315  /// @}
316 
317  /// Scene description value types
318  /// @{
319 
320  /// Given a value, check if it is a valid value type.
321  /// This function only checks that the type of the value is valid
322  /// for this schema. It does not imply that the value is valid for
323  /// a particular field -- the field's validation function must be
324  /// used for that.
325  SDF_API
326  SdfAllowed IsValidValue(const VtValue& value) const;
327 
328  /// Returns all registered type names.
329  SDF_API
330  std::vector<SdfValueTypeName> GetAllTypes() const;
331 
332  /// Return the type name object for the given type name token.
333  SDF_API
334  SdfValueTypeName FindType(const TfToken& typeName) const;
335  /// \overload
336  SDF_API
337  SdfValueTypeName FindType(const char *typeName) const;
338  /// \overload
339  SDF_API
340  SdfValueTypeName FindType(std::string const &typeName) const;
341 
342  /// Return the type name object for the given type and optional role.
343  SDF_API
345  const TfToken& role = TfToken()) const;
346 
347  /// Return the type name object for the value's type and optional role.
348  SDF_API
350  const TfToken& role = TfToken()) const;
351 
352  /// Return the type name object for the given type name string if it
353  /// exists otherwise create a temporary type name object. Clients
354  /// should not normally need to call this.
355  SDF_API
356  SdfValueTypeName FindOrCreateType(const TfToken& typeName) const;
357 
358  /// @}
359 
360 protected:
361  /// \class _SpecDefiner
362  ///
363  /// Class that defines fields for a spec type.
364  ///
365  class _SpecDefiner {
366  public:
367  /// Functions for setting spec attributes during registration
368  /// @{
369 
371  const TfToken& name, bool required = false);
373  const TfToken& name, bool required = false);
375  const TfToken& name, const TfToken& displayGroup,
376  bool required = false);
377 
378  _SpecDefiner &CopyFrom(const SpecDefinition &other);
379 
380  /// @}
381  private:
382  friend class SdfSchemaBase;
383  explicit _SpecDefiner(SdfSchemaBase *schema, SpecDefinition *definition)
384  : _schema(schema)
385  , _definition(definition)
386  {}
387  SdfSchemaBase *_schema;
388  SpecDefinition *_definition;
389  };
390 
391  /// A helper for registering value types.
393  public:
394  explicit _ValueTypeRegistrar(Sdf_ValueTypeRegistry*);
395 
396  class Type
397  {
398  public:
399  ~Type();
400 
401  // Specify a type with the given name, default value, and default
402  // array value of VtArray<T>.
403  template <class T>
404  Type(const TfToken& name, const T& defaultValue)
405  : Type(name, VtValue(defaultValue), VtValue(VtArray<T>()))
406  { }
407  template <class T>
408  Type(char const *name, const T& defaultValue)
409  : Type(TfToken(name),
410  VtValue(defaultValue), VtValue(VtArray<T>()))
411  { }
412 
413  // Specify a type with the given name and underlying C++ type.
414  // No default value or array value will be registered.
415  Type(const TfToken& name, const TfType& type);
416 
417  // Set C++ type name string for this type. Defaults to type name
418  // from TfType.
419  Type& CPPTypeName(const std::string& cppTypeName);
420 
421  // Set shape for this type. Defaults to shapeless.
422  Type& Dimensions(const SdfTupleDimensions& dims);
423 
424  // Set default unit for this type. Defaults to dimensionless unit.
426 
427  // Set role for this type. Defaults to no role.
428  Type& Role(const TfToken& role);
429 
430  // Indicate that arrays of this type are not supported.
431  Type& NoArrays();
432 
433  private:
434  Type(const TfToken& name,
435  const VtValue& defaultValue,
436  const VtValue& defaultArrayValue);
437 
438  class _Impl;
439  std::unique_ptr<_Impl> _impl;
440 
441  friend class _ValueTypeRegistrar;
442  };
443 
444  /// Register a value type and its corresponding array value type.
445  void AddType(const Type& type);
446 
447  private:
448  Sdf_ValueTypeRegistry* _registry;
449  };
450 
451  SdfSchemaBase();
452 
453  /// Construct an SdfSchemaBase but does not populate it with standard
454  /// fields and types.
455  class EmptyTag {};
457 
458  virtual ~SdfSchemaBase();
459 
460  /// Creates and registers a new field named \p fieldKey with the fallback
461  /// value \p fallback. If \p plugin is specified, it indicates that this
462  /// field is not a built-in field from this schema, but rather a field
463  /// that was externally registered.
464  ///
465  /// It is a fatal error to call this function with a key that has already
466  /// been used for another field.
467  template <class T>
469  const TfToken &fieldKey, const T &fallback, bool plugin = false)
470  {
471  return _CreateField(fieldKey, VtValue(fallback), plugin);
472  }
473 
474  /// Registers the given spec \p type with this schema and return a
475  /// _SpecDefiner for specifying additional fields.
477  // Mark the definition as valid and return a pointer to it.
478  _specDefinitions[type].second = true;
479  return _SpecDefiner(this, &_specDefinitions[type].first);
480  }
481 
482  /// Returns a _SpecDefiner for the previously-defined spec \p type
483  /// for specifying additional fields.
485 
486  /// Registers the standard fields.
488 
489  /// Registers plugin fields and sets up handling so that fields will
490  /// be added when additional plugins are registered.
491  void _RegisterPluginFields();
492 
493  /// Registers standard attribute value types.
494  void _RegisterStandardTypes();
495 
496  /// Registers legacy attribute value types.
497  void _RegisterLegacyTypes();
498 
499  /// Returns a type registrar.
500  _ValueTypeRegistrar _GetTypeRegistrar() const;
501 
502  /// Factory function for creating a default value for a metadata
503  /// field. The parameters are the value type name and default
504  /// value (if any) specified in the defining plugin.
505  typedef std::function<VtValue(const std::string&, const JsValue&)>
507 
508  /// Registers all metadata fields specified in the given plugins
509  /// under the given metadata tag.
510  const std::vector<const SdfSchemaBase::FieldDefinition *>
511  _UpdateMetadataFromPlugins(const PlugPluginPtrVector& plugins,
512  const std::string& metadataTag =
513  std::string(),
514  const _DefaultValueFactoryFn& defFactory =
516 
517 private:
518  friend class _SpecDefiner;
519 
520  void _OnDidRegisterPlugins(const PlugNotice::DidRegisterPlugins& n);
521 
522  // Return a _SpecDefiner for an existing spec definition, \p local.
524  return _SpecDefiner(this, local);
525  }
526 
527  void _AddRequiredFieldName(const TfToken &name);
528 
529  const SpecDefinition* _CheckAndGetSpecDefinition(SdfSpecType type) const;
530 
531  SDF_API
532  const SpecDefinition* _IssueErrorForInvalidSpecType(SdfSpecType specType) const;
533 
535  FieldDefinition& _CreateField(
536  const TfToken &fieldKey, const VtValue &fallback, bool plugin = false);
537 
538  template <class T>
539  FieldDefinition& _DoRegisterField(const TfToken &fieldKey, const T &fallback)
540  {
541  return _DoRegisterField(fieldKey, VtValue(fallback));
542  }
543 
544  FieldDefinition& _DoRegisterField(
545  const TfToken &fieldKey, const VtValue &fallback);
546 
547 private:
550  _FieldDefinitionMap;
551  _FieldDefinitionMap _fieldDefinitions;
552 
553  // Pair of definition and flag indicating validity.
554  std::pair<SdfSchemaBase::SpecDefinition, bool>
555  _specDefinitions[SdfNumSpecTypes];
556 
557  std::unique_ptr<Sdf_ValueTypeRegistry> _valueTypeRegistry;
558  TfTokenVector _requiredFieldNames;
559 };
560 
561 /// \class SdfSchema
562 ///
563 /// Class that provides information about the various scene description
564 /// fields.
565 ///
566 class SdfSchema : public SdfSchemaBase {
567 public:
568  SDF_API
569  static const SdfSchema& GetInstance()
570  {
572  }
573 
574 private:
575  friend class TfSingleton<SdfSchema>;
576  SdfSchema();
577  virtual ~SdfSchema();
578 };
579 
581 
582 ///
583 /// The following fields are pre-registered by Sdf.
584 /// \showinitializer
585 #define SDF_FIELD_KEYS \
586  ((Active, "active")) \
587  ((AllowedTokens, "allowedTokens")) \
588  ((AssetInfo, "assetInfo")) \
589  ((ColorConfiguration, "colorConfiguration")) \
590  ((ColorManagementSystem, "colorManagementSystem")) \
591  ((ColorSpace, "colorSpace")) \
592  ((Comment, "comment")) \
593  ((ConnectionPaths, "connectionPaths")) \
594  ((Custom, "custom")) \
595  ((CustomData, "customData")) \
596  ((CustomLayerData, "customLayerData")) \
597  ((Default, "default")) \
598  ((DefaultPrim, "defaultPrim")) \
599  ((DisplayGroup, "displayGroup")) \
600  ((DisplayGroupOrder, "displayGroupOrder")) \
601  ((DisplayName, "displayName")) \
602  ((DisplayUnit, "displayUnit")) \
603  ((Documentation, "documentation")) \
604  ((EndTimeCode, "endTimeCode")) \
605  ((ExpressionVariables, "expressionVariables")) \
606  ((FramePrecision, "framePrecision")) \
607  ((FramesPerSecond, "framesPerSecond")) \
608  ((Hidden, "hidden")) \
609  ((HasOwnedSubLayers, "hasOwnedSubLayers")) \
610  ((InheritPaths, "inheritPaths")) \
611  ((Instanceable, "instanceable")) \
612  ((Kind, "kind")) \
613  ((LayerRelocates, "layerRelocates")) \
614  ((PrimOrder, "primOrder")) \
615  ((NoLoadHint, "noLoadHint")) \
616  ((Owner, "owner")) \
617  ((Payload, "payload")) \
618  ((Permission, "permission")) \
619  ((Prefix, "prefix")) \
620  ((PrefixSubstitutions, "prefixSubstitutions")) \
621  ((PropertyOrder, "propertyOrder")) \
622  ((References, "references")) \
623  ((Relocates, "relocates")) \
624  ((SessionOwner, "sessionOwner")) \
625  ((Specializes, "specializes")) \
626  ((Specifier, "specifier")) \
627  ((Spline, "spline")) \
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
type
Definition: core.h:556
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:404
static SDF_API SdfAllowed IsValidVariantIdentifier(const std::string &name)
static T & GetInstance()
Definition: singleton.h:120
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:468
#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 GLfloat * value
Definition: glcorearb.h:824
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:476
SDF_API const VtValue & GetFallbackValue() const
Definition: enum.h:119
Functor to use for hash maps from tokens to other things.
Definition: token.h:149
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:94
TfToken metadataDisplayGroup
Definition: schema.h:152
std::function< VtValue(const std::string &, const JsValue &)> _DefaultValueFactoryFn
Definition: schema.h:506
_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:167
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:122
Type & Dimensions(const SdfTupleDimensions &dims)
friend class _SpecDefiner
Definition: schema.h:518
FieldDefinition & AddInfo(const TfToken &tok, const JsValue &val)
std::vector< std::pair< TfToken, JsValue > > InfoVec
Definition: schema.h:63
FieldDefinition & MapValueValidator(Validator v)
static SDF_API SdfAllowed IsValidInheritPath(const SdfPath &path)
static SDF_API SdfAllowed IsValidRelocatesTargetPath(const SdfPath &path)
#define ARCH_UNLIKELY(x)
Definition: hints.h:30
Type(char const *name, const T &defaultValue)
Definition: schema.h:408
GLdouble n
Definition: glcorearb.h:2008
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
Definition: token.h:70
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 *)
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:44
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:440
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:153
Definition: path.h:273
friend struct Sdf_SchemaFieldTypeRegistrar
Definition: schema.h:534
bool IsRequiredFieldName(const TfToken &fieldName) const
Definition: schema.h:270
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:569
A helper for registering value types.
Definition: schema.h:392
SDF_API const FieldDefinition * GetFieldDefinition(const TfToken &fieldKey) const
_ValueTypeRegistrar _GetTypeRegistrar() const
Returns a type registrar.
#define SDF_API
Definition: api.h:23
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:1425
SdfSpecType
Definition: types.h:68
static SDF_API SdfAllowed IsValidPayload(const SdfPayload &payload)
SdfAllowed IsValidListValue(const T &value) const
Definition: schema.h:86
Type & Role(const TfToken &role)
GLuint GLfloat * val
Definition: glcorearb.h:1608
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
SdfAllowed IsValidMapValue(const T &value) const
Definition: schema.h:102
SdfAllowed IsValidValue(const T &value) const
Definition: schema.h:78
void _RegisterStandardTypes()
Registers standard attribute value types.
Definition: type.h:47
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
#define SDF_FIELD_KEYS
Definition: schema.h:585
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
Definition: schema.h:211
SDF_API TfTokenVector GetFields() const
Returns all fields for this spec.
Definition: value.h:146
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
Definition: types.h:271
SDF_API bool IsReadOnly() const
TF_DECLARE_PUBLIC_TOKENS(SdfFieldKeys, SDF_API, SDF_FIELD_KEYS)