35 #ifndef IE_CORE_TYPETRAITS_H
36 #define IE_CORE_TYPETRAITS_H
38 #include "boost/static_assert.hpp"
40 #include "boost/mpl/or.hpp"
41 #include "boost/mpl/and.hpp"
42 #include "boost/mpl/if.hpp"
43 #include "boost/mpl/not.hpp"
44 #include "boost/mpl/eval_if.hpp"
45 #include "boost/mpl/identity.hpp"
47 #include "boost/type_traits.hpp"
49 #include "IECore/HalfTypeTraits.h"
50 #include "IECore/SimpleTypedData.h"
51 #include "IECore/VectorTypedData.h"
52 #include "IECore/Spline.h"
53 #include "IECore/SplineData.h"
54 #include "IECore/DateTimeData.h"
55 #include "IECore/TransformationMatrixData.h"
57 #include "OpenEXR/ImathVec.h"
58 #include "OpenEXR/ImathMatrix.h"
59 #include "OpenEXR/ImathQuat.h"
60 #include "OpenEXR/ImathBox.h"
69 template<
typename T>
struct HasValueType :
public boost::false_type {};
71 template<
typename T>
struct HasValueType<
GeometricTypedData<T> > :
public boost::true_type {};
72 template<
typename T>
struct HasValueType< const T > :
public HasValueType< T > {};
77 template<
typename T>
struct HasVectorValueType<
GeometricTypedData<
std::vector<T> > > :
public boost::true_type {};
78 template<
typename T>
struct HasVectorValueType< const T > :
public HasVectorValueType<T> {};
81 template<
typename T>
struct HasBaseType :
public boost::mpl::not_< boost::is_void<typename T::BaseType> > {};
89 typedef typename T::ValueType type;
93 struct GetVectorValueType
95 typedef typename T::ValueType::value_type type;
103 typedef typename boost::mpl::eval_if< HasValueType<T>, Detail::GetValueType<T>, boost::mpl::identity<T> >::type type;
107 struct VectorValueType
109 typedef typename boost::mpl::eval_if< HasVectorValueType<T>, Detail::GetVectorValueType<T>, boost::mpl::identity<T> >::type type;
113 template<
typename T>
struct IsTypedData :
public boost::false_type {};
115 template<
typename T>
struct IsTypedData<
GeometricTypedData<T> > :
public boost::true_type {};
116 template<
typename T>
struct IsTypedData< const T > :
public IsTypedData<T> {};
121 template<
typename T>
struct IsGeometricTypedData< const T > :
public IsGeometricTypedData<T> {};
126 template<
typename T>
struct IsVectorTypedData<
GeometricTypedData<
std::vector<T> > > :
public boost::true_type {};
127 template<
typename T>
struct IsVectorTypedData< const T > :
public IsVectorTypedData<T> {};
132 template<
typename T>
struct IsSimpleTypedData<
GeometricTypedData<T > > :
public boost::true_type {};
133 template<
typename T>
struct IsSimpleTypedData< TypedData<
std::vector<T> > > :
public boost::false_type {};
134 template<
typename T>
struct IsSimpleTypedData< GeometricTypedData<
std::vector<T> > > :
public boost::false_type {};
135 template<
typename T>
struct IsSimpleTypedData< const T > :
public IsSimpleTypedData<T> {};
138 template<
typename T>
struct IsMatrix33 :
public boost::false_type {};
139 template<
typename T>
struct IsMatrix33<
Imath::Matrix33<T> > :
public boost::true_type {};
140 template<
typename T>
struct IsMatrix33< const T > :
public IsMatrix33< T > {};
143 template<
typename T>
struct IsMatrix44 :
public boost::false_type {};
144 template<
typename T>
struct IsMatrix44<
Imath::Matrix44<T> > :
public boost::true_type {};
145 template<
typename T>
struct IsMatrix44< const T > :
public IsMatrix44< T > {};
148 template<
typename T>
struct IsMatrix : boost::mpl::or_< IsMatrix33<T>, IsMatrix44<T> > {};
151 template<
typename T>
struct IsVec3 :
public boost::false_type {};
152 template<
typename T>
struct IsVec3<
Imath::Vec3<T> > :
public boost::true_type {};
153 template<
typename T>
struct IsVec3< const T > :
public IsVec3< T > {};
156 template<
typename T>
struct IsFloatVec3 :
public boost::false_type {};
157 template<>
struct IsFloatVec3<
Imath::Vec3<float> > :
public boost::true_type {};
158 template<>
struct IsFloatVec3<
Imath::Vec3<double> > :
public boost::true_type {};
159 template<
typename T>
struct IsFloatVec3< const T > :
public IsFloatVec3< T > {};
162 template<
typename T>
struct IsVec2 :
public boost::false_type {};
163 template<
typename T>
struct IsVec2<
Imath::Vec2<T> > :
public boost::true_type {};
164 template<
typename T>
struct IsVec2< const T > :
public IsVec2< T > {};
167 template<
typename T>
struct IsFloatVec2 :
public boost::false_type {};
168 template<>
struct IsFloatVec2<
Imath::Vec2<float> > :
public boost::true_type {};
169 template<>
struct IsFloatVec2<
Imath::Vec2<double> > :
public boost::true_type {};
170 template<
typename T>
struct IsFloatVec2< const T > :
public IsFloatVec2< T > {};
173 template<
typename T>
struct IsVec : boost::mpl::or_< IsVec3<T>, IsVec2<T> > {};
176 template<
typename T>
struct IsColor3 :
public boost::false_type {};
177 template<
typename T>
struct IsColor3<
Imath::Color3<T> > :
public boost::true_type {};
178 template<
typename T>
struct IsColor3< const T > :
public IsColor3< T > {};
181 template<
typename T>
struct IsColor4 :
public boost::false_type {};
182 template<
typename T>
struct IsColor4<
Imath::Color4<T> > :
public boost::true_type {};
183 template<
typename T>
struct IsColor4< const T > :
public IsColor4< T > {};
186 template<
typename T>
struct IsColor : boost::mpl::or_< IsColor3<T>, IsColor4<T> > {};
189 template<
typename T>
struct IsQuat :
public boost::false_type {};
190 template<
typename T>
struct IsQuat<
Imath::Quat<T> > :
public boost::true_type {};
191 template<
typename T>
struct IsQuat< const T > :
public IsQuat< T > {};
194 template<
typename T>
struct IsBox :
public boost::false_type {};
195 template<
typename T>
struct IsBox<
Imath::Box<T> > :
public boost::true_type {};
196 template<
typename T>
struct IsBox< const T> :
public IsBox< T > {};
201 template<
typename T>
struct IsTransformationMatrix< const T > :
public IsTransformationMatrix< T > {};
204 template<
typename T >
struct IsMatrixTypedData : boost::mpl::and_< IsTypedData<T>, IsMatrix< typename ValueType<T>::type > > {};
207 template<
typename T >
struct IsVec2TypedData : boost::mpl::and_< IsTypedData<T>, IsVec2< typename ValueType<T>::type > > {};
210 template<
typename T >
struct IsVec2VectorTypedData : boost::mpl::and_< IsVectorTypedData<T>, IsVec2< typename VectorValueType<T>::type > > {};
213 template<
typename T >
struct IsFloatVec2VectorTypedData : boost::mpl::and_< IsVectorTypedData<T>, IsFloatVec2< typename VectorValueType<T>::type > > {};
216 template<
typename T >
struct IsVec3TypedData : boost::mpl::and_< IsTypedData<T>, IsVec3< typename ValueType<T>::type > > {};
219 template<
typename T >
struct IsVec3VectorTypedData : boost::mpl::and_< IsVectorTypedData<T>, IsVec3< typename VectorValueType<T>::type > > {};
222 template<
typename T >
struct IsFloatVec3VectorTypedData : boost::mpl::and_< IsVectorTypedData<T>, IsFloatVec3< typename VectorValueType<T>::type > > {};
225 template<
typename T >
struct IsVecTypedData : boost::mpl::or_< IsVec2TypedData<T>, IsVec3TypedData<T> > {};
228 template<
typename T >
struct IsVecVectorTypedData : boost::mpl::or_< IsVec2VectorTypedData<T>, IsVec3VectorTypedData<T> > {};
231 template<
typename T >
struct IsNumericVectorTypedData : boost::mpl::and_< IsVectorTypedData<T>, boost::is_arithmetic< typename VectorValueType<T>::type >, boost::mpl::not_< boost::is_same< typename VectorValueType<T>::type, bool > > > {};
234 template<
typename T >
struct IsNumericBasedVectorTypedData : boost::mpl::and_< IsVectorTypedData<T>, boost::is_arithmetic< typename T::BaseType >, boost::mpl::not_< boost::is_same< typename T::BaseType, bool > > > {};
237 template<
typename T >
struct IsFloatVectorTypedData : boost::mpl::and_< IsVectorTypedData<T>, boost::is_floating_point< typename VectorValueType<T>::type > > {};
240 template<
typename T >
struct IsNumericSimpleTypedData : boost::mpl::and_< IsSimpleTypedData<T>, boost::is_arithmetic< typename ValueType<T>::type >, boost::mpl::not_< boost::is_same< typename ValueType<T>::type, bool > > > {};
243 template<
typename T >
struct IsNumericBasedSimpleTypedData : boost::mpl::and_< IsSimpleTypedData<T>, boost::is_arithmetic< typename T::BaseType >, boost::mpl::not_< boost::is_same< typename T::BaseType, bool > > > {};
246 template<
typename T >
struct IsNumericTypedData : boost::mpl::or_< IsNumericSimpleTypedData<T>, IsNumericVectorTypedData<T> > {};
249 template<
typename T >
struct IsNumericBasedTypedData : boost::mpl::or_< IsNumericBasedSimpleTypedData<T>, IsNumericBasedVectorTypedData<T> > {};
253 template<
typename T,
template<
typename>
class Pred >
struct IsInterpolableHelper : Pred<T> {};
254 template<
typename T,
template<
typename>
class Pred >
struct IsInterpolableHelper<
TransformationMatrix< T >, Pred > : IsInterpolableHelper<T, Pred> {};
255 template<
typename T,
template<
typename>
class Pred >
struct IsInterpolableHelper<
Imath::Quat< T >, Pred > : IsInterpolableHelper<T, Pred> {};
256 template<
typename T,
template<
typename>
class Pred >
struct IsInterpolableHelper<
Imath::Vec2< T >, Pred > : IsInterpolableHelper<T, Pred> {};
257 template<
typename T,
template<
typename>
class Pred >
struct IsInterpolableHelper<
Imath::Vec3< T >, Pred > : IsInterpolableHelper<T, Pred> {};
258 template<
typename T,
template<
typename>
class Pred >
struct IsInterpolableHelper<
Imath::Color3< T >, Pred > : IsInterpolableHelper<T, Pred> {};
259 template<
typename T,
template<
typename>
class Pred >
struct IsInterpolableHelper<
Imath::Color4< T >, Pred > : IsInterpolableHelper<T, Pred> {};
260 template<
typename T,
template<
typename>
class Pred >
struct IsInterpolableHelper<
Imath::Box< T >, Pred > : IsInterpolableHelper<T, Pred> {};
261 template<
typename T,
template<
typename>
class Pred >
struct IsInterpolableHelper<
Imath::Matrix44< T >, Pred > : IsInterpolableHelper<T, Pred> {};
262 template<
typename T,
template<
typename>
class Pred >
struct IsInterpolableHelper<
std::vector< T >, Pred > : IsInterpolableHelper<T, Pred> {};
263 template<
typename T,
template<
typename>
class Pred >
struct IsInterpolableHelper< TypedData< T >, Pred > : IsInterpolableHelper<T, Pred> {};
264 template<
typename T,
template<
typename>
class Pred >
struct IsInterpolableHelper< GeometricTypedData< T >, Pred > : IsInterpolableHelper<T, Pred> {};
265 template<
typename T,
template<
typename>
class Pred >
struct IsInterpolableHelper< const T, Pred > : IsInterpolableHelper<T, Pred> {};
271 template<
typename T >
struct IsInterpolable : Detail::IsInterpolableHelper<T, boost::is_arithmetic > {};
278 template<
typename T >
struct IsInterpolableTypedData : boost::mpl::and_< IsTypedData<T>, IsInterpolable< typename ValueType<T>::type > > {};
284 template<
typename T >
struct IsInterpolableVectorTypedData : boost::mpl::and_< IsVectorTypedData<T>, IsInterpolable< typename VectorValueType<T>::type > > {};
296 template<
typename T,
typename U =
void >
struct IsSpline :
public boost::false_type {};
297 template<
typename T,
typename U>
struct IsSpline<
Spline<T, U> > :
public boost::true_type {};
298 template<
typename T,
typename U>
struct IsSpline< const
Spline<T, U> > :
public boost::true_type {};
301 template<
typename T >
struct IsSplineTypedData : boost::mpl::and_< IsTypedData<T>, IsSpline< typename ValueType<T>::type > > {};
308 #endif // IE_CORE_TYPETRAITS_H
Definition: GeometricTypedData.h:76
Definition: TypeTraits.h:271
IsColor.
Definition: TypeTraits.h:186
IsVec2TypedData.
Definition: TypeTraits.h:207
IsBox.
Definition: TypeTraits.h:194
IsFloatVec3.
Definition: TypeTraits.h:156
IsMatrixTypedData.
Definition: TypeTraits.h:204
IsVecVectorTypedData.
Definition: TypeTraits.h:228
Definition: MStringLess.h:40
IsVec2.
Definition: TypeTraits.h:162
IsMatrix.
Definition: TypeTraits.h:148
IsVec3TypedData.
Definition: TypeTraits.h:216
IsVec3.
Definition: TypeTraits.h:151
IsStrictlyInterpolableSimpleTypedData.
Definition: TypeTraits.h:293
Definition: TypedData.h:64
IsFloatVec2.
Definition: TypeTraits.h:167
IsTypedData.
Definition: TypeTraits.h:113
IsInterpolableSimpleTypedData.
Definition: TypeTraits.h:290
IsNumericBasedVectorTypedData - true if the data holds a vector of types where BaseType is numeric...
Definition: TypeTraits.h:234
IsNumericTypedData.
Definition: TypeTraits.h:246
IsVecTypedData.
Definition: TypeTraits.h:225
IsInterpolableTypedData.
Definition: TypeTraits.h:278
IsInterpolableVectorTypedData.
Definition: TypeTraits.h:284
HasValueType.
Definition: TypeTraits.h:69
IsColor3.
Definition: TypeTraits.h:176
IsNumericBasedTypedData.
Definition: TypeTraits.h:249
HasVectorValueType.
Definition: TypeTraits.h:75
IsGeometricTypedData.
Definition: TypeTraits.h:119
IsSplineTypedData.
Definition: TypeTraits.h:301
IsQuat.
Definition: TypeTraits.h:189
Definition: TypeTraits.h:275
IsVec2VectorTypedData.
Definition: TypeTraits.h:210
IsMatrix33.
Definition: TypeTraits.h:138
IsVec.
Definition: TypeTraits.h:173
IsVectorTypedData.
Definition: TypeTraits.h:124
IsFloatVec3VectorTypedData.
Definition: TypeTraits.h:222
IsSimpleTypedData.
Definition: TypeTraits.h:130
HasBaseType.
Definition: TypeTraits.h:81
IsStrictlyInterpolableTypedData.
Definition: TypeTraits.h:281
IsColor4.
Definition: TypeTraits.h:181
IsFloatVectorTypedData.
Definition: TypeTraits.h:237
IsSpline.
Definition: TypeTraits.h:296
IsFloatVec2VectorTypedData.
Definition: TypeTraits.h:213
IsNumericVectorTypedData.
Definition: TypeTraits.h:231
IsVec3VectorTypedData.
Definition: TypeTraits.h:219
IsNumericBasedSimpleTypedData - true if the data is simple and BaseType is numeric.
Definition: TypeTraits.h:243
IsStrictlyInterpolableVectorTypedData.
Definition: TypeTraits.h:287
This namespace contains all components of the core library.
Definition: AddSmoothSkinningInfluencesOp.h:43
IsMatrix44.
Definition: TypeTraits.h:143
IsNumericSimpleTypedData.
Definition: TypeTraits.h:240