Loading...
Searching...
No Matches
valueTypeName.h
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_USD_SDF_VALUE_TYPE_NAME_H
8#define PXR_USD_SDF_VALUE_TYPE_NAME_H
9
10#include "pxr/pxr.h"
11#include "pxr/usd/sdf/api.h"
12#include "pxr/base/tf/token.h"
13
14#include <iosfwd>
15#include <string>
16#include <vector>
17
18PXR_NAMESPACE_OPEN_SCOPE
19
20class TfEnum;
21class TfType;
22class VtValue;
24class Sdf_ValueTypeImpl;
25
31{
32public:
33 SdfTupleDimensions() : size(0) {}
34 SdfTupleDimensions(size_t m) : size(1) { d[0] = m; }
35 SdfTupleDimensions(size_t m, size_t n) : size(2) { d[0] = m; d[1] = n; }
36 SdfTupleDimensions(const size_t (&s)[2])
37 : size(2) { d[0] = s[0]; d[1] = s[1]; }
38
39 SDF_API
40 bool operator==(const SdfTupleDimensions& rhs) const;
41 bool operator!=(const SdfTupleDimensions& rhs) const {
42 return !(*this == rhs);
43 }
44
45public:
46 size_t d[2];
47 size_t size;
48};
49
72{
73public:
75 SDF_API
77
80 SDF_API
82
84 SDF_API
85 const TfType& GetType() const;
86
92 SDF_API
93 bool CanRepresent(const VtValue &value) const;
94
96 SDF_API
97 bool CanRepresent(const SdfAbstractDataConstValue &value) const;
98
103 SDF_API
104 const std::string& GetCPPTypeName() const;
105
107 SDF_API
108 const TfToken& GetRole() const;
109
111 SDF_API
112 const VtValue& GetDefaultValue() const;
113
115 SDF_API
116 const TfEnum& GetDefaultUnit() const;
117
121 SDF_API
123
127 SDF_API
129
132 SDF_API
133 bool IsScalar() const;
134
137 SDF_API
138 bool IsArray() const;
139
141 SDF_API
143
146 SDF_API
147 bool operator==(const SdfValueTypeName& rhs) const;
148 bool operator!=(const SdfValueTypeName& rhs) const {
149 return !(*this == rhs);
150 }
151
154 SDF_API
155 bool operator==(const std::string& rhs) const;
156 bool operator!=(const std::string& rhs) const {
157 return !(*this == rhs);
158 }
159
162 SDF_API
163 bool operator==(const TfToken& rhs) const;
164 bool operator!=(const TfToken& rhs) const {
165 return !(*this == rhs);
166 }
167
168 friend inline
169 bool operator==(const std::string& lhs, const SdfValueTypeName& rhs) {
170 return rhs == lhs;
171 }
172 friend inline
173 bool operator!=(const std::string& lhs, const SdfValueTypeName& rhs) {
174 return !(rhs == lhs);
175 }
176
177 friend inline
178 bool operator==(const TfToken& lhs, const SdfValueTypeName &rhs) {
179 return rhs == lhs;
180 }
181 friend inline
182 bool operator!=(const TfToken& lhs, const SdfValueTypeName &rhs) {
183 return !(rhs == lhs);
184 }
185
187 SDF_API
188 size_t GetHash() const;
189
192 explicit operator bool() const
193 {
194 return !_IsEmpty();
195 }
196
199 SDF_API
200 std::vector<TfToken> GetAliasesAsTokens() const;
201
202private:
203 friend class Sdf_ValueTypeRegistry;
204 friend struct Sdf_ValueTypePrivate;
205
206 SDF_API
207 explicit SdfValueTypeName(const Sdf_ValueTypeImpl*);
208
209 SDF_API
210 bool _IsEmpty() const;
211
212private:
213 const Sdf_ValueTypeImpl* _impl;
214};
215
218 size_t operator()(const SdfValueTypeName& x) const
219 {
220 return x.GetHash();
221 }
222};
223
224inline size_t
225hash_value(const SdfValueTypeName& typeName)
226{
227 return typeName.GetHash();
228}
229
230SDF_API std::ostream& operator<<(std::ostream&, const SdfValueTypeName& typeName);
231
232PXR_NAMESPACE_CLOSE_SCOPE
233
234#endif // PXR_USD_SDF_VALUE_TYPE_NAME_H
A type-erased container for a const field value in an SdfAbstractData.
Definition: abstractData.h:544
Represents a value type name, i.e.
Definition: valueTypeName.h:72
SDF_API bool IsArray() const
Returns true iff this type is an array.
SDF_API bool operator==(const std::string &rhs) const
Returns true if this type name is equal to rhs.
SDF_API const TfEnum & GetDefaultUnit() const
Returns the default unit enum for the type.
SDF_API SdfValueTypeName GetArrayType() const
Returns the array version of this type name if it's an scalar type name, otherwise returns this type ...
SDF_API bool operator==(const SdfValueTypeName &rhs) const
Returns true if this type name is equal to rhs.
SDF_API const TfType & GetType() const
Returns the TfType of the type.
SDF_API const VtValue & GetDefaultValue() const
Returns the default value for the type.
SDF_API SdfTupleDimensions GetDimensions() const
Returns the dimensions of the scalar value, e.g. 3 for a 3D point.
SDF_API const TfToken & GetRole() const
Returns the type's role.
SDF_API bool IsScalar() const
Returns true iff this type is a scalar.
SDF_API TfToken GetAsToken() const
Returns the type name as a token.
SDF_API std::vector< TfToken > GetAliasesAsTokens() const
Returns all aliases of the type name as tokens.
SDF_API bool CanRepresent(const VtValue &value) const
Return true if value holds an object whose type is compatible with this scene description type in a s...
SDF_API bool CanRepresent(const SdfAbstractDataConstValue &value) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
SDF_API const std::string & GetCPPTypeName() const
Returns the C++ type name for this type.
SDF_API SdfValueTypeName GetScalarType() const
Returns the scalar version of this type name if it's an array type name, otherwise returns this type ...
SDF_API size_t GetHash() const
Returns a hash value for this type name.
SDF_API bool operator==(const TfToken &rhs) const
Returns true if this type name is equal to rhs.
SDF_API SdfValueTypeName()
Constructs an invalid type name.
An enum class that records both enum type and enum value.
Definition: enum.h:120
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
TfType represents a dynamic runtime type.
Definition: type.h:48
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:152
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
Represents the shape of a value type (or that of an element in an array).
Definition: valueTypeName.h:31
Functor for hashing a SdfValueTypeName.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...