ML Reference
mlStdTypeInfos.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef ML_STD_TYPE_INFOS_H
14#define ML_STD_TYPE_INFOS_H
15
19
20// ML-includes
21#include "mlErrorMacros.h"
22#include "mlErrorOutput.h"
23#include "mlInitSystemML.h"
24#include "mlTypeDefTraits.h"
25#include "mlTypeTraits.h"
26
27#include <algorithm>
28#include <cmath>
29
30ML_START_NAMESPACE
31
34
35//--------------------------------------------------------------------------------------
37//--------------------------------------------------------------------------------------
38template <typename VTYP>
40{
41
42public:
43
46 static inline const char *typeName(MLint8 *) { static const char name[]="int8"; return name; }
47 static inline const char *typeName(MLuint8 *) { static const char name[]="unsigned int8"; return name; }
48 static inline const char *typeName(MLint16 *) { static const char name[]="int16"; return name; }
49 static inline const char *typeName(MLuint16 *) { static const char name[]="unsigned int16"; return name; }
50 static inline const char *typeName(MLint32 *) { static const char name[]="int32"; return name; }
51 static inline const char *typeName(MLuint32 *) { static const char name[]="unsigned int32"; return name; }
52 static inline const char *typeName(MLfloat *) { static const char name[]="float"; return name; }
53 static inline const char *typeName(MLdouble *) { static const char name[]="double"; return name; }
54 static inline const char *typeName(MLint64 *) { static const char name[]="int64"; return name; }
55 static inline const char *typeName(MLuint64 *) { static const char name[]="unsigned int64"; return name; }
57
58protected:
60 static const VTYP _typeMin;
61
63 static const VTYP _typeMax;
64
66 static const VTYP _typeDefault;
67
69 static const char _typeInfoString[_ML_STD_SLEN];
70
84
86 static inline VTYP& value_cast( MLTypeData* v) { return *(reinterpret_cast< VTYP*>(v)); }
87 static inline const VTYP& value_cast(const MLTypeData* v) { return *(reinterpret_cast<const VTYP*>(v)); }
89
92 static inline VTYP castToType(MLdouble v) { return static_cast<VTYP>(floor(v+0.5)); }
93
96 inline void _getGoodCastTos(MLint8, MLuint &num, const char **&typeNames)
97 {
98 num = 5;
99 static const char *v[] =
100 {
101 MLTStdTypeInfos<MLint16 >::typeName(static_cast<MLint16 *>(nullptr)),
102 MLTStdTypeInfos<MLint32 >::typeName(static_cast<MLint32 *>(nullptr)),
103 MLTStdTypeInfos<MLfloat >::typeName(static_cast<MLfloat *>(nullptr)),
104 MLTStdTypeInfos<MLdouble >::typeName(static_cast<MLdouble *>(nullptr)),
105 MLTStdTypeInfos<MLint64 >::typeName(static_cast<MLint64 *>(nullptr))
106 };
107 typeNames = v;
108 }
109
110 inline void _getGoodCastTos(MLuint8, MLuint &num, const char **&typeNames)
111 {
112 num = 8;
113 static const char *v[] =
114 {
115 MLTStdTypeInfos<MLint16 >::typeName(static_cast<MLint16 *>(nullptr)),
116 MLTStdTypeInfos<MLuint16 >::typeName(static_cast<MLuint16 *>(nullptr)),
117 MLTStdTypeInfos<MLint32 >::typeName(static_cast<MLint32 *>(nullptr)),
118 MLTStdTypeInfos<MLuint32 >::typeName(static_cast<MLuint32 *>(nullptr)),
119 MLTStdTypeInfos<MLfloat >::typeName(static_cast<MLfloat *>(nullptr)),
120 MLTStdTypeInfos<MLdouble >::typeName(static_cast<MLdouble *>(nullptr)),
121 MLTStdTypeInfos<MLint64 >::typeName(static_cast<MLint64 *>(nullptr)),
122 MLTStdTypeInfos<MLuint64 >::typeName(static_cast<MLuint64 *>(nullptr))
123 };
124 typeNames = v;
125 }
126
127 inline void _getGoodCastTos(MLint16, MLuint &num, const char **&typeNames)
128 {
129 num = 4;
130 static const char *v[] =
131 {
132 MLTStdTypeInfos<MLint32 >::typeName(static_cast<MLint32 *>(nullptr)),
133 MLTStdTypeInfos<MLfloat >::typeName(static_cast<MLfloat *>(nullptr)),
134 MLTStdTypeInfos<MLdouble >::typeName(static_cast<MLdouble *>(nullptr)),
135 MLTStdTypeInfos<MLint64 >::typeName(static_cast<MLint64 *>(nullptr))
136 };
137 typeNames = v;
138 }
139
140 inline void _getGoodCastTos(MLuint16, MLuint &num, const char **&typeNames)
141 {
142 num = 6;
143 static const char *v[] =
144 {
145 MLTStdTypeInfos<MLint32 >::typeName(static_cast<MLint32 *>(nullptr)),
146 MLTStdTypeInfos<MLuint32 >::typeName(static_cast<MLuint32 *>(nullptr)),
147 MLTStdTypeInfos<MLfloat >::typeName(static_cast<MLfloat *>(nullptr)),
148 MLTStdTypeInfos<MLdouble >::typeName(static_cast<MLdouble *>(nullptr)),
149 MLTStdTypeInfos<MLint64 >::typeName(static_cast<MLint64 *>(nullptr)),
150 MLTStdTypeInfos<MLuint64 >::typeName(static_cast<MLuint64 *>(nullptr))
151 };
152 typeNames = v;
153 }
154
155 inline void _getGoodCastTos(MLint32, MLuint &num, const char **&typeNames)
156 {
157 num = 3;
158 static const char *v[] =
159 {
160 MLTStdTypeInfos<MLfloat >::typeName(static_cast<MLfloat *>(nullptr)),
161 MLTStdTypeInfos<MLdouble >::typeName(static_cast<MLdouble *>(nullptr)),
162 MLTStdTypeInfos<MLint64 >::typeName(static_cast<MLint64 *>(nullptr))
163 };
164 typeNames = v;
165 }
166
167 inline void _getGoodCastTos(MLuint32, MLuint &num, const char **&typeNames)
168 {
169 num = 4;
170 static const char *v[] =
171 {
172 MLTStdTypeInfos<MLfloat >::typeName(static_cast<MLfloat *>(nullptr)),
173 MLTStdTypeInfos<MLdouble >::typeName(static_cast<MLdouble *>(nullptr)),
174 MLTStdTypeInfos<MLint64 >::typeName(static_cast<MLint64 *>(nullptr)),
175 MLTStdTypeInfos<MLuint64 >::typeName(static_cast<MLuint64 *>(nullptr))
176 };
177 typeNames = v;
178 }
179
180 inline void _getGoodCastTos(MLfloat, MLuint &num, const char **&typeNames)
181 {
182 num = 1;
183 static const char *v[] =
184 {
185 MLTStdTypeInfos<MLdouble >::typeName(static_cast<MLdouble *>(nullptr)),
186 };
187 typeNames = v;
188 }
189
190 inline void _getGoodCastTos(MLdouble, MLuint &num, const char **&typeNames)
191 {
192 num = 0;
193 typeNames = nullptr;
194 }
195
196 inline void _getGoodCastTos(MLint64, MLuint &num, const char **&typeNames)
197 {
198 num = 2;
199 static const char *v[] =
200 {
201 MLTStdTypeInfos<MLfloat >::typeName(static_cast<MLfloat *>(nullptr)),
202 MLTStdTypeInfos<MLdouble >::typeName(static_cast<MLdouble *>(nullptr)),
203 };
204 typeNames = v;
205 }
206
207 inline void _getGoodCastTos(MLuint64, MLuint &num, const char **&typeNames)
208 {
209 num = 2;
210 static const char *v[] =
211 {
212 MLTStdTypeInfos<MLfloat >::typeName(static_cast<MLfloat *>(nullptr)),
213 MLTStdTypeInfos<MLdouble >::typeName(static_cast<MLdouble *>(nullptr)),
214 };
215 typeNames = v;
216 }
218
221
225
226public:
227
232 {
233 if (_numInstances > 0)
234 {
235 ML_PRINT_FATAL_ERROR("MLTStdTypeInfos", ML_PROGRAMMING_ERROR, "Too many instances of MLTStdTypeInfos created.");
237 }
238 _numInstances++;
239
240 // Save pointer to the one instance of this class.
241 _myInfos = this;
242
245
246 // Determine the type to which this type can be cast without information loss.
247 MLuint numLocalGoodCastTos=0;
248 const char **goodLocalCastTos=nullptr;
249 _getGoodCastTos(static_cast<VTYP>(0), numLocalGoodCastTos, goodLocalCastTos);
250
310 VTYP buf=0;
311 void *addr[1];
312 addr[0] = &buf;
313 MLTypeInfosInit(this,
314 sizeof(VTYP),
315 typeName(static_cast<VTYP*>(nullptr)),
316 _typeMin,
317 _typeMax,
318 reinterpret_cast<const MLTypeData*>(&_typeMin),
319 reinterpret_cast<const MLTypeData*>(&_typeMax),
320 reinterpret_cast<const MLTypeData*>(&_typeDefault),
321 _typeInfoString,
322 true,
324 _rangeAndPrecisionEquiv(static_cast<VTYP>(0)),
325 addr,
326 numLocalGoodCastTos,
327 goodLocalCastTos
328 );
329 }
330
331
332 //-------------------------------------------------------------------------------
333 // Methods to be overloaded:
334 //-------------------------------------------------------------------------------
335
338
340 static char *MLTYPE_getStringValue (const MLTypeData *p) { return MLTypeComponentsToString(_myInfos, p); }
342 static void MLTYPE_setStringValue (const char *s, MLTypeData *r)
343 {
344 if (auto result = MLTypeComponentsFromString(_myInfos, s, reinterpret_cast<const MLTypeData*>(&_typeDefault), r); result != 1)
345 {
347 }
348 }
349
351 static void MLTYPE_setToMinimum (MLTypeData *p) { value_cast(p) = _typeMin; }
353 static void MLTYPE_setToMaximum (MLTypeData *p) { value_cast(p) = _typeMax; }
355 static void MLTYPE_setToDefault (MLTypeData *p) { value_cast(p) = _typeDefault; }
357 static MLdouble MLTYPE_getComponent (const MLTypeData *p, size_t /*n*/) { return static_cast<MLdouble>(value_cast(p)); }
359 static void MLTYPE_setComponent (MLTypeData *p, size_t /*n*/, MLdouble v) { value_cast(p) = static_cast<VTYP>(v); }
361 static void MLTYPE_copy (const MLTypeData *source, MLTypeData *dest) { value_cast(dest) = value_cast(source); }
363 static void MLTYPE_arrayCopy (const MLTypeData *source, MLTypeData *dest, size_t size) { memcpy(dest, source, sizeof(VTYP)*size); }
365 static void MLTYPE_arrayCopyWithStrides (const MLTypeData *source, MLssize_t sourceStride, MLTypeData *dest, MLssize_t destStride, size_t size)
366 {
367 for (size_t i=0;i<size;i++)
368 {
369 value_cast(dest) = value_cast(source);
370 source += sizeof(VTYP)*sourceStride;
371 dest += sizeof(VTYP)*destStride;
372 }
373 }
374
376 static void MLTYPE_arrayFill (const MLTypeData *fillValue, MLTypeData *dest, size_t n)
377 {
378 const VTYP value = value_cast(fillValue);
379 VTYP* arrayPtr = &value_cast(dest);
380
381 // Use memset if 8bit integer is used or if fillValue is 0
382 if (TypeTraits<VTYP>::is8BitInteger || value == 0) {
383 if (arrayPtr){ // Avoid complaining memory checkers in memset if arrayPtr and n is NULL/0.
384 memset(arrayPtr, value, n* sizeof(VTYP) );
385 }
386 } else {
387 for (size_t i = 0; i < n; i++) {
388 *arrayPtr++ = value;
389 }
390 }
391 }
392
394 static bool MLTYPE_castToBool (const MLTypeData *p) { return MLValuesDifferWOM(value_cast(p), static_cast<VTYP>(0)); }
396 static MLint MLTYPE_castToInt (const MLTypeData *p) { return static_cast<MLint>(value_cast(p)); }
398 static MLdouble MLTYPE_castToDouble (const MLTypeData *p) { return static_cast<MLdouble>(value_cast(p)); }
400 static void MLTYPE_castToOtherType(const MLTypeData *myData, const MLTypeInfos *otherInfos, MLTypeData *otherData) { MLTypeCastToOtherType(_myInfos, myData, otherInfos, otherData); }
401
403 static void MLTYPE_castFromInt (MLint p, MLTypeData *q) { value_cast(q) = static_cast<VTYP>(p); }
405 static void MLTYPE_castFromDouble (MLdouble p, MLTypeData *q) { value_cast(q) = static_cast<VTYP>(p); }
407 static void MLTYPE_castFromOtherType (const MLTypeInfos *otherInfos, const MLTypeData *otherData,
408 MLTypeData *myData) { MLTypeCastToOtherType(otherInfos,otherData, _myInfos, myData); }
409
411 static bool MLTYPE_isEqualToType (const MLTypeData *p, const MLTypeData *q) { return MLValuesAreEqualWOM(value_cast(p), value_cast(q)); }
413 static bool MLTYPE_isEqualToTypeWithEpsilon(const MLTypeData *p, const MLTypeData *q, MLdouble eps) { return MLAbs(value_cast(p)-value_cast(q)) < eps; }
414
416 static void MLTYPE_negate (const MLTypeData *p, MLTypeData *q) { value_cast(q) = -value_cast(p); }
417
419 static void MLTYPE_normalize (const MLTypeData * /*p*/, MLTypeData *q) { value_cast(q) = 1; }
420
424 static void MLTYPE_arrayRescale (const MLTypeData* source, MLdouble factor, const MLTypeData* offset, MLTypeData* dest, size_t size) {
425 const VTYP* srcPtr = &value_cast(source);
426 VTYP* destPtr = &value_cast(dest);
427 const VTYP offsetValue = value_cast(offset);
428 for (size_t i = 0; i<size; i++) {
429 *destPtr++ = castToType((*srcPtr++) * factor + offsetValue);
430 }
431 }
432
436 static bool MLTYPE_arrayEqualsValue (const MLTypeData* value, const MLTypeData* buffer, size_t size) {
437 const VTYP constValue = value_cast(value);
438 const VTYP* arrayPtr = &value_cast(buffer);
439 for (size_t i=0; i<size; i++) {
440 if (*arrayPtr++ != constValue) { return false; }
441 }
442 return true;
443 }
444
448 static void MLTYPE_arrayGetMinMax (const MLTypeData* p, size_t s, MLdouble& min, MLdouble& max) {
449
450 const auto *begin = reinterpret_cast<const VTYP *>(p);
451 auto min_max = std::minmax_element(begin, begin + s);
452 min = static_cast<double>(*min_max.first);
453 max = static_cast<double>(*min_max.second);
454 }
455
456
460 static void MLTYPE_interpolate (const MLTypeData* p, const MLTypeData* q, MLdouble r, MLTypeData* t) {
461 value_cast(t) = castToType(value_cast(p) * (1.0-r) + value_cast(q) * r);
462 }
463
465 static void MLTYPE_multWithInt (const MLTypeData *p, MLint q, MLTypeData *r) { value_cast(r) = static_cast<VTYP>(value_cast(p) * q); }
467 static void MLTYPE_multWithDouble (const MLTypeData *p, MLdouble q, MLTypeData *r) { value_cast(r) = static_cast<VTYP>(value_cast(p) * q); }
469 static void MLTYPE_multWithType (const MLTypeData *p, const MLTypeData *q, MLTypeData *r) { value_cast(r) = value_cast(p)*value_cast(q); }
471 static void MLTYPE_multWithOtherType (const MLTypeInfos *otherInfos, const MLTypeData *otherData,
472 const MLTypeData *myData, MLTypeData *r) { MLTypeMultWithOtherType(_myInfos, myData, otherInfos, otherData, r); }
473
475 static void MLTYPE_plusInt (const MLTypeData *p, MLint q, MLTypeData *r) { value_cast(r) = value_cast(p) + q; }
477 static void MLTYPE_plusDouble (const MLTypeData *p, MLdouble q, MLTypeData *r) { value_cast(r) = static_cast<VTYP>(value_cast(p) + q); }
479 static void MLTYPE_plusType (const MLTypeData *p, const MLTypeData *q, MLTypeData *r) { value_cast(r) = value_cast(p) + value_cast(q); }
480
482};
483
484template<> inline MLfloat MLTStdTypeInfos<MLfloat >::castToType(MLdouble v) { return static_cast<MLfloat >(v); }
486
487
488// For unsigned types, implement specialized negations to avoid warnings due to negations of unsigned types. We just copy instead of negating.
489template<> inline void MLTStdTypeInfos<MLuint8 >::MLTYPE_negate (const MLTypeData *p, MLTypeData *q) { value_cast(q) = value_cast(p); }
490template<> inline void MLTStdTypeInfos<MLuint16 >::MLTYPE_negate (const MLTypeData *p, MLTypeData *q) { value_cast(q) = value_cast(p); }
491template<> inline void MLTStdTypeInfos<MLuint32 >::MLTYPE_negate (const MLTypeData *p, MLTypeData *q) { value_cast(q) = value_cast(p); }
492template<> inline void MLTStdTypeInfos<MLuint64 >::MLTYPE_negate (const MLTypeData *p, MLTypeData *q) { value_cast(q) = value_cast(p); }
493
494
495// Member initializations for unspecialized class members.
496template <typename VTYP> const VTYP MLTStdTypeInfos<VTYP>::_typeDefault = VTYP(0);
497template <typename VTYP> MLTypeInfos* MLTStdTypeInfos<VTYP>::_myInfos = nullptr;
498template <typename VTYP> MLint32 MLTStdTypeInfos<VTYP>::_numInstances = 0;
499
500ML_END_NAMESPACE
501
502
503#endif //of __mlStdTypeInfos_H
504
505
506
Template class to register the standard integer classes as voxel types in the ML.
static void MLTYPE_multWithOtherType(const MLTypeInfos *otherInfos, const MLTypeData *otherData, const MLTypeData *myData, MLTypeData *r)
Implements multiplication with another type. Result is written into parameter three.
static void MLTYPE_castToOtherType(const MLTypeData *myData, const MLTypeInfos *otherInfos, MLTypeData *otherData)
Returns the parameter cast to double. Usually implemented by default with function casting component-...
MLDataType _rangeAndPrecisionEquiv(MLuint32)
static VTYP castToType(MLdouble v)
Implements a method that rounds a double value when casting to an integer but does not round when cas...
static void MLTYPE_arrayGetMinMax(const MLTypeData *p, size_t s, MLdouble &min, MLdouble &max)
Gets the mininum and maximum component values from the array in the first argument,...
static bool MLTYPE_arrayEqualsValue(const MLTypeData *value, const MLTypeData *buffer, size_t size)
Checks that the first argument equals all the values given with the second argument (and the size in ...
MLDataType _rangeAndPrecisionEquiv(MLuint64)
void _getGoodCastTos(MLfloat, MLuint &num, const char **&typeNames)
void _getGoodCastTos(MLuint32, MLuint &num, const char **&typeNames)
void _getGoodCastTos(MLuint64, MLuint &num, const char **&typeNames)
static const char * typeName(MLint8 *)
static const char * typeName(MLint16 *)
static void MLTYPE_plusInt(const MLTypeData *p, MLint q, MLTypeData *r)
Implements integer addition to parameter one. Result is written into parameter three.
MLDataType _rangeAndPrecisionEquiv(MLdouble)
MLDataType _rangeAndPrecisionEquiv(MLuint16)
static void MLTYPE_multWithInt(const MLTypeData *p, MLint q, MLTypeData *r)
Implements multiplication with integer. Result is written into parameter three.
MLDataType _rangeAndPrecisionEquiv(MLint32)
static bool MLTYPE_isEqualToType(const MLTypeData *p, const MLTypeData *q)
Returns true if both parameters are equal; otherwise, it returns false.
static const char * typeName(MLuint8 *)
static void MLTYPE_multWithType(const MLTypeData *p, const MLTypeData *q, MLTypeData *r)
Implements multiplication with its own type. Result is written into parameter three.
static void MLTYPE_multWithDouble(const MLTypeData *p, MLdouble q, MLTypeData *r)
Implements multiplication with double. Result is written into parameter three.
static void MLTYPE_setToMinimum(MLTypeData *p)
Sets value to minimum value. Must be implemented.
static void MLTYPE_copy(const MLTypeData *source, MLTypeData *dest)
Copies first parameter to second one.
static const char * typeName(MLint32 *)
static void MLTYPE_setComponent(MLTypeData *p, size_t, MLdouble v)
Sets n-th component from double value. Must be implemented.
void _getGoodCastTos(MLint32, MLuint &num, const char **&typeNames)
static const VTYP _typeMax
Permanent instance of the maximum value.
static bool MLTYPE_isEqualToTypeWithEpsilon(const MLTypeData *p, const MLTypeData *q, MLdouble eps)
Returns true if both parameters are equal within a static epsilon; otherwise, it returns false.
static const char * typeName(MLint64 *)
static MLTypeInfos * _myInfos
Permanent instance of a pointer to the typeInfos used by this class.
static VTYP & value_cast(MLTypeData *v)
Avoid using reinterpret_casts.
void _getGoodCastTos(MLuint8, MLuint &num, const char **&typeNames)
static const char * typeName(MLdouble *)
static void MLTYPE_arrayRescale(const MLTypeData *source, MLdouble factor, const MLTypeData *offset, MLTypeData *dest, size_t size)
Scales the values from the first parameter with the second parameter and offsets it with the value fr...
static const VTYP _typeMin
Permanent instance of the minimum value.
static void MLTYPE_setStringValue(const char *s, MLTypeData *r)
Converts the string s to a value and writes result into r. Use MLTypeComponentsFromString() if possib...
static char * MLTYPE_getStringValue(const MLTypeData *p)
Returns the value as string to be freed by MLFree(). Use MLTypeComponentsToString() if possible.
MLDataType _rangeAndPrecisionEquiv(MLfloat)
static const char * typeName(MLuint16 *)
MLDataType _rangeAndPrecisionEquiv(MLuint8)
static MLdouble MLTYPE_getComponent(const MLTypeData *p, size_t)
Returns n-th component as double value. Must be implemented.
void _getGoodCastTos(MLdouble, MLuint &num, const char **&typeNames)
static bool MLTYPE_castToBool(const MLTypeData *p)
Returns the parameter cast to bool. Typically, it returns false if it is identically to the default e...
static void MLTYPE_setToDefault(MLTypeData *p)
Sets value to default value. Must be implemented.
static void MLTYPE_interpolate(const MLTypeData *p, const MLTypeData *q, MLdouble r, MLTypeData *t)
Interpolates linearly between the first and the second parameter, at the position given by the third ...
static void MLTYPE_castFromOtherType(const MLTypeInfos *otherInfos, const MLTypeData *otherData, MLTypeData *myData)
Casts the first parameters to data type and writes it into the second parameter.
static MLint32 _numInstances
The number of instances of this class.
static void MLTYPE_negate(const MLTypeData *p, MLTypeData *q)
Negates the value. See also the specialized negations for unsigned types that leave the value unchang...
void _getGoodCastTos(MLint64, MLuint &num, const char **&typeNames)
static MLint MLTYPE_castToInt(const MLTypeData *p)
Returns the parameter cast to integer. Often the integer cast of the first component.
static void MLTYPE_castFromDouble(MLdouble p, MLTypeData *q)
Casts the first parameters to data type and writes it into the second parameter.
static void MLTYPE_plusType(const MLTypeData *p, const MLTypeData *q, MLTypeData *r)
Implements parameter two addition to parameter one. Result is written into parameter three.
void _getGoodCastTos(MLuint16, MLuint &num, const char **&typeNames)
static const char * typeName(MLfloat *)
static void MLTYPE_arrayCopy(const MLTypeData *source, MLTypeData *dest, size_t size)
Copies s elements from the first parameter to the second one.
static void MLTYPE_castFromInt(MLint p, MLTypeData *q)
Casts the first parameters to data type and writes it into the second parameter.
static const VTYP _typeDefault
Permanent instance of the default value.
static void MLTYPE_plusDouble(const MLTypeData *p, MLdouble q, MLTypeData *r)
Implements double addition to parameter one. Result is written into parameter three.
static const char * typeName(MLuint64 *)
static const char * typeName(MLuint32 *)
static void MLTYPE_arrayFill(const MLTypeData *fillValue, MLTypeData *dest, size_t n)
Copies the first parameter to the second one as often as given in the third parameter.
MLTStdTypeInfos()
Constructor.
MLDataType _rangeAndPrecisionEquiv(MLint64)
void _getGoodCastTos(MLint16, MLuint &num, const char **&typeNames)
static const VTYP & value_cast(const MLTypeData *v)
static void MLTYPE_normalize(const MLTypeData *, MLTypeData *q)
Normalizes the type.
static void MLTYPE_setToMaximum(MLTypeData *p)
Sets value to minimum value. Must be implemented.
static void MLTYPE_arrayCopyWithStrides(const MLTypeData *source, MLssize_t sourceStride, MLTypeData *dest, MLssize_t destStride, size_t size)
Same as MLTYPE_arrayCopy, but allows to specify stride values for source and destination.
void _getGoodCastTos(MLint8, MLuint &num, const char **&typeNames)
static MLdouble MLTYPE_castToDouble(const MLTypeData *p)
Returns the parameter cast to double. Often the integer cast of the first component.
MLDataType _rangeAndPrecisionEquiv(MLint8)
MLDataType _rangeAndPrecisionEquiv(MLint16)
MLint32 MLDataType
MLDataType.
Definition mlTypeDefs.h:595
DT MLAbs(const DT val)
Defines a templated MLAbs version to circumvent fabs ambiguities on different platforms.
bool MLValuesDifferWOM(MLint8 a, MLint8 b)
Returns true if values differ; otherwise, it returns false.
bool MLValuesAreEqualWOM(MLint8 a, MLint8 b)
Returns true if values a and b are equal; otherwise, it returns false.
@ MLuint8Type
Enumerator for the unsigned 8-bit ML integer type.
Definition mlTypeDefs.h:620
@ MLuint32Type
Enumerator for the unsigned 32-bit ML integer type.
Definition mlTypeDefs.h:624
@ MLfloatType
Enumerator for the signed 32-bit ML floating point type.
Definition mlTypeDefs.h:625
@ MLuint16Type
Enumerator for the unsigned 16-bit ML integer type.
Definition mlTypeDefs.h:622
@ MLint64Type
Enumerator for the signed 64-bit ML integer type.
Definition mlTypeDefs.h:627
@ MLint16Type
Enumerator for the signed 16-bit ML integer type.
Definition mlTypeDefs.h:621
@ MLint32Type
Enumerator for the signed 32-bit ML integer type.
Definition mlTypeDefs.h:623
@ MLdoubleType
Enumerator for the signed 64-bit ML floating point type.
Definition mlTypeDefs.h:626
@ MLint8Type
Enumerator for the signed 8-bit ML integer type.
Definition mlTypeDefs.h:619
@ MLuint64Type
Enumerator for the unsigned 64-bit ML integer type.
Definition mlTypeDefs.h:628
#define ML_PROGRAMMING_ERROR
A case occurred that should not appear and there are a variety of reasons, typically it is a programm...
Definition mlTypeDefs.h:787
#define ML_PRINT_FATAL_ERROR(FUNC_NAME, REASON, HANDLING)
Like ML_PRINT_FATAL_ERROR_DUMP(FUNC_NAME, REASON, HANDLING, RT_OBJ) without a runtime object to be du...
MLEXPORT MLint32 MLTypeComponentsFromString(const MLTypeInfos *infos, const char *stringData, const MLTypeData *defaultValue, MLTypeData *data)
Converts a string of a data type instance to instance data, i.e., similar to sscanf.
MLEXPORT void MLTypeMultWithOtherType(const MLTypeInfos *myInfos, const MLTypeData *myData, const MLTypeInfos *otherInfos, const MLTypeData *otherData, MLTypeData *targetData)
Casts another data element otherData with attributes given by otherInfos to a local buffer of a type ...
MLEXPORT void MLTypeCastToOtherType(const MLTypeInfos *otherInfos, const MLTypeData *otherData, const MLTypeInfos *myInfos, MLTypeData *myData)
Converts a data instance referenced by otherData of a type specified by otherInfos to another data in...
MLEXPORT char * MLTypeComponentsToString(const MLTypeInfos *infos, const MLTypeData *data)
Converts a data type instance to a string.
MLEXPORT MLint32 MLTypeInfosInit(MLTypeInfos *infos, size_t typeSize, const char *name, MLdouble dblMin, MLdouble dblMax, const MLTypeData *typeMinPtr, const MLTypeData *typeMaxPtr, const MLTypeData *typeDefaultPtr, const char *typeStructInfo, MLint32 isScalarType, MLTypeGroup typeGroup, MLDataType rangeAndPrecisionEquiv, void **componentAddresses, size_t numGoodCastTos, const char **goodCastTos)
Initialization of the main properties of MLTypeInfos.
#define ML_HARAKIRI
This logs the fatal error with file and line number.
#define MLEXPORT
To export symbols from a DLL/shared object, we need to mark them with the MLEXPORT symbol.
UINT64 MLuint64
Introduce platform-independent 64-bit unsigned integer type.
Definition mlTypeDefs.h:424
#define ML_TYPE_ASSIGN_FUNCTION_POINTERS()
unsigned int MLuint32
Definition mlTypeDefs.h:184
unsigned char MLuint8
Definition mlTypeDefs.h:108
MLuint64 MLuint
An unsigned ML integer type with at least 64 bits used for index calculations on very large images ev...
Definition mlTypeDefs.h:505
double MLdouble
Definition mlTypeDefs.h:216
unsigned char MLTypeData
This is the pointer type used to point to the data of MLType data instances.
@ MLScalarTypeGroup
unsigned short MLuint16
Definition mlTypeDefs.h:141
signed short MLint16
Definition mlTypeDefs.h:124
char MLint8
Definition mlTypeDefs.h:96
INT64 MLint64
Include 64-bit integer support for Windows or Unix.
Definition mlTypeDefs.h:411
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition mlTypeDefs.h:489
SSIZE_T MLssize_t
The signed ML size type that is a signed 32-bit size_t on 32-bit platforms and 64-bit one on 64-bit p...
Definition mlTypeDefs.h:565
signed int MLint32
Definition mlTypeDefs.h:160
float MLfloat
Definition mlTypeDefs.h:200
double floor(T value)
void ML_UTILS_EXPORT logTypeComponentsFromStringError(const char *function)
const MLint _ML_STD_SLEN
Length of strings for component descriptions and class names.
Structure containing all data type features and pointers to all functions needed to implement operati...
const char * name
Pointer to the data type name.
TypeTraits for scalar ML datatypes.