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" 37 #include "pxr/usd/sdf/valueTypeName.h" 64 #include "pxr/base/tf/type.h" 67 #include "pxr/base/vt/value.h" 69 #include <boost/noncopyable.hpp> 70 #include <boost/preprocessor/list/for_each.hpp> 71 #include <boost/preprocessor/list/size.hpp> 72 #include <boost/preprocessor/punctuation/comma.hpp> 73 #include <boost/preprocessor/selection/max.hpp> 74 #include <boost/preprocessor/seq/for_each.hpp> 75 #include <boost/preprocessor/seq/seq.hpp> 76 #include <boost/preprocessor/tuple/elem.hpp> 85 PXR_NAMESPACE_OPEN_SCOPE
93 SdfSpecTypeUnknown = 0,
97 SdfSpecTypeConnection,
98 SdfSpecTypeExpression,
100 SdfSpecTypeMapperArg,
102 SdfSpecTypePseudoRoot,
103 SdfSpecTypeRelationship,
104 SdfSpecTypeRelationshipTarget,
106 SdfSpecTypeVariantSet,
135 return (spec != SdfSpecifierOver);
157 SdfPermissionPrivate,
180 SdfVariabilityVarying,
181 SdfVariabilityUniform,
202 SdfAuthoringErrorUnrecognizedFields,
203 SdfAuthoringErrorUnrecognizedSpecType
221 #define _SDF_LENGTH_UNITS \ 222 ((Millimeter, "mm", 0.001)) \ 223 ((Centimeter, "cm", 0.01)) \ 224 ((Decimeter, "dm", 0.1)) \ 225 ((Meter, "m", 1.0)) \ 226 ((Kilometer, "km", 1000.0)) \ 227 ((Inch, "in", 0.0254)) \ 228 ((Foot, "ft", 0.3048)) \ 229 ((Yard, "yd", 0.9144)) \ 230 ((Mile, "mi", 1609.344)) 232 #define _SDF_ANGULAR_UNITS \ 233 ((Degrees, "deg", 1.0)) \ 234 ((Radians, "rad", 57.2957795130823208768)) 236 #define _SDF_DIMENSIONLESS_UNITS \ 237 ((Percent, "%", 0.01)) \ 238 ((Default, "default", 1.0)) 241 ((Length, _SDF_LENGTH_UNITS), \ 242 ((Angular, _SDF_ANGULAR_UNITS), \ 243 ((Dimensionless, _SDF_DIMENSIONLESS_UNITS), \ 246 #define _SDF_UNIT_TAG(tup) BOOST_PP_TUPLE_ELEM(3, 0, tup) 247 #define _SDF_UNIT_NAME(tup) BOOST_PP_TUPLE_ELEM(3, 1, tup) 248 #define _SDF_UNIT_SCALE(tup) BOOST_PP_TUPLE_ELEM(3, 2, tup) 250 #define _SDF_UNITSLIST_CATEGORY(tup) BOOST_PP_TUPLE_ELEM(2, 0, tup) 251 #define _SDF_UNITSLIST_TUPLES(tup) BOOST_PP_TUPLE_ELEM(2, 1, tup) 252 #define _SDF_UNITSLIST_ENUM(elem) BOOST_PP_CAT(BOOST_PP_CAT(Sdf, \ 253 _SDF_UNITSLIST_CATEGORY(elem)), Unit) 255 #define _SDF_DECLARE_UNIT_ENUMERANT(r, tag, elem) \ 256 BOOST_PP_CAT(Sdf ## tag ## Unit, _SDF_UNIT_TAG(elem)), 258 #define _SDF_DECLARE_UNIT_ENUM(r, unused, elem) \ 259 enum _SDF_UNITSLIST_ENUM(elem) { \ 260 BOOST_PP_SEQ_FOR_EACH(_SDF_DECLARE_UNIT_ENUMERANT, \ 261 _SDF_UNITSLIST_CATEGORY(elem), \ 262 _SDF_UNITSLIST_TUPLES(elem)) \ 264 BOOST_PP_LIST_FOR_EACH(_SDF_DECLARE_UNIT_ENUM, ~, _SDF_UNITS)
267 #define _SDF_MAX_UNITS_OP(d, state, list) \ 268 BOOST_PP_MAX_D(d, state, BOOST_PP_SEQ_SIZE(_SDF_UNITSLIST_TUPLES(list))) 269 #define _SDF_UNIT_MAX_UNITS \ 270 BOOST_PP_LIST_FOLD_LEFT(_SDF_MAX_UNITS_OP, 0, _SDF_UNITS) 273 #define _SDF_UNIT_NUM_TYPES BOOST_PP_LIST_SIZE(_SDF_UNITS) 277 #define _SDF_UNIT_MAX_UNITS_BITS TF_BITS_FOR_VALUES(_SDF_UNIT_MAX_UNITS) 278 #define _SDF_UNIT_TYPES_BITS TF_BITS_FOR_VALUES(_SDF_UNIT_NUM_TYPES) 344 #define _SDF_SCALAR_VALUE_TYPES \ 345 ((Bool, bool, bool, () )) \ 346 ((UChar, uchar, unsigned char, () )) \ 347 ((Int, int, int, () )) \ 348 ((UInt, uint, unsigned int, () )) \ 349 ((Int64, int64, int64_t, () )) \ 350 ((UInt64, uint64, uint64_t, () )) \ 351 ((Half, half, GfHalf, () )) \ 352 ((Float, float, float, () )) \ 353 ((Double, double, double, () )) \ 354 ((TimeCode, timecode, SdfTimeCode, () )) \ 355 ((String, string, std::string, () )) \ 356 ((Token, token, TfToken, () )) \ 357 ((Asset, asset, SdfAssetPath, () )) \ 358 ((Opaque, opaque, SdfOpaqueValue, () )) 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)> 387 struct SdfValueTypeTraits {
388 static const bool IsValueType =
false;
394 struct SdfValueTypeTraits<char[N]> {
395 static const bool IsValueType =
true;
398 #define SDF_DECLARE_VALUE_TYPE_TRAITS(r, unused, elem) \ 400 struct SdfValueTypeTraits<SDF_VALUE_CPP_TYPE(elem)> { \ 401 static const bool IsValueType = true; \ 404 struct SdfValueTypeTraits<SDF_VALUE_CPP_ARRAY_TYPE(elem)> { \ 405 static const bool IsValueType = true; \ 408 BOOST_PP_SEQ_FOR_EACH(SDF_DECLARE_VALUE_TYPE_TRAITS, ~, SDF_VALUE_TYPES);
435 #define SDF_VALUE_ROLE_NAME_TOKENS \ 460 typedef std::map<std::string, SdfVariantSetSpecHandle>
461 SdfVariantSetSpecHandleMap;
489 public boost::equality_comparable<SdfUnregisteredValue>
524 class Sdf_ValueTypeNamesType : boost::noncopyable {
566 SDF_API ~Sdf_ValueTypeNamesType();
568 SDF_API
static const Sdf_ValueTypeNamesType* New();
577 friend const Sdf_ValueTypeNamesType* Sdf_InitializeValueTypeNames();
578 Sdf_ValueTypeNamesType();
581 extern SDF_API
TfStaticData<
const Sdf_ValueTypeNamesType,
582 Sdf_ValueTypeNamesType::_Init> SdfValueTypeNames;
599 bool operator==(
const SdfValueBlock& block)
const {
return true; }
600 bool operator!=(
const SdfValueBlock& block)
const {
return false; }
603 friend inline size_t hash_value(
const SdfValueBlock &block) {
return 0; }
612 struct SdfHumanReadableValue {
613 SdfHumanReadableValue() =
default;
614 explicit SdfHumanReadableValue(std::string
const &text) : _text(text) {}
616 bool operator==(SdfHumanReadableValue
const &other)
const {
617 return GetText() == other.GetText();
619 bool operator!=(SdfHumanReadableValue
const &other)
const {
620 return !(*
this == other);
623 std::string
const &GetText()
const {
return _text; }
629 std::ostream &
operator<<(std::ostream &out,
const SdfHumanReadableValue &hrval);
632 size_t hash_value(
const SdfHumanReadableValue &hrval);
634 PXR_NAMESPACE_CLOSE_SCOPE
636 #endif // PXR_USD_SDF_TYPES_H SDF_API TfType SdfGetTypeForValueTypeName(TfToken const &name)
Given an sdf valueType name, produce TfType if the type name specifies a valid sdf value type.
A scene description container that can combine with other such containers to form simple component as...
Base class for SdfAttributeSpec and SdfRelationshipSpec.
SDF_API TfToken SdfGetRoleNameForValueTypeName(TfToken const &typeName)
Return role name for typeName.
std::map< SdfPath, SdfPath > SdfRelocatesMap
A map of source SdfPaths to target SdfPaths for relocation.
std::map< std::string, std::vector< std::string > > SdfVariantsMap
A map of variant set names to list of variants in those sets.
This header serves to simply bring in the half float datatype and provide a hash_value function.
const VtValue & GetValue() const
Returns the wrapped VtValue specified in the constructor.
SDF_API std::ostream & operator<<(std::ostream &out, const SdfSpecifier &spec)
Writes the string representation of SdfSpecifier to out.
A map with string keys and VtValue values.
std::map< std::string, std::string > SdfVariantSelectionMap
A map of reference variant set names to variants in those sets.
Base class for all Sdf spec classes.
SDF_API bool operator==(const SdfUnregisteredValue &other) const
Returns true if the wrapped VtValues are equal.
An enum class that records both enum type and enum value.
Represents a value type name, i.e.
SDF_API const TfEnum & SdfGetUnitFromName(const std::string &name)
Gets a unit for the given /a name.
std::map< std::string, VtValue > SdfMapperParametersMap
A map of mapper parameter names to parameter values.
A special value type that can be used to explicitly author an opinion for an attribute's default valu...
Demangle C++ typenames generated by the typeid() facility.
SDF_API bool SdfConvertToValidMetadataDictionary(VtDictionary *dict, std::string *errMsg)
Convert dict to a valid metadata dictionary for scene description.
SDF_API SdfValueTypeName SdfGetValueTypeNameForValue(VtValue const &value)
Given a value, produce the sdf valueType name.
Token for efficient comparison, assignment, and hashing of known strings.
Stores a representation of the value for an unregistered metadata field encountered during text layer...
A subclass of SdfPropertySpec that holds typed data.
Create or return a previously created object instance of global data.
bool SdfIsDefiningSpecifier(SdfSpecifier spec)
Returns true if the specifier defines a prim.
SDF_API TfEnum SdfDefaultUnit(TfToken const &typeName)
Gets the show default unit for the given /a typeName.
Represents a coherent set of alternate representations for part of a scene.
#define TF_DECLARE_PUBLIC_TOKENS(...)
Macro to define public tokens.
SdfSpecifier
An enum that identifies the possible specifiers for an SdfPrimSpec.
A path value used to locate objects in layers or scenegraphs.
SdfAuthoringError
An enum for TfError codes related to authoring operations.
SdfVariability
An enum that identifies variability types for attributes.
std::enable_if< std::is_same< Half, half >::value, size_t >::type hash_value(const Half &h)
Overload hash_value for half.
Represents a prim description in an SdfLayer object.
A property that contains a reference to one or more SdfPrimSpec instances.
This file defines some macros that are useful for declaring and using static TfTokens.
SdfSpecType
An enum that specifies the type of an object.
SDF_API double SdfConvertUnit(const TfEnum &fromUnit, const TfEnum &toUnit)
Converts from one unit of measure to another.
VT_API size_t GetHash() const
Return a hash code for the held object by calling VtHashValue() on it.
TfType represents a dynamic runtime type.
SDF_API bool SdfValueHasValidType(VtValue const &value)
Given a value, returns if there is a valid corresponding valueType.
VT_API bool operator==(VtDictionary const &, VtDictionary const &)
Equality comparison.
SDF_API SdfUnregisteredValue()
Wraps an empty VtValue.
std::map< double, VtValue > SdfTimeSampleMap
A map from sample times to sample values.
Represents a single variant in a variant set.
SDF_API const std::string & SdfUnitCategory(const TfEnum &unit)
Gets the unit category for a given /a unit.
Provides a container which may hold any type, and provides introspection and iteration over array typ...
SDF_API const std::string & SdfGetNameForUnit(const TfEnum &unit)
Gets the name for a given /a unit.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...
SdfPermission
An enum that defines permission levels.
friend size_t hash_value(const SdfUnregisteredValue &uv)
Hash.