24#ifndef PXR_USD_SDF_TYPES_H
25#define PXR_USD_SDF_TYPES_H
31#include "pxr/usd/sdf/api.h"
34#include "pxr/usd/sdf/listOp.h"
35#include "pxr/usd/sdf/opaqueValue.h"
36#include "pxr/usd/sdf/pathExpression.h"
38#include "pxr/usd/sdf/valueTypeName.h"
62#include "pxr/base/tf/preprocessorUtilsLite.h"
65#include "pxr/base/tf/type.h"
68#include "pxr/base/vt/value.h"
78PXR_NAMESPACE_OPEN_SCOPE
86 SdfSpecTypeUnknown = 0,
90 SdfSpecTypeConnection,
91 SdfSpecTypeExpression,
95 SdfSpecTypePseudoRoot,
96 SdfSpecTypeRelationship,
97 SdfSpecTypeRelationshipTarget,
99 SdfSpecTypeVariantSet,
128 return (spec != SdfSpecifierOver);
150 SdfPermissionPrivate,
173 SdfVariabilityVarying,
174 SdfVariabilityUniform,
195 SdfAuthoringErrorUnrecognizedFields,
196 SdfAuthoringErrorUnrecognizedSpecType
214#define _SDF_LENGTH_UNITS \
215((Millimeter, "mm", 0.001)) \
216((Centimeter, "cm", 0.01)) \
217((Decimeter, "dm", 0.1)) \
219((Kilometer, "km", 1000.0)) \
220((Inch, "in", 0.0254)) \
221((Foot, "ft", 0.3048)) \
222((Yard, "yd", 0.9144)) \
223((Mile, "mi", 1609.344))
225#define _SDF_ANGULAR_UNITS \
226((Degrees, "deg", 1.0)) \
227((Radians, "rad", 57.2957795130823208768))
229#define _SDF_DIMENSIONLESS_UNITS \
230((Percent, "%", 0.01)) \
231((Default, "default", 1.0))
234((Length, _SDF_LENGTH_UNITS), \
235(Angular, _SDF_ANGULAR_UNITS), \
236(Dimensionless, _SDF_DIMENSIONLESS_UNITS))
238#define _SDF_UNIT_TAG(tup) TF_PP_TUPLE_ELEM(0, tup)
239#define _SDF_UNIT_NAME(tup) TF_PP_TUPLE_ELEM(1, tup)
240#define _SDF_UNIT_SCALE(tup) TF_PP_TUPLE_ELEM(2, tup)
242#define _SDF_UNITSLIST_CATEGORY(tup) TF_PP_TUPLE_ELEM(0, tup)
243#define _SDF_UNITSLIST_TUPLES(tup) TF_PP_TUPLE_ELEM(1, tup)
244#define _SDF_UNITSLIST_ENUM(elem) TF_PP_CAT(TF_PP_CAT(Sdf, \
245 _SDF_UNITSLIST_CATEGORY(elem)), Unit)
247#define _SDF_DECLARE_UNIT_ENUMERANT(tag, elem) \
248 TF_PP_CAT(Sdf ## tag ## Unit, _SDF_UNIT_TAG(elem)),
250#define _SDF_DECLARE_UNIT_ENUM(elem) \
251enum _SDF_UNITSLIST_ENUM(elem) { \
252 TF_PP_SEQ_FOR_EACH(_SDF_DECLARE_UNIT_ENUMERANT, \
253 _SDF_UNITSLIST_CATEGORY(elem), \
254 _SDF_UNITSLIST_TUPLES(elem)) \
257#define _SDF_FOR_EACH_UNITS_IMPL(macro, ...) \
258 TF_PP_FOR_EACH(macro, __VA_ARGS__)
259#define _SDF_FOR_EACH_UNITS(macro, args) \
260 _SDF_FOR_EACH_UNITS_IMPL(macro, TF_PP_EAT_PARENS(args))
262_SDF_FOR_EACH_UNITS(_SDF_DECLARE_UNIT_ENUM, _SDF_UNITS)
335#define _SDF_SCALAR_VALUE_TYPES \
336 ((Bool, bool, bool, () )) \
337 ((UChar, uchar, unsigned char, () )) \
338 ((Int, int, int, () )) \
339 ((UInt, uint, unsigned int, () )) \
340 ((Int64, int64, int64_t, () )) \
341 ((UInt64, uint64, uint64_t, () )) \
342 ((Half, half, GfHalf, () )) \
343 ((Float, float, float, () )) \
344 ((Double, double, double, () )) \
345 ((TimeCode, timecode, SdfTimeCode, () )) \
346 ((String, string, std::string, () )) \
347 ((Token, token, TfToken, () )) \
348 ((Asset, asset, SdfAssetPath, () )) \
349 ((Opaque, opaque, SdfOpaqueValue, () )) \
350 ((PathExpression, pathExpression, SdfPathExpression, () ))
352#define _SDF_DIMENSIONED_VALUE_TYPES \
353 ((Matrix2d, matrix2d, GfMatrix2d, (2,2) )) \
354 ((Matrix3d, matrix3d, GfMatrix3d, (3,3) )) \
355 ((Matrix4d, matrix4d, GfMatrix4d, (4,4) )) \
356 ((Quath, quath, GfQuath, (4) )) \
357 ((Quatf, quatf, GfQuatf, (4) )) \
358 ((Quatd, quatd, GfQuatd, (4) )) \
359 ((Int2, int2, GfVec2i, (2) )) \
360 ((Half2, half2, GfVec2h, (2) )) \
361 ((Float2, float2, GfVec2f, (2) )) \
362 ((Double2, double2, GfVec2d, (2) )) \
363 ((Int3, int3, GfVec3i, (3) )) \
364 ((Half3, half3, GfVec3h, (3) )) \
365 ((Float3, float3, GfVec3f, (3) )) \
366 ((Double3, double3, GfVec3d, (3) )) \
367 ((Int4, int4, GfVec4i, (4) )) \
368 ((Half4, half4, GfVec4h, (4) )) \
369 ((Float4, float4, GfVec4f, (4) )) \
370 ((Double4, double4, GfVec4d, (4) ))
372#define SDF_VALUE_TYPES _SDF_SCALAR_VALUE_TYPES _SDF_DIMENSIONED_VALUE_TYPES
375#define SDF_VALUE_CPP_TYPE(tup) TF_PP_TUPLE_ELEM(2, tup)
376#define SDF_VALUE_CPP_ARRAY_TYPE(tup) VtArray<TF_PP_TUPLE_ELEM(2, tup)>
379struct SdfValueTypeTraits {
380 static const bool IsValueType =
false;
386struct SdfValueTypeTraits<char[N]> {
387 static const bool IsValueType =
true;
390#define SDF_DECLARE_VALUE_TYPE_TRAITS(unused, elem) \
392struct SdfValueTypeTraits<SDF_VALUE_CPP_TYPE(elem)> { \
393 static const bool IsValueType = true; \
396struct SdfValueTypeTraits<SDF_VALUE_CPP_ARRAY_TYPE(elem)> { \
397 static const bool IsValueType = true; \
400TF_PP_SEQ_FOR_EACH(SDF_DECLARE_VALUE_TYPE_TRAITS, ~, SDF_VALUE_TYPES);
427#define SDF_VALUE_ROLE_NAME_TOKENS \
452typedef std::map<std::string, SdfVariantSetSpecHandle>
453 SdfVariantSetSpecHandleMap;
523class Sdf_ValueTypeNamesType {
524 Sdf_ValueTypeNamesType(
const Sdf_ValueTypeNamesType&) =
delete;
525 Sdf_ValueTypeNamesType& operator=(
const Sdf_ValueTypeNamesType&) =
delete;
569 SDF_API ~Sdf_ValueTypeNamesType();
571 SDF_API
static const Sdf_ValueTypeNamesType* New();
580 friend const Sdf_ValueTypeNamesType* Sdf_InitializeValueTypeNames();
581 Sdf_ValueTypeNamesType();
584extern SDF_API
TfStaticData<
const Sdf_ValueTypeNamesType,
585 Sdf_ValueTypeNamesType::_Init> SdfValueTypeNames;
602 bool operator==(
const SdfValueBlock& block)
const {
return true; }
603 bool operator!=(
const SdfValueBlock& block)
const {
return false; }
606 friend inline size_t hash_value(
const SdfValueBlock &block) {
return 0; }
615struct SdfHumanReadableValue {
616 SdfHumanReadableValue() =
default;
617 explicit SdfHumanReadableValue(std::string
const &text) : _text(text) {}
619 bool operator==(SdfHumanReadableValue
const &other)
const {
620 return GetText() == other.GetText();
622 bool operator!=(SdfHumanReadableValue
const &other)
const {
623 return !(*
this == other);
626 std::string
const &GetText()
const {
return _text; }
632std::ostream &
operator<<(std::ostream &out,
const SdfHumanReadableValue &hrval);
635size_t hash_value(
const SdfHumanReadableValue &hrval);
637PXR_NAMESPACE_CLOSE_SCOPE
A subclass of SdfPropertySpec that holds typed data.
A scene description container that can combine with other such containers to form simple component as...
A path value used to locate objects in layers or scenegraphs.
Represents a prim description in an SdfLayer object.
Base class for SdfAttributeSpec and SdfRelationshipSpec.
A property that contains a reference to one or more SdfPrimSpec instances.
Base class for all Sdf spec classes.
Stores a representation of the value for an unregistered metadata field encountered during text layer...
const VtValue & GetValue() const
Returns the wrapped VtValue specified in the constructor.
SDF_API bool operator==(const SdfUnregisteredValue &other) const
Returns true if the wrapped VtValues are equal.
SDF_API SdfUnregisteredValue()
Wraps an empty VtValue.
SDF_API SdfUnregisteredValue(const SdfUnregisteredValueListOp &value)
Wraps a SdfUnregisteredValueListOp.
SDF_API bool operator!=(const SdfUnregisteredValue &other) const
Returns true if the wrapped VtValues are not equal.
friend size_t hash_value(const SdfUnregisteredValue &uv)
Hash.
SDF_API SdfUnregisteredValue(const VtDictionary &value)
Wraps a VtDictionary.
SDF_API SdfUnregisteredValue(const std::string &value)
Wraps a std::string.
Represents a value type name, i.e.
Represents a coherent set of alternate representations for part of a scene.
Represents a single variant in a variant set.
An enum class that records both enum type and enum value.
Create or return a previously created object instance of global data.
Token for efficient comparison, assignment, and hashing of known strings.
TfType represents a dynamic runtime type.
A map with string keys and VtValue values.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
VT_API size_t GetHash() const
Return a hash code for the held object by calling VtHashValue() on it.
Demangle C++ typenames generated by the typeid() facility.
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
This header serves to simply bring in the half float datatype and provide a hash_value function.
size_t hash_value(const half h)
Overload hash_value for half.
This file defines some macros that are useful for declaring and using static TfTokens.
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
A special value type that can be used to explicitly author an opinion for an attribute's default valu...
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
SDF_API TfType SdfGetTypeForValueTypeName(TfToken const &name)
Given an sdf valueType name, produce TfType if the type name specifies a valid sdf value type.
SdfAuthoringError
An enum for TfError codes related to authoring operations.
SdfSpecType
An enum that specifies the type of an object.
SDF_API bool SdfValueHasValidType(VtValue const &value)
Given a value, returns if there is a valid corresponding valueType.
SdfSpecifier
An enum that identifies the possible specifiers for an SdfPrimSpec.
std::map< std::string, VtValue > SdfMapperParametersMap
A map of mapper parameter names to parameter values.
SDF_API const std::string & SdfUnitCategory(const TfEnum &unit)
Gets the unit category for a given /a unit.
SDF_API TfToken SdfGetRoleNameForValueTypeName(TfToken const &typeName)
Return role name for typeName.
std::pair< SdfPath, SdfPath > SdfRelocate
A single relocate specifying a source SdfPath and a target SdfPath for a relocation.
std::map< std::string, std::vector< std::string > > SdfVariantsMap
A map of variant set names to list of variants in those sets.
SDF_API double SdfConvertUnit(const TfEnum &fromUnit, const TfEnum &toUnit)
Converts from one unit of measure to another.
SdfVariability
An enum that identifies variability types for attributes.
SDF_API TfEnum SdfDefaultUnit(TfToken const &typeName)
Gets the show default unit for the given /a typeName.
std::map< std::string, std::string > SdfVariantSelectionMap
A map of reference variant set names to variants in those sets.
SDF_API SdfValueTypeName SdfGetValueTypeNameForValue(VtValue const &value)
Given a value, produce the sdf valueType name.
std::vector< SdfRelocate > SdfRelocates
A vector of relocation source path to target path pairs.
SDF_API const std::string & SdfGetNameForUnit(const TfEnum &unit)
Gets the name for a given /a unit.
SdfPermission
An enum that defines permission levels.
bool SdfIsDefiningSpecifier(SdfSpecifier spec)
Returns true if the specifier defines a prim.
SDF_API bool SdfConvertToValidMetadataDictionary(VtDictionary *dict, std::string *errMsg)
Convert dict to a valid metadata dictionary for scene description.
SDF_API const TfEnum & SdfGetUnitFromName(const std::string &name)
Gets a unit for the given /a name.
std::map< SdfPath, SdfPath > SdfRelocatesMap
A map of source SdfPaths to target SdfPaths for relocation.
std::map< double, VtValue > SdfTimeSampleMap
A map from sample times to sample values.