All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
valueTypeName.h
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef SDF_VALUETYPENAME_H
25 #define SDF_VALUETYPENAME_H
26 
27 #include "pxr/pxr.h"
28 #include "pxr/usd/sdf/api.h"
29 #include "pxr/base/tf/token.h"
30 #include <boost/operators.hpp>
31 #include <iosfwd>
32 #include <string>
33 #include <vector>
34 
35 PXR_NAMESPACE_OPEN_SCOPE
36 
37 class TfEnum;
38 class TfType;
39 class VtValue;
40 class Sdf_ValueTypeImpl;
41 
47  : boost::equality_comparable<SdfTupleDimensions> {
48 public:
49  SdfTupleDimensions() : size(0) {}
50  SdfTupleDimensions(size_t m) : size(1) { d[0] = m; }
51  SdfTupleDimensions(size_t m, size_t n) : size(2) { d[0] = m; d[1] = n; }
52  SdfTupleDimensions(const size_t (&s)[2])
53  : size(2) { d[0] = s[0]; d[1] = s[1]; }
54 
55  bool operator==(const SdfTupleDimensions& rhs) const;
56 
57 public:
58  size_t d[2];
59  size_t size;
60 };
61 
84  : boost::equality_comparable<SdfValueTypeName, std::string
85  , boost::equality_comparable<SdfValueTypeName, TfToken
86  , boost::equality_comparable<SdfValueTypeName
87  > > > {
88 public:
90  SDF_API
92 
95  SDF_API
96  TfToken GetAsToken() const;
97 
99  SDF_API
100  const TfType& GetType() const;
101 
106  SDF_API
107  const std::string& GetCPPTypeName() const;
108 
110  SDF_API
111  const TfToken& GetRole() const;
112 
114  SDF_API
115  const VtValue& GetDefaultValue() const;
116 
118  SDF_API
119  const TfEnum& GetDefaultUnit() const;
120 
124  SDF_API
125  SdfValueTypeName GetScalarType() const;
126 
130  SDF_API
131  SdfValueTypeName GetArrayType() const;
132 
135  SDF_API
136  bool IsScalar() const;
137 
140  SDF_API
141  bool IsArray() const;
142 
144  SDF_API
146 
149  SDF_API
150  bool operator==(const SdfValueTypeName& rhs) const;
151 
154  SDF_API
155  bool operator==(const std::string& rhs) const;
156 
159  SDF_API
160  bool operator==(const TfToken& rhs) const;
161 
163  SDF_API
164  size_t GetHash() const;
165 
168  explicit operator bool() const
169  {
170  return !_IsEmpty();
171  }
172 
175  SDF_API
176  std::vector<TfToken> GetAliasesAsTokens() const;
177 
178 private:
179  friend class Sdf_ValueTypeRegistry;
180  friend struct Sdf_ValueTypePrivate;
181 
182  SDF_API
183  explicit SdfValueTypeName(const Sdf_ValueTypeImpl*);
184 
185  SDF_API
186  bool _IsEmpty() const;
187 
188 private:
189  const Sdf_ValueTypeImpl* _impl;
190 };
191 
194  size_t operator()(const SdfValueTypeName& x) const
195  {
196  return x.GetHash();
197  }
198 };
199 
200 inline size_t
201 hash_value(const SdfValueTypeName& typeName)
202 {
203  return typeName.GetHash();
204 }
205 
206 SDF_API std::ostream& operator<<(std::ostream&, const SdfValueTypeName& typeName);
207 
208 PXR_NAMESPACE_CLOSE_SCOPE
209 
210 #endif // SDF_VALUETYPENAME_H
SDF_API const TfType & GetType() const
Returns the TfType of the type.
SDF_API bool operator==(const SdfValueTypeName &rhs) const
Returns true if this type name is equal to rhs.
SDF_API size_t GetHash() const
Returns a hash value for this type name.
SDF_API bool IsScalar() const
Returns true iff this type is a scalar.
SDF_API SdfValueTypeName GetArrayType() const
Returns the array version of this type name if it&#39;s an scalar type name, otherwise returns this type ...
An enum class that records both enum type and enum value.
Definition: enum.h:140
Represents a value type name, i.e.
Definition: valueTypeName.h:83
SDF_API SdfTupleDimensions GetDimensions() const
Returns the dimensions of the scalar value, e.g. 3 for a 3D point.
SDF_API bool IsArray() const
Returns true iff this type is an array.
SDF_API const VtValue & GetDefaultValue() const
Returns the default value for the type.
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
SDF_API std::vector< TfToken > GetAliasesAsTokens() const
Returns all aliases of the type name as tokens.
SDF_API const TfEnum & GetDefaultUnit() const
Returns the default unit enum for the type.
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
SDF_API const std::string & GetCPPTypeName() const
Returns the C++ type name for this type.
SDF_API SdfValueTypeName()
Constructs an invalid type name.
SDF_API const TfToken & GetRole() const
Returns the type&#39;s role.
Functor for hashing a SdfValueTypeName.
TfType represents a dynamic runtime type.
Definition: type.h:70
Represents the shape of a value type (or that of an element in an array).
Definition: valueTypeName.h:46
SDF_API TfToken GetAsToken() const
Returns the type name as a token.
SDF_API SdfValueTypeName GetScalarType() const
Returns the scalar version of this type name if it&#39;s an array type name, otherwise returns this type ...
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:182