7#ifndef PXR_USD_SDF_TYPES_H
8#define PXR_USD_SDF_TYPES_H
14#include "pxr/usd/sdf/api.h"
17#include "pxr/usd/sdf/listOp.h"
18#include "pxr/usd/sdf/opaqueValue.h"
19#include "pxr/usd/sdf/pathExpression.h"
21#include "pxr/usd/sdf/valueTypeName.h"
46#include "pxr/base/tf/preprocessorUtilsLite.h"
49#include "pxr/base/tf/type.h"
54#include "pxr/base/vt/value.h"
55#include "pxr/base/vt/valueTransform.h"
65PXR_NAMESPACE_OPEN_SCOPE
73 SdfSpecTypeUnknown = 0,
77 SdfSpecTypeConnection,
78 SdfSpecTypeExpression,
82 SdfSpecTypePseudoRoot,
83 SdfSpecTypeRelationship,
84 SdfSpecTypeRelationshipTarget,
86 SdfSpecTypeVariantSet,
115 return (spec != SdfSpecifierOver);
137 SdfPermissionPrivate,
160 SdfVariabilityVarying,
161 SdfVariabilityUniform,
182 SdfAuthoringErrorUnrecognizedFields,
183 SdfAuthoringErrorUnrecognizedSpecType
201#define _SDF_LENGTH_UNITS \
202((Millimeter, "mm", 0.001)) \
203((Centimeter, "cm", 0.01)) \
204((Decimeter, "dm", 0.1)) \
206((Kilometer, "km", 1000.0)) \
207((Inch, "in", 0.0254)) \
208((Foot, "ft", 0.3048)) \
209((Yard, "yd", 0.9144)) \
210((Mile, "mi", 1609.344))
212#define _SDF_ANGULAR_UNITS \
213((Degrees, "deg", 1.0)) \
214((Radians, "rad", 57.2957795130823208768))
216#define _SDF_DIMENSIONLESS_UNITS \
217((Percent, "%", 0.01)) \
218((Default, "default", 1.0))
221((Length, _SDF_LENGTH_UNITS), \
222(Angular, _SDF_ANGULAR_UNITS), \
223(Dimensionless, _SDF_DIMENSIONLESS_UNITS))
225#define _SDF_UNIT_TAG(tup) TF_PP_TUPLE_ELEM(0, tup)
226#define _SDF_UNIT_NAME(tup) TF_PP_TUPLE_ELEM(1, tup)
227#define _SDF_UNIT_SCALE(tup) TF_PP_TUPLE_ELEM(2, tup)
229#define _SDF_UNITSLIST_CATEGORY(tup) TF_PP_TUPLE_ELEM(0, tup)
230#define _SDF_UNITSLIST_TUPLES(tup) TF_PP_TUPLE_ELEM(1, tup)
231#define _SDF_UNITSLIST_ENUM(elem) TF_PP_CAT(TF_PP_CAT(Sdf, \
232 _SDF_UNITSLIST_CATEGORY(elem)), Unit)
234#define _SDF_DECLARE_UNIT_ENUMERANT(tag, elem) \
235 TF_PP_CAT(Sdf ## tag ## Unit, _SDF_UNIT_TAG(elem)),
237#define _SDF_DECLARE_UNIT_ENUM(elem) \
238enum _SDF_UNITSLIST_ENUM(elem) { \
239 TF_PP_SEQ_FOR_EACH(_SDF_DECLARE_UNIT_ENUMERANT, \
240 _SDF_UNITSLIST_CATEGORY(elem), \
241 _SDF_UNITSLIST_TUPLES(elem)) \
244#define _SDF_FOR_EACH_UNITS_IMPL(macro, ...) \
245 TF_PP_FOR_EACH(macro, __VA_ARGS__)
246#define _SDF_FOR_EACH_UNITS(macro, args) \
247 _SDF_FOR_EACH_UNITS_IMPL(macro, TF_PP_EAT_PARENS(args))
253ARCH_PRAGMA_MACRO_TOO_FEW_ARGUMENTS
254_SDF_FOR_EACH_UNITS(_SDF_DECLARE_UNIT_ENUM, _SDF_UNITS)
329#define _SDF_SCALAR_VALUE_TYPES \
330 ((Bool, bool, bool, () )) \
331 ((UChar, uchar, unsigned char, () )) \
332 ((Int, int, int, () )) \
333 ((UInt, uint, unsigned int, () )) \
334 ((Int64, int64, int64_t, () )) \
335 ((UInt64, uint64, uint64_t, () )) \
336 ((Half, half, GfHalf, () )) \
337 ((Float, float, float, () )) \
338 ((Double, double, double, () )) \
339 ((TimeCode, timecode, SdfTimeCode, () )) \
340 ((String, string, std::string, () )) \
341 ((Token, token, TfToken, () )) \
342 ((Asset, asset, SdfAssetPath, () )) \
343 ((Opaque, opaque, SdfOpaqueValue, () )) \
344 ((PathExpression, pathExpression, SdfPathExpression, () ))
346#define _SDF_DIMENSIONED_VALUE_TYPES \
347 ((Matrix2d, matrix2d, GfMatrix2d, (2,2) )) \
348 ((Matrix3d, matrix3d, GfMatrix3d, (3,3) )) \
349 ((Matrix4d, matrix4d, GfMatrix4d, (4,4) )) \
350 ((Quath, quath, GfQuath, (4) )) \
351 ((Quatf, quatf, GfQuatf, (4) )) \
352 ((Quatd, quatd, GfQuatd, (4) )) \
353 ((Int2, int2, GfVec2i, (2) )) \
354 ((Half2, half2, GfVec2h, (2) )) \
355 ((Float2, float2, GfVec2f, (2) )) \
356 ((Double2, double2, GfVec2d, (2) )) \
357 ((Int3, int3, GfVec3i, (3) )) \
358 ((Half3, half3, GfVec3h, (3) )) \
359 ((Float3, float3, GfVec3f, (3) )) \
360 ((Double3, double3, GfVec3d, (3) )) \
361 ((Int4, int4, GfVec4i, (4) )) \
362 ((Half4, half4, GfVec4h, (4) )) \
363 ((Float4, float4, GfVec4f, (4) )) \
364 ((Double4, double4, GfVec4d, (4) ))
366#define SDF_VALUE_TYPES _SDF_SCALAR_VALUE_TYPES _SDF_DIMENSIONED_VALUE_TYPES
369#define SDF_VALUE_CPP_TYPE(tup) TF_PP_TUPLE_ELEM(2, tup)
370#define SDF_VALUE_CPP_ARRAY_TYPE(tup) VtArray<TF_PP_TUPLE_ELEM(2, tup)>
371#define SDF_VALUE_CPP_ARRAY_EDIT_TYPE(tup) VtArrayEdit<TF_PP_TUPLE_ELEM(2, tup)>
374struct SdfValueTypeTraits {
375 static const bool IsValueType =
false;
381struct SdfValueTypeTraits<char[N]> {
382 static const bool IsValueType =
true;
385#define SDF_DECLARE_VALUE_TYPE_TRAITS(unused, elem) \
387struct SdfValueTypeTraits<SDF_VALUE_CPP_TYPE(elem)> { \
388 static const bool IsValueType = true; \
391struct SdfValueTypeTraits<SDF_VALUE_CPP_ARRAY_TYPE(elem)> { \
392 static const bool IsValueType = true; \
395struct SdfValueTypeTraits<SDF_VALUE_CPP_ARRAY_EDIT_TYPE(elem)> { \
396 static const bool IsValueType = true; \
399TF_PP_SEQ_FOR_EACH(SDF_DECLARE_VALUE_TYPE_TRAITS, ~, SDF_VALUE_TYPES);
426#define SDF_VALUE_ROLE_NAME_TOKENS \
451typedef std::map<std::string, SdfVariantSetSpecHandle>
452 SdfVariantSetSpecHandleMap;
522class Sdf_ValueTypeNamesType {
523 Sdf_ValueTypeNamesType(
const Sdf_ValueTypeNamesType&) =
delete;
524 Sdf_ValueTypeNamesType& operator=(
const Sdf_ValueTypeNamesType&) =
delete;
568 SDF_API ~Sdf_ValueTypeNamesType();
570 SDF_API
static const Sdf_ValueTypeNamesType* New();
579 friend const Sdf_ValueTypeNamesType* Sdf_InitializeValueTypeNames();
580 Sdf_ValueTypeNamesType();
583extern SDF_API
TfStaticData<
const Sdf_ValueTypeNamesType,
584 Sdf_ValueTypeNamesType::_Init> SdfValueTypeNames;
601 bool operator==(
const SdfValueBlock& block)
const {
return true; }
602 bool operator!=(
const SdfValueBlock& block)
const {
return false; }
605 friend inline size_t hash_value(
const SdfValueBlock &block) {
return 0; }
629struct SdfHumanReadableValue {
630 SdfHumanReadableValue() =
default;
631 explicit SdfHumanReadableValue(std::string
const &text) : _text(text) {}
633 bool operator==(SdfHumanReadableValue
const &other)
const {
634 return GetText() == other.GetText();
636 bool operator!=(SdfHumanReadableValue
const &other)
const {
637 return !(*
this == other);
640 std::string
const &GetText()
const {
return _text; }
646std::ostream &
operator<<(std::ostream &out,
const SdfHumanReadableValue &hrval);
649size_t hash_value(
const SdfHumanReadableValue &hrval);
651PXR_NAMESPACE_CLOSE_SCOPE
#define VT_VALUE_TYPE_CAN_TRANSFORM(T)
A helper for specializing the above trait.
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.
std::size_t hash_value(const half h)
Overload hash_value for half.
Pragmas for controlling compiler-specific behaviors.
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...
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.
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.
ARCH_PRAGMA_PUSH ARCH_PRAGMA_MACRO_TOO_FEW_ARGUMENTS ARCH_PRAGMA_POP typedef std::map< std::string, VtValue > SdfMapperParametersMap
A map of mapper parameter names to parameter values.
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.