All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
traits.h
1 //
2 // Copyright 2018 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 VTKATANA_TRAITS_H
25 #define VTKATANA_TRAITS_H
26 
27 #include "pxr/pxr.h"
28 
29 #include <type_traits>
30 
31 #include <FnAttribute/FnAttribute.h>
32 
33 #include "pxr/base/tf/envSetting.h"
34 #include "pxr/base/tf/token.h"
35 
36 #include "pxr/base/vt/array.h"
37 
38 #include "pxr/base/gf/vec2d.h"
39 #include "pxr/base/gf/vec2f.h"
40 #include "pxr/base/gf/vec2h.h"
41 #include "pxr/base/gf/vec3d.h"
42 #include "pxr/base/gf/vec3f.h"
43 #include "pxr/base/gf/vec3h.h"
44 #include "pxr/base/gf/vec4d.h"
45 #include "pxr/base/gf/vec4f.h"
46 #include "pxr/base/gf/vec4h.h"
47 
48 #include "pxr/base/gf/matrix3d.h"
49 #include "pxr/base/gf/matrix3f.h"
50 #include "pxr/base/gf/matrix4d.h"
51 #include "pxr/base/gf/matrix4f.h"
52 
53 #include "pxr/usd/sdf/assetPath.h"
54 #include "pxr/usd/sdf/path.h"
55 
56 PXR_NAMESPACE_OPEN_SCOPE
57 
58 extern TfEnvSetting<bool> VTKATANA_ENABLE_ZERO_COPY_ARRAYS;
59 
88 
90 template <typename T>
91 struct VtKatana_IsString : public std::is_same<T, std::string> {};
92 
97 template <typename T>
99  : public std::integral_constant<bool,
100  std::is_same<T, SdfPath>::value ||
101  std::is_same<T, SdfAssetPath>::value ||
102  std::is_same<T, TfToken>::value> {};
103 
105 template <typename T>
107  : public std::integral_constant<bool, VtKatana_IsString<T>::value ||
108  VtKatana_HoldsString<T>::value> {
109 };
110 
112 template <typename T, typename = void>
114  typedef void type;
115 };
116 
118 template <typename T>
120  T, typename std::enable_if<std::is_arithmetic<T>::value>::type> {
121  typedef T type;
122 };
123 
125 template <>
127  typedef GfHalf type;
128 };
129 
131 template <typename T>
133  T, typename std::enable_if<GfIsGfVec<T>::value ||
134  GfIsGfMatrix<T>::value>::type> {
135  typedef typename T::ScalarType type;
136 };
137 
140 template <typename T, typename = void>
142  : public std::integral_constant<
143  bool, std::is_same<typename VtKatana_GetNumericScalarType<T>::type,
144  GfHalf>::value ||
145  std::is_arithmetic<typename VtKatana_GetNumericScalarType<
146  T>::type>::value> {};
147 
150 template <typename T, typename = void>
152  typedef FnAttribute::NullAttribute type;
153 };
154 
157 template <typename T>
159  T, typename std::enable_if<VtKatana_IsOrHoldsString<T>::value>::type> {
160  typedef FnAttribute::StringAttribute type;
161 };
162 
165 template <typename T>
167  T, typename std::enable_if<
168  VtKatana_IsNumeric<T>::value &&
169  std::is_integral<
170  typename VtKatana_GetNumericScalarType<T>::type>::value>::type> {
171  typedef FnAttribute::IntAttribute type;
172 };
173 
176 template <typename T>
178  T, typename std::enable_if<
179  VtKatana_IsNumeric<T>::value &&
180  (std::is_same<typename VtKatana_GetNumericScalarType<T>::type,
181  float>::value ||
182  std::is_same<typename VtKatana_GetNumericScalarType<T>::type,
183  GfHalf>::value)>::type> {
184  typedef FnAttribute::FloatAttribute type;
185 };
186 
189 template <typename T>
191  T, typename std::enable_if<
192  VtKatana_IsNumeric<T>::value &&
193  std::is_same<typename VtKatana_GetNumericScalarType<T>::type,
194  double>::value>::type> {
195  typedef FnAttribute::DoubleAttribute type;
196 };
197 
200 template <typename T,
201  typename = typename std::enable_if<std::is_base_of<
202  FnAttribute::DataAttribute,
203  typename VtKatana_GetKatanaAttrType<T>::type>::value>::type>
206 };
207 
208 PXR_NAMESPACE_CLOSE_SCOPE
209 
210 #endif
pxr_half::half GfHalf
A 16-bit floating point data type.
Definition: half.h:42
True if T holds onto and can be converted to a std::string The mapping to string for SdfPath and TfTo...
Definition: traits.h:98
We distinguish between two types of data that we want to shuffle between Katana and Vt...
Definition: traits.h:91
All Katana Data Attribute types (Float, String, Int, Double) have an associated value_type member...
Definition: traits.h:204
Return the underlying arithmetic type for the numeric value.
Definition: traits.h:113
Every Numeric and String type can be mapped to a single Katana Attribute Type.
Definition: traits.h:151
Numeric types are types represented by a single scalar or a memory-aligned tuple of scalars...
Definition: traits.h:141