MeVisLab Toolbox 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 
30 ML_START_NAMESPACE
31 
34 
35 //--------------------------------------------------------------------------------------
37 //--------------------------------------------------------------------------------------
38 template <typename VTYP>
40 {
41 
42 public:
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 
58 protected:
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 
226 public:
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 casted 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  {
346  logTypeComponentsFromStringError(__FUNCTION__);
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 
484 template<> inline MLfloat MLTStdTypeInfos<MLfloat >::castToType(MLdouble v) { return static_cast<MLfloat >(v); }
485 template<> inline MLdouble MLTStdTypeInfos<MLdouble >::castToType(MLdouble v) { return v; }
486 
487 
488 // For unsigned types implement specialized negations to avoid warning due to negations of unsigned types. We just copy instead of negating.
489 template<> inline void MLTStdTypeInfos<MLuint8 >::MLTYPE_negate (const MLTypeData *p, MLTypeData *q) { value_cast(q) = value_cast(p); }
490 template<> inline void MLTStdTypeInfos<MLuint16 >::MLTYPE_negate (const MLTypeData *p, MLTypeData *q) { value_cast(q) = value_cast(p); }
491 template<> inline void MLTStdTypeInfos<MLuint32 >::MLTYPE_negate (const MLTypeData *p, MLTypeData *q) { value_cast(q) = value_cast(p); }
492 template<> 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.
496 template <typename VTYP> const VTYP MLTStdTypeInfos<VTYP>::_typeDefault = VTYP(0);
497 template <typename VTYP> MLTypeInfos* MLTStdTypeInfos<VTYP>::_myInfos = nullptr;
498 template <typename VTYP> MLint32 MLTStdTypeInfos<VTYP>::_numInstances = 0;
499 
500 ML_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)
Implement multiplication with another type. Result written into parameter three.
static void MLTYPE_castToOtherType(const MLTypeData *myData, const MLTypeInfos *otherInfos, MLTypeData *otherData)
Return parameter casted to double. Usually implemented by default with function casting component wis...
MLDataType _rangeAndPrecisionEquiv(MLuint32)
static VTYP castToType(MLdouble v)
implement method that rounds a double value when casting to integer, but doesn't round when casting t...
static void MLTYPE_arrayGetMinMax(const MLTypeData *p, size_t s, MLdouble &min, MLdouble &max)
Get 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)
Check that the first argument equals all the values given with the second argument (and the size in t...
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 void MLTYPE_plusInt(const MLTypeData *p, MLint q, MLTypeData *r)
Implement integer addition to parameter one. Result written into parameter three.
MLDataType _rangeAndPrecisionEquiv(MLdouble)
MLDataType _rangeAndPrecisionEquiv(MLuint16)
static void MLTYPE_multWithInt(const MLTypeData *p, MLint q, MLTypeData *r)
Implement multiplication with integer. Result written into parameter three.
MLDataType _rangeAndPrecisionEquiv(MLint32)
static const char * typeName(MLfloat *)
static bool MLTYPE_isEqualToType(const MLTypeData *p, const MLTypeData *q)
Return true if both parameters are equal, otherwise false.
static void MLTYPE_multWithType(const MLTypeData *p, const MLTypeData *q, MLTypeData *r)
Implement multiplication with its own type. Result written into parameter three.
static void MLTYPE_multWithDouble(const MLTypeData *p, MLdouble q, MLTypeData *r)
Implement multiplication with double. Result written into parameter three.
static void MLTYPE_setToMinimum(MLTypeData *p)
Sets value to minimum value. Must be implemented.
static const char * typeName(MLdouble *)
static void MLTYPE_copy(const MLTypeData *source, MLTypeData *dest)
Copy first parameter to second one.
static const char * typeName(MLuint8 *)
static void MLTYPE_setComponent(MLTypeData *p, size_t, MLdouble v)
Sets n-th component from double value. Must be implemented.
static const char * typeName(MLint8 *)
static const char * typeName(MLint32 *)
void _getGoodCastTos(MLint32, MLuint &num, const char **&typeNames)
static const VTYP _typeMax
Permanent instance of the maximum value.
static const char * typeName(MLuint32 *)
static bool MLTYPE_isEqualToTypeWithEpsilon(const MLTypeData *p, const MLTypeData *q, MLdouble eps)
Returns true if both parameters are equal within a static epsilon, otherwise false.
static MLTypeInfos * _myInfos
Permanent instance of a pointer to the typeInfos used by this class.
void _getGoodCastTos(MLuint8, MLuint &num, const char **&typeNames)
static void MLTYPE_arrayRescale(const MLTypeData *source, MLdouble factor, const MLTypeData *offset, MLTypeData *dest, size_t size)
Scale the values from the first parameter with the second parameter and offset it with the value from...
static const VTYP _typeMin
Permanent instance of the minimum value.
static void MLTYPE_setStringValue(const char *s, MLTypeData *r)
Convert string s to value and write result into r. Use MLTypeComponentsFromString() if possible.
MLDataType _rangeAndPrecisionEquiv(MLfloat)
static VTYP & value_cast(MLTypeData *v)
avoid ugly reinterpret_casts
MLDataType _rangeAndPrecisionEquiv(MLuint8)
static MLdouble MLTYPE_getComponent(const MLTypeData *p, size_t)
Gets n-th component as double value. Must be implemented.
void _getGoodCastTos(MLdouble, MLuint &num, const char **&typeNames)
static bool MLTYPE_castToBool(const MLTypeData *p)
Return parameter casted to bool. Typically false when it is identically to the default element,...
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)
Interpolate linearly between the first and the second parameter, at the position given by the third p...
static char * MLTYPE_getStringValue(const MLTypeData *p)
Return value as string to be freed by MLFree(). Use MLTypeComponentsToString() if possible.
static void MLTYPE_castFromOtherType(const MLTypeInfos *otherInfos, const MLTypeData *otherData, MLTypeData *myData)
Cast first parameters to data type and write it into second parameter.
static MLint32 _numInstances
Number of instances of this class.
static const VTYP & value_cast(const MLTypeData *v)
static void MLTYPE_negate(const MLTypeData *p, MLTypeData *q)
Negate the value. See also the specialized negations for unsigned types which leave value unchanged.
void _getGoodCastTos(MLint64, MLuint &num, const char **&typeNames)
static MLint MLTYPE_castToInt(const MLTypeData *p)
Return parameter casted to integer. Often the integer cast of the first component.
static void MLTYPE_castFromDouble(MLdouble p, MLTypeData *q)
Cast first parameters to data type and write it into second parameter.
static const char * typeName(MLuint16 *)
static void MLTYPE_plusType(const MLTypeData *p, const MLTypeData *q, MLTypeData *r)
Implement parameter two addition to parameter one. Result written into parameter three.
void _getGoodCastTos(MLuint16, MLuint &num, const char **&typeNames)
static void MLTYPE_arrayCopy(const MLTypeData *source, MLTypeData *dest, size_t size)
Copy s elements from first parameter to second one.
static void MLTYPE_castFromInt(MLint p, MLTypeData *q)
Cast first parameters to data type and write it into second parameter.
static const VTYP _typeDefault
Permanent instance of the default value.
static void MLTYPE_plusDouble(const MLTypeData *p, MLdouble q, MLTypeData *r)
Implement double addition to parameter one. Result written into parameter three.
static const char * typeName(MLuint64 *)
static void MLTYPE_arrayFill(const MLTypeData *fillValue, MLTypeData *dest, size_t n)
Copy first parameter to second one as often as given in the third parameter.
MLTStdTypeInfos()
Constructor.
MLDataType _rangeAndPrecisionEquiv(MLint64)
void _getGoodCastTos(MLint16, MLuint &num, const char **&typeNames)
static void MLTYPE_normalize(const MLTypeData *, MLTypeData *q)
Normalize type.
static void MLTYPE_setToMaximum(MLTypeData *p)
Sets value to minimum value. Must be implemented.
static const char * typeName(MLint64 *)
static void MLTYPE_arrayCopyWithStrides(const MLTypeData *source, MLssize_t sourceStride, MLTypeData *dest, MLssize_t destStride, size_t size)
Same as above, 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)
Return parameter casted to double. Often the integer cast of the first component.
MLDataType _rangeAndPrecisionEquiv(MLint8)
static const char * typeName(MLint16 *)
MLDataType _rangeAndPrecisionEquiv(MLint16)
MLint32 MLDataType
MLDataType.
Definition: mlTypeDefs.h:684
DT MLAbs(const DT val)
Defines templated MLAbs version to circumvent fabs ambiguities on different platforms.
bool MLValuesDifferWOM(MLint8 a, MLint8 b)
Returns true if values differ, otherwise false.
bool MLValuesAreEqualWOM(MLint8 a, MLint8 b)
Returns true if values a and b are equal, otherwise false.
@ MLuint8Type
Enumerator for the unsigned 8 bit ML integer type.
Definition: mlTypeDefs.h:723
@ MLuint32Type
Enumerator for the unsigned 32 bit ML integer type.
Definition: mlTypeDefs.h:727
@ MLfloatType
Enumerator for the signed 32 bit ML floating point type.
Definition: mlTypeDefs.h:728
@ MLuint16Type
Enumerator for the unsigned 16 bit ML integer type.
Definition: mlTypeDefs.h:725
@ MLint64Type
Enumerator for the signed 64 bit ML integer type.
Definition: mlTypeDefs.h:730
@ MLint16Type
Enumerator for the signed 16 bit ML integer type.
Definition: mlTypeDefs.h:724
@ MLint32Type
Enumerator for the signed 32 bit ML integer type.
Definition: mlTypeDefs.h:726
@ MLdoubleType
Enumerator for the signed 64 bit ML floating point type.
Definition: mlTypeDefs.h:729
@ MLint8Type
Enumerator for the signed 8 bit ML integer type.
Definition: mlTypeDefs.h:722
@ MLuint64Type
Enumerator for the unsigned 64 bit ML integer type.
Definition: mlTypeDefs.h:731
#define ML_PROGRAMMING_ERROR
A case occurred which should not appear and here are a variety of reasons, typically it is a programm...
Definition: mlTypeDefs.h:890
#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., like an 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:513
#define ML_TYPE_ASSIGN_FUNCTION_POINTERS()
Definition: mlTypeDefs.h:1700
unsigned int MLuint32
Definition: mlTypeDefs.h:191
unsigned char MLuint8
Definition: mlTypeDefs.h:115
MLuint64 MLuint
An unsigned ML integer type with at least 64 bits used for index calculations on very large images ev...
Definition: mlTypeDefs.h:594
double MLdouble
Definition: mlTypeDefs.h:223
unsigned char MLTypeData
This is the pointer type used to point to the data of MLType data instances.
Definition: mlTypeDefs.h:1436
@ MLScalarTypeGroup
Definition: mlTypeDefs.h:1454
unsigned short MLuint16
Definition: mlTypeDefs.h:148
signed short MLint16
Definition: mlTypeDefs.h:131
char MLint8
Definition: mlTypeDefs.h:103
INT64 MLint64
Include 64 bit integer support for Windows or Unix.
Definition: mlTypeDefs.h:500
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition: mlTypeDefs.h:578
SSIZE_T MLssize_t
The signed ML size type which is a signed 32 bit size_t on 32 bit platforms and 64 bit one on 64 bit ...
Definition: mlTypeDefs.h:654
signed int MLint32
Definition: mlTypeDefs.h:167
float MLfloat
Definition: mlTypeDefs.h:207
boost::graph_traits< ml_graph_ptr >::vertex_descriptor source(graph_traits< ml_graph_ptr >::edge_descriptor e, const ml_graph_ptr)
Returns the vertex descriptor for u of the edge (u,v) represented by e.
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...
Definition: mlTypeDefs.h:1466
const char * name
Pointer to the data type name.
Definition: mlTypeDefs.h:1485
TypeTraits for scalar ML Datatypes.
Definition: mlTypeTraits.h:51