FnUsdAbstractionLib 15.1.6
|
An object which can hold many types of value. More...
#include <Value.h>
Public Types | |
enum | DataType { STRING_DATA , TOKEN_DATA , ASSETPATH_DATA , INT8_DATA , INT16_DATA , INT32_DATA , INT64_DATA , HALF_DATA , FLOAT_DATA , DOUBLE_DATA } |
Abstraction handle for casting to underlying implementation type. | |
enum | Type { DefaultType = -1 , String = 0 , StringArray , Token , TokenArray , Path , PathArray , AssetPath , AssetPathArray , Bool , BoolArray , Int , IntArray , Int64 , Int64Array , UChar , UCharArray , UInt , UIntArray , UInt64 , UInt64Array , Half , HalfArray , Float , FloatArray , Double , DoubleArray , TimeCode , TimeCodeArray , Int2 , Int2Array , Half2 , Half2Array , Float2 , Float2Array , Double2 , Double2Array , Int3 , Int3Array , Half3 , Half3Array , Float3 , Float3Array , Double3 , Double3Array , Int4 , Int4Array , Half4 , Half4Array , Float4 , Float4Array , Double4 , Double4Array , Matrix2d , Matrix2dArray , Matrix3d , Matrix3dArray , Matrix4d , Matrix4dArray , Quath , QuathArray , Quatf , QuatfArray , Quatd , QuatdArray , Channel , ChannelArray , Color , ColorArray , Color3h , Color3hArray , Color3f , Color3fArray , Color3d , Color3dArray , Color4h , Color4hArray , Color4f , Color4fArray , Color4d , Color4dArray , Normal , NormalArray , Normal3h , Normal3hArray , Normal3f , Normal3fArray , Normal3d , Normal3dArray , Point , PointArray , Point3h , Point3hArray , Point3f , Point3fArray , Point3d , Point3dArray , Vector , VectorArray , Vector3h , Vector3hArray , Vector3f , Vector3fArray , Vector3d , Vector3dArray , TexCoord2h , TexCoord2hArray , TexCoord2f , TexCoord2fArray , TexCoord2d , TexCoord2dArray , TexCoord3h , TexCoord3hArray , TexCoord3f , TexCoord3fArray , TexCoord3d , TexCoord3dArray , Matrix , MatrixArray , Frame4d , Frame4dArray , Struct , StructArray , Terminal , TerminalArray , Vstruct , VstructArray , InvalidType , NumValueTypes = InvalidType } |
Public Member Functions | |
Value () | |
Creates an empty (invalid) value. | |
Value (const Value &) | |
Copy constructors. | |
Value & | operator= (const Value &) |
template<typename T > | |
Value (const T &data) | |
Construct from a value source. | |
template<typename T > | |
Value (const usg::Array< T > &array) | |
Construct from a value Array source. | |
template<typename T > | |
Value (const std::vector< T > &vector) | |
Construct from a std::vector source. | |
Value (const char *data) | |
bool | isValid () const |
True if Value::Impl is valid (has a valid object binding.) | |
operator bool () const | |
Value::Handle * | getVtValue (int usd_version) |
const Value::Handle * | getVtValue (int usd_version) const |
template<typename T > | |
const T & | get () const |
Returns a const reference to the contained data. | |
usg::Token | getToken () const |
Dedicated version returning a Token. | |
usg::Path | getPath () const |
Dedicated version returning a Path. | |
usg::AssetPath | getAssetPath () const |
Dedicated version returning an AssetPath. | |
template<typename T > | |
void | get (T &val, const T &def_val) const |
Fills in the passed-in data object if this Value is valid, otherwise copies the provided default. | |
template<typename T > | |
void | get (std::vector< T > &values, const std::vector< T > &def_values) const |
Fills in the passed-in array object if this Value is valid, otherwise copies the provided default array. | |
void | get (std::string &val, const char *def_val) const |
Specialized version for easier string handling (retrieves a Type::String) | |
bool | isEmpty () const |
Same as !isValid(). | |
Type | getType () const |
Return this value's Type enumeration. | |
const std::string & | getTypeName () const |
Return this value's Type name. | |
Type | getBaseType () const |
DataType | getBaseDataType () const |
bool | isArray () const |
Returns true if this is an array-typed value. | |
size_t | getArraySize () const |
Returns the size of the array if an array type value, otherwise 0. | |
size_t | getHash () const |
Return a hash of the value using VtHashValue. | |
Value (const Value::Impl &) | |
Wrapper abstraction for implementation type. | |
Value & | operator= (const Value::Impl &) |
bool | setFromImpl (Value::Impl &&b) |
Takes ownership of 'b' - returns true if resulting Value is valid. | |
Value::Impl * | impl () |
const Value::Impl * | impl () const |
template<> | |
USG_API | Value (const std::string &data) |
Static Public Member Functions | |
static Type | getTypeFromName (const std::string &type_name) |
Gets Type enum from string. | |
static const std::string & | getTypeName (Type type) |
Gets type name from Type enum. | |
static Type | getBaseType (Type type) |
Returns this Type's non-aliased Type enumeration (ie base type of a Color3f is Float3) | |
static DataType | getBaseDataType (Type type) |
Returns this Type's base DataType enumeration (ie data type of a Color3f is FLOAT_DATA) | |
static size_t | getNumDataElements (Type type) |
Returns the number of data elements for the Type. For example, 3 for a Vector3 or 16 for a Matrix4. | |
static size_t | getBytesPerDataElement (Type type) |
Returns the number of bytes for a data element of the Type. For example, 4 for a float or 8 for a double. | |
static Value | getDefaultValueForType (Type type) |
Returns a value for the default 'empty' state of the Type. ie 0 for int, 0.0f for float, '' for string, etc. | |
Protected Attributes | |
std::unique_ptr< Value::Impl, void(*)(Value::Impl *)> | _pImpl |
Friends | |
class | Attribute |
USG_API std::ostream & | operator<< (std::ostream &o, const Value &b) |
Prints a summary of the attribute to a stream. | |
USG_API bool | operator== (const Value &lhs, const Value &rhs) |
Tests two values for equality. | |
An object which can hold many types of value.
enum usg::Value::Type |
Supported POD & compound value types. Each value type has an array variant.
Some types are interpretation aliases (a role) overlaying the base type. For example Normal, Normal3f, Color, Color3f, Point, Point3f, Vector and Vector3f are all aliases for the Float3 base type.
Shader properties only support an explicit subset of these types and should only be declared with the following types: Int IntArray String StringArray Float FloatArray
Color3f Color3fArray Point3f Point3fArray Normal3f Normal3fArray Vector3f Vector3fArray
Matrix4d Matrix4dArray
Struct StructArray, Terminal TerminalArray Vstruct VstructArray
Enumerator | |
---|---|
DefaultType | Special value used as the 'default' indicator for an argument. |
InvalidType | Special value typically used as a return argument indicating an error or unhandled type. |
Value::Handle * usg::Value::getVtValue | ( | int | usd_version | ) |
Return a pointer to the underlying VtValue object if the usd_version passed in matches the Usd version this library was built with, otherwise return null.
The version must match the one returned by usg::usdAPIVersion().
Caller should cast the returned pointer to a VtValue* and possibly double-check its validity since a Value can be created without a valid binding. However, if Value::isValid() returns true then the underlying binding will also be valid.
Type usg::Value::getBaseType | ( | ) | const |
©2025 The Foundry Visionmongers, Ltd. All Rights Reserved. |