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, public hboost::noncopyable {
63 
64 protected:
65  class _SpecDefiner;
66 
67 public:
68  /// \class FieldDefinition
69  ///
70  /// Class defining various attributes for a field.
71  ///
73  public:
75  const SdfSchemaBase& schema,
76  const TfToken& name,
77  const VtValue& fallbackValue);
78 
79  typedef std::vector< std::pair<TfToken, JsValue> > InfoVec;
80 
81  SDF_API const TfToken& GetName() const;
82  SDF_API const VtValue& GetFallbackValue() const;
83  SDF_API const InfoVec& GetInfo() const;
84 
85  SDF_API bool IsPlugin() const;
86  SDF_API bool IsReadOnly() const;
87  SDF_API bool HoldsChildren() const;
88 
89  /// Validation functions that return true if a given value passes
90  /// the registered validator or if no validator has been set.
91  /// @{
92 
93  template <class T>
95  {
96  return (_valueValidator ?
97  _valueValidator(_schema, VtValue(value)) :
98  SdfAllowed(true));
99  }
100 
101  template <class T>
103  {
104  return (_listValueValidator ?
105  _listValueValidator(_schema, VtValue(value)) :
106  SdfAllowed(true));
107  }
108 
109  template <class T>
111  {
112  return (_mapKeyValidator ?
113  _mapKeyValidator(_schema, VtValue(value)) :
114  SdfAllowed(true));
115  }
116 
117  template <class T>
119  {
120  return (_mapValueValidator ?
121  _mapValueValidator(_schema, VtValue(value)) :
122  SdfAllowed(true));
123  }
124 
125  /// @}
126 
127  /// Functions for setting field attributes during registration.
128  /// @{
129 
131 
135  FieldDefinition& AddInfo(const TfToken& tok, const JsValue& val);
136 
137  using Validator =
138  SdfAllowed (*) (const SdfSchemaBase&, const VtValue&);
143 
144  /// @}
145 
146  private:
147  const SdfSchemaBase& _schema;
148  TfToken _name;
149  VtValue _fallbackValue;
150  InfoVec _info;
151 
152  bool _isPlugin;
153  bool _isReadOnly;
154  bool _holdsChildren;
155 
156  Validator _valueValidator;
157  Validator _listValueValidator;
158  Validator _mapKeyValidator;
159  Validator _mapValueValidator;
160  };
161 
162  // Structure containing information about a field as it pertains to the
163  // spec this object defines.
164  struct _FieldInfo {
165  _FieldInfo(): required(false), metadata(false) { }
166  bool required;
167  bool metadata;
169  };
170 
171  class SpecDefinition;
172 
173  /// \class SpecDefinition
174  ///
175  /// Class representing fields and other information for a spec type.
176  ///
178  public:
179  /// Returns all fields for this spec.
181 
182  /// Returns all value fields marked as required for this spec.
184  return _requiredFields;
185  }
186 
187  /// Returns all value fields marked as metadata for this spec.
189 
190  /// Returns whether the given field is valid for this spec.
191  SDF_API bool IsValidField(const TfToken& name) const;
192 
193  /// Returns whether the given field is metadata for this spec.
194  SDF_API bool IsMetadataField(const TfToken& name) const;
195 
196  /// Returns the display group for this metadata field. Returns the
197  /// empty token if this field is not a metadata field or if this
198  /// metadata field has no display group.
199  SDF_API
201 
202  /// Returns whether the given field is required for this spec.
203  SDF_API bool IsRequiredField(const TfToken& name) const;
204 
205 
206  private:
208  _FieldMap;
209  _FieldMap _fields;
210 
211  // A separate vector of required field names from _fields. Access to
212  // these is in a hot path, so we cache them separately.
213  TfTokenVector _requiredFields;
214 
215  private:
216  friend class _SpecDefiner;
217  void _AddField(const TfToken& name, const _FieldInfo& fieldInfo);
218  };
219 
220  /// Returns the field definition for the given field.
221  /// Returns NULL if no definition exists for given field.
222  SDF_API
223  const FieldDefinition* GetFieldDefinition(const TfToken &fieldKey) const;
224 
225  /// Returns the spec definition for the given spec type.
226  /// Returns NULL if no definition exists for the given spec type.
227  inline const SpecDefinition* GetSpecDefinition(SdfSpecType specType) const {
228  return _specDefinitions[specType].second ?
229  &_specDefinitions[specType].first : nullptr;
230  }
231 
232  /// Convenience functions for accessing specific field information.
233  /// @{
234 
235  /// Return whether the specified field has been registered. Also
236  /// optionally return the fallback value.
237  SDF_API
238  bool IsRegistered(const TfToken &fieldKey, VtValue *fallback=NULL) const;
239 
240  /// Returns whether the given field is a 'children' field -- that is, it
241  /// indexes certain children beneath the owning spec.
242  SDF_API
243  bool HoldsChildren(const TfToken &fieldKey) const;
244 
245  /// Return the fallback value for the specified \p fieldKey or the
246  /// empty value if \p fieldKey is not registered.
247  SDF_API
248  const VtValue& GetFallback(const TfToken &fieldKey) const;
249 
250  /// Coerce \p value to the correct type for the specified field.
251  SDF_API
252  VtValue CastToTypeOf(const TfToken &fieldKey, const VtValue &value) const;
253 
254  /// Return whether the given field is valid for the given spec type.
255  SDF_API
256  bool IsValidFieldForSpec(const TfToken &fieldKey, SdfSpecType specType) const;
257 
258  /// Returns all fields registered for the given spec type.
259  SDF_API TfTokenVector GetFields(SdfSpecType specType) const;
260 
261  /// Returns all metadata fields registered for the given spec type.
263 
264  /// Return the metadata field display group for metadata \a metadataField on
265  /// \a specType. Return the empty token if \a metadataField is not a
266  /// metadata field, or if it has no display group.
267  SDF_API
269  TfToken const &metadataField) const;
270 
271  /// Returns all required fields registered for the given spec type.
272  SDF_API const TfTokenVector &GetRequiredFields(SdfSpecType specType) const;
273 
274  /// Return true if \p fieldName is a required field name for at least one
275  /// spec type, return false otherwise. The main use of this function is to
276  /// quickly rule out field names that aren't required (and thus don't need
277  /// special handling).
278  inline bool IsRequiredFieldName(const TfToken &fieldName) const {
279  for (size_t i = 0; i != _requiredFieldNames.size(); ++i) {
280  if (_requiredFieldNames[i] == fieldName)
281  return true;
282  }
283  return false;
284  }
285 
286  /// @}
287 
288  /// Specific validation functions for various fields. These are internally
289  /// registered as validators for the associated field, but can also be
290  /// used directly.
291  /// @{
292 
296  static SdfAllowed IsValidInheritPath(const SdfPath& path);
297  static SdfAllowed IsValidPayload(const SdfPayload& payload);
302  static SdfAllowed IsValidSubLayer(const std::string& sublayer);
304 
305  /// @}
306 
307  /// Scene description value types
308  /// @{
309 
310  /// Given a value, check if it is a valid value type.
311  /// This function only checks that the type of the value is valid
312  /// for this schema. It does not imply that the value is valid for
313  /// a particular field -- the field's validation function must be
314  /// used for that.
315  SDF_API
316  SdfAllowed IsValidValue(const VtValue& value) const;
317 
318  /// Returns all registered type names.
319  std::vector<SdfValueTypeName> GetAllTypes() const;
320 
321  /// Return the type name object for the given type name token.
322  SDF_API
323  SdfValueTypeName FindType(const TfToken& typeName) const;
324  /// \overload
325  SDF_API
326  SdfValueTypeName FindType(const char *typeName) const;
327  /// \overload
328  SDF_API
329  SdfValueTypeName FindType(std::string const &typeName) const;
330 
331  /// Return the type name object for the given type and optional role.
332  SDF_API
334  const TfToken& role = TfToken()) const;
335 
336  /// Return the type name object for the value's type and optional role.
337  SDF_API
339  const TfToken& role = TfToken()) const;
340 
341  /// Return the type name object for the given type name string if it
342  /// exists otherwise create a temporary type name object. Clients
343  /// should not normally need to call this.
344  SDF_API
345  SdfValueTypeName FindOrCreateType(const TfToken& typeName) const;
346 
347  /// @}
348 
349 protected:
350  /// \class _SpecDefiner
351  ///
352  /// Class that defines fields for a spec type.
353  ///
354  class _SpecDefiner {
355  public:
356  /// Functions for setting spec attributes during registration
357  /// @{
358 
360  const TfToken& name, bool required = false);
362  const TfToken& name, bool required = false);
364  const TfToken& name, const TfToken& displayGroup,
365  bool required = false);
366 
367  _SpecDefiner &CopyFrom(const SpecDefinition &other);
368 
369  /// @}
370  private:
371  friend class SdfSchemaBase;
372  explicit _SpecDefiner(SdfSchemaBase *schema, SpecDefinition *definition)
373  : _schema(schema)
374  , _definition(definition)
375  {}
376  SdfSchemaBase *_schema;
377  SpecDefinition *_definition;
378  };
379 
380  /// A helper for registering value types.
382  public:
383  explicit _ValueTypeRegistrar(Sdf_ValueTypeRegistry*);
384 
385  class Type
386  {
387  public:
388  ~Type();
389 
390  // Specify a type with the given name, default value, and default
391  // array value of VtArray<T>.
392  template <class T>
393  Type(const TfToken& name, const T& defaultValue)
394  : Type(name, VtValue(defaultValue), VtValue(VtArray<T>()))
395  { }
396  template <class T>
397  Type(char const *name, const T& defaultValue)
398  : Type(TfToken(name),
399  VtValue(defaultValue), VtValue(VtArray<T>()))
400  { }
401 
402  // Specify a type with the given name and underlying C++ type.
403  // No default value or array value will be registered.
404  Type(const TfToken& name, const TfType& type);
405 
406  // Set C++ type name string for this type. Defaults to type name
407  // from TfType.
408  Type& CPPTypeName(const std::string& cppTypeName);
409 
410  // Set shape for this type. Defaults to shapeless.
411  Type& Dimensions(const SdfTupleDimensions& dims);
412 
413  // Set default unit for this type. Defaults to dimensionless unit.
415 
416  // Set role for this type. Defaults to no role.
417  Type& Role(const TfToken& role);
418 
419  // Indicate that arrays of this type are not supported.
420  Type& NoArrays();
421 
422  private:
423  Type(const TfToken& name,
424  const VtValue& defaultValue,
425  const VtValue& defaultArrayValue);
426 
427  class _Impl;
428  std::unique_ptr<_Impl> _impl;
429 
430  friend class _ValueTypeRegistrar;
431  };
432 
433  /// Register a value type and its corresponding array value type.
434  void AddType(const Type& type);
435 
436  private:
437  Sdf_ValueTypeRegistry* _registry;
438  };
439 
440  SdfSchemaBase();
441 
442  /// Construct an SdfSchemaBase but does not populate it with standard
443  /// fields and types.
444  class EmptyTag {};
446 
447  virtual ~SdfSchemaBase();
448 
449  /// Creates and registers a new field named \p fieldKey with the fallback
450  /// value \p fallback. If \p plugin is specified, it indicates that this
451  /// field is not a built-in field from this schema, but rather a field
452  /// that was externally registered.
453  ///
454  /// It is a fatal error to call this function with a key that has already
455  /// been used for another field.
456  template <class T>
458  const TfToken &fieldKey, const T &fallback, bool plugin = false)
459  {
460  return _CreateField(fieldKey, VtValue(fallback), plugin);
461  }
462 
463  /// Registers the given spec \p type with this schema and return a
464  /// _SpecDefiner for specifying additional fields.
466  // Mark the definition as valid and return a pointer to it.
467  _specDefinitions[type].second = true;
468  return _SpecDefiner(this, &_specDefinitions[type].first);
469  }
470 
471  /// Returns a _SpecDefiner for the previously-defined spec \p type
472  /// for specifying additional fields.
474 
475  /// Registers the standard fields.
477 
478  /// Registers plugin fields and sets up handling so that fields will
479  /// be added when additional plugins are registered.
480  void _RegisterPluginFields();
481 
482  /// Registers standard attribute value types.
483  void _RegisterStandardTypes();
484 
485  /// Registers legacy attribute value types.
486  void _RegisterLegacyTypes();
487 
488  /// Returns a type registrar.
489  _ValueTypeRegistrar _GetTypeRegistrar() const;
490 
491  /// Factory function for creating a default value for a metadata
492  /// field. The parameters are the value type name and default
493  /// value (if any) specified in the defining plugin.
494  typedef std::function<VtValue(const std::string&, const JsValue&)>
496 
497  /// Registers all metadata fields specified in the given plugins
498  /// under the given metadata tag.
499  const std::vector<const SdfSchemaBase::FieldDefinition *>
500  _UpdateMetadataFromPlugins(const PlugPluginPtrVector& plugins,
501  const std::string& metadataTag =
502  std::string(),
503  const _DefaultValueFactoryFn& defFactory =
505 
506 private:
507  friend class _SpecDefiner;
508 
509  void _OnDidRegisterPlugins(const PlugNotice::DidRegisterPlugins& n);
510 
511  // Return a _SpecDefiner for an existing spec definition, \p local.
513  return _SpecDefiner(this, local);
514  }
515 
516  void _AddRequiredFieldName(const TfToken &name);
517 
518  const SpecDefinition* _CheckAndGetSpecDefinition(SdfSpecType type) const;
519 
521  FieldDefinition& _CreateField(
522  const TfToken &fieldKey, const VtValue &fallback, bool plugin = false);
523 
524  template <class T>
525  FieldDefinition& _DoRegisterField(const TfToken &fieldKey, const T &fallback)
526  {
527  return _DoRegisterField(fieldKey, VtValue(fallback));
528  }
529 
530  FieldDefinition& _DoRegisterField(
531  const TfToken &fieldKey, const VtValue &fallback);
532 
533 private:
536  _FieldDefinitionMap;
537  _FieldDefinitionMap _fieldDefinitions;
538 
539  // Pair of definition and flag indicating validity.
540  std::pair<SdfSchemaBase::SpecDefinition, bool>
541  _specDefinitions[SdfNumSpecTypes];
542 
543  std::unique_ptr<Sdf_ValueTypeRegistry> _valueTypeRegistry;
544  TfTokenVector _requiredFieldNames;
545 };
546 
547 /// \class SdfSchema
548 ///
549 /// Class that provides information about the various scene description
550 /// fields.
551 ///
552 class SdfSchema : public SdfSchemaBase {
553 public:
554  SDF_API
555  static const SdfSchema& GetInstance()
556  {
558  }
559 
560 private:
561  friend class TfSingleton<SdfSchema>;
562  SdfSchema();
563  virtual ~SdfSchema();
564 };
565 
567 
568 ///
569 /// The following fields are pre-registered by Sdf.
570 /// \showinitializer
571 #define SDF_FIELD_KEYS \
572  ((Active, "active")) \
573  ((AllowedTokens, "allowedTokens")) \
574  ((AssetInfo, "assetInfo")) \
575  ((ColorConfiguration, "colorConfiguration")) \
576  ((ColorManagementSystem, "colorManagementSystem")) \
577  ((ColorSpace, "colorSpace")) \
578  ((Comment, "comment")) \
579  ((ConnectionPaths, "connectionPaths")) \
580  ((Custom, "custom")) \
581  ((CustomData, "customData")) \
582  ((CustomLayerData, "customLayerData")) \
583  ((Default, "default")) \
584  ((DefaultPrim, "defaultPrim")) \
585  ((DisplayGroup, "displayGroup")) \
586  ((DisplayGroupOrder, "displayGroupOrder")) \
587  ((DisplayName, "displayName")) \
588  ((DisplayUnit, "displayUnit")) \
589  ((Documentation, "documentation")) \
590  ((EndTimeCode, "endTimeCode")) \
591  ((FramePrecision, "framePrecision")) \
592  ((FramesPerSecond, "framesPerSecond")) \
593  ((Hidden, "hidden")) \
594  ((HasOwnedSubLayers, "hasOwnedSubLayers")) \
595  ((InheritPaths, "inheritPaths")) \
596  ((Instanceable, "instanceable")) \
597  ((Kind, "kind")) \
598  ((PrimOrder, "primOrder")) \
599  ((NoLoadHint, "noLoadHint")) \
600  ((Owner, "owner")) \
601  ((Payload, "payload")) \
602  ((Permission, "permission")) \
603  ((Prefix, "prefix")) \
604  ((PrefixSubstitutions, "prefixSubstitutions")) \
605  ((PropertyOrder, "propertyOrder")) \
606  ((References, "references")) \
607  ((Relocates, "relocates")) \
608  ((SessionOwner, "sessionOwner")) \
609  ((Specializes, "specializes")) \
610  ((Specifier, "specifier")) \
611  ((StartTimeCode, "startTimeCode")) \
612  ((SubLayers, "subLayers")) \
613  ((SubLayerOffsets, "subLayerOffsets")) \
614  ((Suffix, "suffix")) \
615  ((SuffixSubstitutions, "suffixSubstitutions")) \
616  ((SymmetricPeer, "symmetricPeer")) \
617  ((SymmetryArgs, "symmetryArgs")) \
618  ((SymmetryArguments, "symmetryArguments")) \
619  ((SymmetryFunction, "symmetryFunction")) \
620  ((TargetPaths, "targetPaths")) \
621  ((TimeSamples, "timeSamples")) \
622  ((TimeCodesPerSecond, "timeCodesPerSecond")) \
623  ((TypeName, "typeName")) \
624  ((VariantSelection, "variantSelection")) \
625  ((Variability, "variability")) \
626  ((VariantSetNames, "variantSetNames")) \
627  \
628  /* XXX: These fields should move into Sd. See bug 123508. */ \
629  ((EndFrame, "endFrame")) \
630  ((StartFrame, "startFrame"))
631 
632 #define SDF_CHILDREN_KEYS \
633  ((ConnectionChildren, "connectionChildren")) \
634  ((ExpressionChildren, "expressionChildren")) \
635  ((MapperArgChildren, "mapperArgChildren")) \
636  ((MapperChildren, "mapperChildren")) \
637  ((PrimChildren, "primChildren")) \
638  ((PropertyChildren, "properties")) \
639  ((RelationshipTargetChildren, "targetChildren")) \
640  ((VariantChildren, "variantChildren")) \
641  ((VariantSetChildren, "variantSetChildren"))
642 
645 
647 
648 #endif // PXR_USD_SDF_SCHEMA_H
GLint ref
Definition: glcorearb.h:123
type
Definition: core.h:977
SDF_API const VtValue & GetFallback(const TfToken &fieldKey) const
static SdfAllowed IsValidNamespacedIdentifier(const std::string &name)
Type(const TfToken &name, const T &defaultValue)
Definition: schema.h:393
static T & GetInstance()
Definition: singleton.h:137
FieldDefinition & Children()
void _RegisterStandardFields()
Registers the standard fields.
void _RegisterPluginFields()
SDF_API SdfAllowed IsValidValue(const VtValue &value) const
FieldDefinition & ReadOnly()
FieldDefinition & _RegisterField(const TfToken &fieldKey, const T &fallback, bool plugin=false)
Definition: schema.h:457
GLint first
Definition: glcorearb.h:404
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
static SdfAllowed IsValidRelationshipTargetPath(const SdfPath &path)
static SdfAllowed IsValidSubLayer(const std::string &sublayer)
Type & CPPTypeName(const std::string &cppTypeName)
GLsizei const GLchar *const * path
Definition: glcorearb.h:3340
FieldDefinition & FallbackValue(const VtValue &v)
_SpecDefiner _Define(SdfSpecType type)
Definition: schema.h:465
SDF_API const VtValue & GetFallbackValue() const
Definition: enum.h:139
Functor to use for hash maps from tokens to other things.
Definition: token.h:166
SDF_API_TEMPLATE_CLASS(TfSingleton< SdfSchema >)
static SdfAllowed IsValidReference(const SdfReference &ref)
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:110
GLuint const GLchar * name
Definition: glcorearb.h:785
TfToken metadataDisplayGroup
Definition: schema.h:168
std::function< VtValue(const std::string &, const JsValue &)> _DefaultValueFactoryFn
Definition: schema.h:495
_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:183
SDF_API bool IsRequiredField(const TfToken &name) const
Returns whether the given field is required for this spec.
static SdfAllowed IsValidSpecializesPath(const SdfPath &path)
static SdfAllowed IsValidVariantIdentifier(const std::string &name)
SdfAllowed(*)(const SdfSchemaBase &, const VtValue &) Validator
Definition: schema.h:138
Type & Dimensions(const SdfTupleDimensions &dims)
friend class _SpecDefiner
Definition: schema.h:507
FieldDefinition & AddInfo(const TfToken &tok, const JsValue &val)
std::vector< std::pair< TfToken, JsValue > > InfoVec
Definition: schema.h:79
FieldDefinition & MapValueValidator(Validator v)
Type(char const *name, const T &defaultValue)
Definition: schema.h:397
Definition: token.h:87
SDF_API bool IsMetadataField(const TfToken &name) const
Returns whether the given field is metadata for this spec.
FieldDefinition & Plugin()
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
static SdfAllowed IsValidInheritPath(const SdfPath &path)
_ValueTypeRegistrar(Sdf_ValueTypeRegistry *)
SDF_API const TfTokenVector & GetRequiredFields(SdfSpecType specType) const
Returns all required fields registered for the given spec type.
Definition: value.h:61
_SpecDefiner & CopyFrom(const SpecDefinition &other)
const GLdouble * v
Definition: glcorearb.h:836
_SpecDefiner & Field(const TfToken &name, bool required=false)
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
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.
#define SDF_CHILDREN_KEYS
Definition: schema.h:632
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
Definition: types.h:166
Definition: path.h:288
static SdfAllowed IsValidAttributeConnectionPath(const SdfPath &path)
friend struct Sdf_SchemaFieldTypeRegistrar
Definition: schema.h:520
bool IsRequiredFieldName(const TfToken &fieldName) const
Definition: schema.h:278
static SdfAllowed IsValidRelocatesPath(const SdfPath &path)
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:555
GLdouble n
Definition: glcorearb.h:2007
A helper for registering value types.
Definition: schema.h:381
SDF_API const FieldDefinition * GetFieldDefinition(const TfToken &fieldKey) const
_ValueTypeRegistrar _GetTypeRegistrar() const
Returns a type registrar.
#define SDF_API
Definition: api.h:40
GLuint GLfloat * val
Definition: glcorearb.h:1607
SDF_API SdfValueTypeName FindOrCreateType(const TfToken &typeName) const
static SdfAllowed IsValidPayload(const SdfPayload &payload)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1375
static SdfAllowed IsValidIdentifier(const std::string &name)
SdfSpecType
Definition: types.h:91
#define SDF_FIELD_KEYS
Definition: schema.h:571
SdfAllowed IsValidListValue(const T &value) const
Definition: schema.h:102
Type & Role(const TfToken &role)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:91
SdfAllowed IsValidMapValue(const T &value) const
Definition: schema.h:118
SdfAllowed IsValidValue(const T &value) const
Definition: schema.h:94
void _RegisterStandardTypes()
Registers standard attribute value types.
GLsizei const GLfloat * value
Definition: glcorearb.h:823
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
SDF_API TfTokenVector GetFields(SdfSpecType specType) const
Returns all fields registered for the given spec type.
SDF_API const TfToken & GetName() const
SDF_API const InfoVec & GetInfo() const
SDF_API TfToken GetMetadataFieldDisplayGroup(SdfSpecType specType, TfToken const &metadataField) const
TF_DECLARE_PUBLIC_TOKENS(SdfFieldKeys, SDF_API, SDF_FIELD_KEYS)
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:227
std::vector< SdfValueTypeName > GetAllTypes() const
Returns all registered type names.
SDF_API TfTokenVector GetFields() const
Returns all fields for this spec.
Definition: value.h:168
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)
TF_DECLARE_WEAK_PTRS(PlugPlugin)
SDF_API bool IsReadOnly() const