All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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;
23class Sdf_ValueTypeImpl;
24
30{
31public:
32 SdfTupleDimensions() : size(0) {}
33 SdfTupleDimensions(size_t m) : size(1) { d[0] = m; }
34 SdfTupleDimensions(size_t m, size_t n) : size(2) { d[0] = m; d[1] = n; }
35 SdfTupleDimensions(const size_t (&s)[2])
36 : size(2) { d[0] = s[0]; d[1] = s[1]; }
37
38 SDF_API
39 bool operator==(const SdfTupleDimensions& rhs) const;
40 bool operator!=(const SdfTupleDimensions& rhs) const {
41 return !(*this == rhs);
42 }
43
44public:
45 size_t d[2];
46 size_t size;
47};
48
71{
72public:
74 SDF_API
76
79 SDF_API
81
83 SDF_API
84 const TfType& GetType() const;
85
90 SDF_API
91 const std::string& GetCPPTypeName() const;
92
94 SDF_API
95 const TfToken& GetRole() const;
96
98 SDF_API
99 const VtValue& GetDefaultValue() const;
100
102 SDF_API
103 const TfEnum& GetDefaultUnit() const;
104
108 SDF_API
110
114 SDF_API
116
119 SDF_API
120 bool IsScalar() const;
121
124 SDF_API
125 bool IsArray() const;
126
128 SDF_API
130
133 SDF_API
134 bool operator==(const SdfValueTypeName& rhs) const;
135 bool operator!=(const SdfValueTypeName& rhs) const {
136 return !(*this == rhs);
137 }
138
141 SDF_API
142 bool operator==(const std::string& rhs) const;
143 bool operator!=(const std::string& rhs) const {
144 return !(*this == rhs);
145 }
146
149 SDF_API
150 bool operator==(const TfToken& rhs) const;
151 bool operator!=(const TfToken& rhs) const {
152 return !(*this == rhs);
153 }
154
155 friend inline
156 bool operator==(const std::string& lhs, const SdfValueTypeName& rhs) {
157 return rhs == lhs;
158 }
159 friend inline
160 bool operator!=(const std::string& lhs, const SdfValueTypeName& rhs) {
161 return !(rhs == lhs);
162 }
163
164 friend inline
165 bool operator==(const TfToken& lhs, const SdfValueTypeName &rhs) {
166 return rhs == lhs;
167 }
168 friend inline
169 bool operator!=(const TfToken& lhs, const SdfValueTypeName &rhs) {
170 return !(rhs == lhs);
171 }
172
174 SDF_API
175 size_t GetHash() const;
176
179 explicit operator bool() const
180 {
181 return !_IsEmpty();
182 }
183
186 SDF_API
187 std::vector<TfToken> GetAliasesAsTokens() const;
188
189private:
190 friend class Sdf_ValueTypeRegistry;
191 friend struct Sdf_ValueTypePrivate;
192
193 SDF_API
194 explicit SdfValueTypeName(const Sdf_ValueTypeImpl*);
195
196 SDF_API
197 bool _IsEmpty() const;
198
199private:
200 const Sdf_ValueTypeImpl* _impl;
201};
202
205 size_t operator()(const SdfValueTypeName& x) const
206 {
207 return x.GetHash();
208 }
209};
210
211inline size_t
212hash_value(const SdfValueTypeName& typeName)
213{
214 return typeName.GetHash();
215}
216
217SDF_API std::ostream& operator<<(std::ostream&, const SdfValueTypeName& typeName);
218
219PXR_NAMESPACE_CLOSE_SCOPE
220
221#endif // PXR_USD_SDF_VALUE_TYPE_NAME_H
Represents a value type name, i.e.
Definition: valueTypeName.h:71
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 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:147
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:30
Functor for hashing a SdfValueTypeName.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...