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"
52#include "pxr/base/vt/value.h"
62PXR_NAMESPACE_OPEN_SCOPE
70 SdfSpecTypeUnknown = 0,
74 SdfSpecTypeConnection,
75 SdfSpecTypeExpression,
79 SdfSpecTypePseudoRoot,
80 SdfSpecTypeRelationship,
81 SdfSpecTypeRelationshipTarget,
83 SdfSpecTypeVariantSet,
112 return (spec != SdfSpecifierOver);
134 SdfPermissionPrivate,
157 SdfVariabilityVarying,
158 SdfVariabilityUniform,
179 SdfAuthoringErrorUnrecognizedFields,
180 SdfAuthoringErrorUnrecognizedSpecType
198#define _SDF_LENGTH_UNITS \
199((Millimeter, "mm", 0.001)) \
200((Centimeter, "cm", 0.01)) \
201((Decimeter, "dm", 0.1)) \
203((Kilometer, "km", 1000.0)) \
204((Inch, "in", 0.0254)) \
205((Foot, "ft", 0.3048)) \
206((Yard, "yd", 0.9144)) \
207((Mile, "mi", 1609.344))
209#define _SDF_ANGULAR_UNITS \
210((Degrees, "deg", 1.0)) \
211((Radians, "rad", 57.2957795130823208768))
213#define _SDF_DIMENSIONLESS_UNITS \
214((Percent, "%", 0.01)) \
215((Default, "default", 1.0))
218((Length, _SDF_LENGTH_UNITS), \
219(Angular, _SDF_ANGULAR_UNITS), \
220(Dimensionless, _SDF_DIMENSIONLESS_UNITS))
222#define _SDF_UNIT_TAG(tup) TF_PP_TUPLE_ELEM(0, tup)
223#define _SDF_UNIT_NAME(tup) TF_PP_TUPLE_ELEM(1, tup)
224#define _SDF_UNIT_SCALE(tup) TF_PP_TUPLE_ELEM(2, tup)
226#define _SDF_UNITSLIST_CATEGORY(tup) TF_PP_TUPLE_ELEM(0, tup)
227#define _SDF_UNITSLIST_TUPLES(tup) TF_PP_TUPLE_ELEM(1, tup)
228#define _SDF_UNITSLIST_ENUM(elem) TF_PP_CAT(TF_PP_CAT(Sdf, \
229 _SDF_UNITSLIST_CATEGORY(elem)), Unit)
231#define _SDF_DECLARE_UNIT_ENUMERANT(tag, elem) \
232 TF_PP_CAT(Sdf ## tag ## Unit, _SDF_UNIT_TAG(elem)),
234#define _SDF_DECLARE_UNIT_ENUM(elem) \
235enum _SDF_UNITSLIST_ENUM(elem) { \
236 TF_PP_SEQ_FOR_EACH(_SDF_DECLARE_UNIT_ENUMERANT, \
237 _SDF_UNITSLIST_CATEGORY(elem), \
238 _SDF_UNITSLIST_TUPLES(elem)) \
241#define _SDF_FOR_EACH_UNITS_IMPL(macro, ...) \
242 TF_PP_FOR_EACH(macro, __VA_ARGS__)
243#define _SDF_FOR_EACH_UNITS(macro, args) \
244 _SDF_FOR_EACH_UNITS_IMPL(macro, TF_PP_EAT_PARENS(args))
250ARCH_PRAGMA_MACRO_TOO_FEW_ARGUMENTS
251_SDF_FOR_EACH_UNITS(_SDF_DECLARE_UNIT_ENUM, _SDF_UNITS)
325#define _SDF_SCALAR_VALUE_TYPES \
326 ((Bool, bool, bool, () )) \
327 ((UChar, uchar, unsigned char, () )) \
328 ((Int, int, int, () )) \
329 ((UInt, uint, unsigned int, () )) \
330 ((Int64, int64, int64_t, () )) \
331 ((UInt64, uint64, uint64_t, () )) \
332 ((Half, half, GfHalf, () )) \
333 ((Float, float, float, () )) \
334 ((Double, double, double, () )) \
335 ((TimeCode, timecode, SdfTimeCode, () )) \
336 ((String, string, std::string, () )) \
337 ((Token, token, TfToken, () )) \
338 ((Asset, asset, SdfAssetPath, () )) \
339 ((Opaque, opaque, SdfOpaqueValue, () )) \
340 ((PathExpression, pathExpression, SdfPathExpression, () ))
342#define _SDF_DIMENSIONED_VALUE_TYPES \
343 ((Matrix2d, matrix2d, GfMatrix2d, (2,2) )) \
344 ((Matrix3d, matrix3d, GfMatrix3d, (3,3) )) \
345 ((Matrix4d, matrix4d, GfMatrix4d, (4,4) )) \
346 ((Quath, quath, GfQuath, (4) )) \
347 ((Quatf, quatf, GfQuatf, (4) )) \
348 ((Quatd, quatd, GfQuatd, (4) )) \
349 ((Int2, int2, GfVec2i, (2) )) \
350 ((Half2, half2, GfVec2h, (2) )) \
351 ((Float2, float2, GfVec2f, (2) )) \
352 ((Double2, double2, GfVec2d, (2) )) \
353 ((Int3, int3, GfVec3i, (3) )) \
354 ((Half3, half3, GfVec3h, (3) )) \
355 ((Float3, float3, GfVec3f, (3) )) \
356 ((Double3, double3, GfVec3d, (3) )) \
357 ((Int4, int4, GfVec4i, (4) )) \
358 ((Half4, half4, GfVec4h, (4) )) \
359 ((Float4, float4, GfVec4f, (4) )) \
360 ((Double4, double4, GfVec4d, (4) ))
362#define SDF_VALUE_TYPES _SDF_SCALAR_VALUE_TYPES _SDF_DIMENSIONED_VALUE_TYPES
365#define SDF_VALUE_CPP_TYPE(tup) TF_PP_TUPLE_ELEM(2, tup)
366#define SDF_VALUE_CPP_ARRAY_TYPE(tup) VtArray<TF_PP_TUPLE_ELEM(2, tup)>
369struct SdfValueTypeTraits {
370 static const bool IsValueType =
false;
376struct SdfValueTypeTraits<char[N]> {
377 static const bool IsValueType =
true;
380#define SDF_DECLARE_VALUE_TYPE_TRAITS(unused, elem) \
382struct SdfValueTypeTraits<SDF_VALUE_CPP_TYPE(elem)> { \
383 static const bool IsValueType = true; \
386struct SdfValueTypeTraits<SDF_VALUE_CPP_ARRAY_TYPE(elem)> { \
387 static const bool IsValueType = true; \
390TF_PP_SEQ_FOR_EACH(SDF_DECLARE_VALUE_TYPE_TRAITS, ~, SDF_VALUE_TYPES);
417#define SDF_VALUE_ROLE_NAME_TOKENS \
442typedef std::map<std::string, SdfVariantSetSpecHandle>
443 SdfVariantSetSpecHandleMap;
513class Sdf_ValueTypeNamesType {
514 Sdf_ValueTypeNamesType(
const Sdf_ValueTypeNamesType&) =
delete;
515 Sdf_ValueTypeNamesType& operator=(
const Sdf_ValueTypeNamesType&) =
delete;
559 SDF_API ~Sdf_ValueTypeNamesType();
561 SDF_API
static const Sdf_ValueTypeNamesType* New();
570 friend const Sdf_ValueTypeNamesType* Sdf_InitializeValueTypeNames();
571 Sdf_ValueTypeNamesType();
574extern SDF_API
TfStaticData<
const Sdf_ValueTypeNamesType,
575 Sdf_ValueTypeNamesType::_Init> SdfValueTypeNames;
592 bool operator==(
const SdfValueBlock& block)
const {
return true; }
593 bool operator!=(
const SdfValueBlock& block)
const {
return false; }
596 friend inline size_t hash_value(
const SdfValueBlock &block) {
return 0; }
605struct SdfHumanReadableValue {
606 SdfHumanReadableValue() =
default;
607 explicit SdfHumanReadableValue(std::string
const &text) : _text(text) {}
609 bool operator==(SdfHumanReadableValue
const &other)
const {
610 return GetText() == other.GetText();
612 bool operator!=(SdfHumanReadableValue
const &other)
const {
613 return !(*
this == other);
616 std::string
const &GetText()
const {
return _text; }
622std::ostream &
operator<<(std::ostream &out,
const SdfHumanReadableValue &hrval);
625size_t hash_value(
const SdfHumanReadableValue &hrval);
627PXR_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.
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...
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.