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"
36 #include "pxr/usd/sdf/valueTypeName.h"
63 #include "pxr/base/tf/type.h"
66 #include "pxr/base/vt/value.h"
68 #include <boost/noncopyable.hpp>
69 #include <boost/preprocessor/list/for_each.hpp>
70 #include <boost/preprocessor/list/size.hpp>
71 #include <boost/preprocessor/punctuation/comma.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>
76 #include <boost/shared_ptr.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, () ))
359 #define _SDF_DIMENSIONED_VALUE_TYPES \
360 ((Matrix2d, matrix2d, GfMatrix2d, (2,2) )) \
361 ((Matrix3d, matrix3d, GfMatrix3d, (3,3) )) \
362 ((Matrix4d, matrix4d, GfMatrix4d, (4,4) )) \
363 ((Quath, quath, GfQuath, (4) )) \
364 ((Quatf, quatf, GfQuatf, (4) )) \
365 ((Quatd, quatd, GfQuatd, (4) )) \
366 ((Int2, int2, GfVec2i, (2) )) \
367 ((Half2, half2, GfVec2h, (2) )) \
368 ((Float2, float2, GfVec2f, (2) )) \
369 ((Double2, double2, GfVec2d, (2) )) \
370 ((Int3, int3, GfVec3i, (3) )) \
371 ((Half3, half3, GfVec3h, (3) )) \
372 ((Float3, float3, GfVec3f, (3) )) \
373 ((Double3, double3, GfVec3d, (3) )) \
374 ((Int4, int4, GfVec4i, (4) )) \
375 ((Half4, half4, GfVec4h, (4) )) \
376 ((Float4, float4, GfVec4f, (4) )) \
377 ((Double4, double4, GfVec4d, (4) ))
379 #define SDF_VALUE_TYPES _SDF_SCALAR_VALUE_TYPES _SDF_DIMENSIONED_VALUE_TYPES
382 #define SDF_VALUE_CPP_TYPE(tup) BOOST_PP_TUPLE_ELEM(4, 2, tup)
383 #define SDF_VALUE_CPP_ARRAY_TYPE(tup) VtArray<BOOST_PP_TUPLE_ELEM(4, 2, tup)>
386 struct SdfValueTypeTraits {
387 static const bool IsValueType =
false;
393 struct SdfValueTypeTraits<char[N]> {
394 static const bool IsValueType =
true;
397 #define SDF_DECLARE_VALUE_TYPE_TRAITS(r, unused, elem) \
399 struct SdfValueTypeTraits<SDF_VALUE_CPP_TYPE(elem)> { \
400 static const bool IsValueType = true; \
403 struct SdfValueTypeTraits<SDF_VALUE_CPP_ARRAY_TYPE(elem)> { \
404 static const bool IsValueType = true; \
407 BOOST_PP_SEQ_FOR_EACH(SDF_DECLARE_VALUE_TYPE_TRAITS, ~, SDF_VALUE_TYPES);
434 #define SDF_VALUE_ROLE_NAME_TOKENS \
458 typedef std::map<std::string, SdfVariantSetSpecHandle>
459 SdfVariantSetSpecHandleMap;
468 const SdfRelocatesMap &reloMap );
473 const SdfTimeSampleMap &sampleMap );
476 std::ostream &VtStreamOut(
const SdfVariantSelectionMap &, std::ostream &);
487 public boost::equality_comparable<SdfUnregisteredValue>
513 SDF_API
bool operator==(
const SdfUnregisteredValue &other)
const;
522 class Sdf_ValueTypeNamesType : boost::noncopyable {
562 SDF_API ~Sdf_ValueTypeNamesType();
564 SDF_API
static const Sdf_ValueTypeNamesType* New();
573 friend const Sdf_ValueTypeNamesType* Sdf_InitializeValueTypeNames();
574 Sdf_ValueTypeNamesType();
577 extern SDF_API
TfStaticData<
const Sdf_ValueTypeNamesType,
578 Sdf_ValueTypeNamesType::_Init> SdfValueTypeNames;
595 bool operator==(
const SdfValueBlock& block)
const {
return true; }
596 bool operator!=(
const SdfValueBlock& block)
const {
return false; }
599 friend inline size_t hash_value(
const SdfValueBlock &block) {
return 0; }
608 struct SdfHumanReadableValue {
609 SdfHumanReadableValue() =
default;
610 explicit SdfHumanReadableValue(std::string
const &text) : _text(text) {}
612 bool operator==(SdfHumanReadableValue
const &other)
const {
613 return GetText() == other.GetText();
615 bool operator!=(SdfHumanReadableValue
const &other)
const {
616 return !(*
this == other);
619 std::string
const &GetText()
const {
return _text; }
625 std::ostream &
operator<<(std::ostream &out,
const SdfHumanReadableValue &hrval);
628 size_t hash_value(
const SdfHumanReadableValue &hrval);
630 PXR_NAMESPACE_CLOSE_SCOPE
632 #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 unit of scene description that you combine with other units of scene description to form a shot...
SDF_API bool operator==(const SdfUnregisteredValue &other) const
Returns true if the wrapped VtValues are equal.
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...
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.
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.
const VtValue & GetValue() const
Returns the wrapped VtValue specified in the constructor.
SdfVariability
An enum that identifies variability types for attributes.
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
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.