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"
70#include <boost/preprocessor/list/for_each.hpp>
71#include <boost/preprocessor/list/size.hpp>
72#include <boost/preprocessor/selection/max.hpp>
73#include <boost/preprocessor/seq/for_each.hpp>
74#include <boost/preprocessor/seq/seq.hpp>
75#include <boost/preprocessor/tuple/elem.hpp>
84PXR_NAMESPACE_OPEN_SCOPE
92 SdfSpecTypeUnknown = 0,
96 SdfSpecTypeConnection,
97 SdfSpecTypeExpression,
101 SdfSpecTypePseudoRoot,
102 SdfSpecTypeRelationship,
103 SdfSpecTypeRelationshipTarget,
105 SdfSpecTypeVariantSet,
134 return (spec != SdfSpecifierOver);
156 SdfPermissionPrivate,
179 SdfVariabilityVarying,
180 SdfVariabilityUniform,
201 SdfAuthoringErrorUnrecognizedFields,
202 SdfAuthoringErrorUnrecognizedSpecType
220#define _SDF_LENGTH_UNITS \
221((Millimeter, "mm", 0.001)) \
222((Centimeter, "cm", 0.01)) \
223((Decimeter, "dm", 0.1)) \
225((Kilometer, "km", 1000.0)) \
226((Inch, "in", 0.0254)) \
227((Foot, "ft", 0.3048)) \
228((Yard, "yd", 0.9144)) \
229((Mile, "mi", 1609.344))
231#define _SDF_ANGULAR_UNITS \
232((Degrees, "deg", 1.0)) \
233((Radians, "rad", 57.2957795130823208768))
235#define _SDF_DIMENSIONLESS_UNITS \
236((Percent, "%", 0.01)) \
237((Default, "default", 1.0))
240((Length, _SDF_LENGTH_UNITS), \
241((Angular, _SDF_ANGULAR_UNITS), \
242((Dimensionless, _SDF_DIMENSIONLESS_UNITS), \
245#define _SDF_UNIT_TAG(tup) BOOST_PP_TUPLE_ELEM(3, 0, tup)
246#define _SDF_UNIT_NAME(tup) BOOST_PP_TUPLE_ELEM(3, 1, tup)
247#define _SDF_UNIT_SCALE(tup) BOOST_PP_TUPLE_ELEM(3, 2, tup)
249#define _SDF_UNITSLIST_CATEGORY(tup) BOOST_PP_TUPLE_ELEM(2, 0, tup)
250#define _SDF_UNITSLIST_TUPLES(tup) BOOST_PP_TUPLE_ELEM(2, 1, tup)
251#define _SDF_UNITSLIST_ENUM(elem) TF_PP_CAT(TF_PP_CAT(Sdf, \
252 _SDF_UNITSLIST_CATEGORY(elem)), Unit)
254#define _SDF_DECLARE_UNIT_ENUMERANT(r, tag, elem) \
255 TF_PP_CAT(Sdf ## tag ## Unit, _SDF_UNIT_TAG(elem)),
257#define _SDF_DECLARE_UNIT_ENUM(r, unused, elem) \
258enum _SDF_UNITSLIST_ENUM(elem) { \
259 BOOST_PP_SEQ_FOR_EACH(_SDF_DECLARE_UNIT_ENUMERANT, \
260 _SDF_UNITSLIST_CATEGORY(elem), \
261 _SDF_UNITSLIST_TUPLES(elem)) \
263BOOST_PP_LIST_FOR_EACH(_SDF_DECLARE_UNIT_ENUM, ~, _SDF_UNITS)
266#define _SDF_MAX_UNITS_OP(d, state, list) \
267 BOOST_PP_MAX_D(d, state, BOOST_PP_SEQ_SIZE(_SDF_UNITSLIST_TUPLES(list)))
268#define _SDF_UNIT_MAX_UNITS \
269 BOOST_PP_LIST_FOLD_LEFT(_SDF_MAX_UNITS_OP, 0, _SDF_UNITS)
272#define _SDF_UNIT_NUM_TYPES BOOST_PP_LIST_SIZE(_SDF_UNITS)
276#define _SDF_UNIT_MAX_UNITS_BITS TF_BITS_FOR_VALUES(_SDF_UNIT_MAX_UNITS)
277#define _SDF_UNIT_TYPES_BITS TF_BITS_FOR_VALUES(_SDF_UNIT_NUM_TYPES)
343#define _SDF_SCALAR_VALUE_TYPES \
344 ((Bool, bool, bool, () )) \
345 ((UChar, uchar, unsigned char, () )) \
346 ((Int, int, int, () )) \
347 ((UInt, uint, unsigned int, () )) \
348 ((Int64, int64, int64_t, () )) \
349 ((UInt64, uint64, uint64_t, () )) \
350 ((Half, half, GfHalf, () )) \
351 ((Float, float, float, () )) \
352 ((Double, double, double, () )) \
353 ((TimeCode, timecode, SdfTimeCode, () )) \
354 ((String, string, std::string, () )) \
355 ((Token, token, TfToken, () )) \
356 ((Asset, asset, SdfAssetPath, () )) \
357 ((Opaque, opaque, SdfOpaqueValue, () )) \
358 ((PathExpression, pathExpression, SdfPathExpression, () ))
360#define _SDF_DIMENSIONED_VALUE_TYPES \
361 ((Matrix2d, matrix2d, GfMatrix2d, (2,2) )) \
362 ((Matrix3d, matrix3d, GfMatrix3d, (3,3) )) \
363 ((Matrix4d, matrix4d, GfMatrix4d, (4,4) )) \
364 ((Quath, quath, GfQuath, (4) )) \
365 ((Quatf, quatf, GfQuatf, (4) )) \
366 ((Quatd, quatd, GfQuatd, (4) )) \
367 ((Int2, int2, GfVec2i, (2) )) \
368 ((Half2, half2, GfVec2h, (2) )) \
369 ((Float2, float2, GfVec2f, (2) )) \
370 ((Double2, double2, GfVec2d, (2) )) \
371 ((Int3, int3, GfVec3i, (3) )) \
372 ((Half3, half3, GfVec3h, (3) )) \
373 ((Float3, float3, GfVec3f, (3) )) \
374 ((Double3, double3, GfVec3d, (3) )) \
375 ((Int4, int4, GfVec4i, (4) )) \
376 ((Half4, half4, GfVec4h, (4) )) \
377 ((Float4, float4, GfVec4f, (4) )) \
378 ((Double4, double4, GfVec4d, (4) ))
380#define SDF_VALUE_TYPES _SDF_SCALAR_VALUE_TYPES _SDF_DIMENSIONED_VALUE_TYPES
383#define SDF_VALUE_CPP_TYPE(tup) BOOST_PP_TUPLE_ELEM(4, 2, tup)
384#define SDF_VALUE_CPP_ARRAY_TYPE(tup) VtArray<BOOST_PP_TUPLE_ELEM(4, 2, tup)>
387struct SdfValueTypeTraits {
388 static const bool IsValueType =
false;
394struct SdfValueTypeTraits<char[N]> {
395 static const bool IsValueType =
true;
398#define SDF_DECLARE_VALUE_TYPE_TRAITS(r, unused, elem) \
400struct SdfValueTypeTraits<SDF_VALUE_CPP_TYPE(elem)> { \
401 static const bool IsValueType = true; \
404struct SdfValueTypeTraits<SDF_VALUE_CPP_ARRAY_TYPE(elem)> { \
405 static const bool IsValueType = true; \
408BOOST_PP_SEQ_FOR_EACH(SDF_DECLARE_VALUE_TYPE_TRAITS, ~, SDF_VALUE_TYPES);
435#define SDF_VALUE_ROLE_NAME_TOKENS \
460typedef std::map<std::string, SdfVariantSetSpecHandle>
461 SdfVariantSetSpecHandleMap;
526class Sdf_ValueTypeNamesType {
527 Sdf_ValueTypeNamesType(
const Sdf_ValueTypeNamesType&) =
delete;
528 Sdf_ValueTypeNamesType& operator=(
const Sdf_ValueTypeNamesType&) =
delete;
572 SDF_API ~Sdf_ValueTypeNamesType();
574 SDF_API
static const Sdf_ValueTypeNamesType* New();
583 friend const Sdf_ValueTypeNamesType* Sdf_InitializeValueTypeNames();
584 Sdf_ValueTypeNamesType();
587extern SDF_API
TfStaticData<
const Sdf_ValueTypeNamesType,
588 Sdf_ValueTypeNamesType::_Init> SdfValueTypeNames;
605 bool operator==(
const SdfValueBlock& block)
const {
return true; }
606 bool operator!=(
const SdfValueBlock& block)
const {
return false; }
609 friend inline size_t hash_value(
const SdfValueBlock &block) {
return 0; }
618struct SdfHumanReadableValue {
619 SdfHumanReadableValue() =
default;
620 explicit SdfHumanReadableValue(std::string
const &text) : _text(text) {}
622 bool operator==(SdfHumanReadableValue
const &other)
const {
623 return GetText() == other.GetText();
625 bool operator!=(SdfHumanReadableValue
const &other)
const {
626 return !(*
this == other);
629 std::string
const &GetText()
const {
return _text; }
635std::ostream &
operator<<(std::ostream &out,
const SdfHumanReadableValue &hrval);
638size_t hash_value(
const SdfHumanReadableValue &hrval);
640PXR_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::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.
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.