itom  3.0.0
param.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2016, Institut fuer Technische Optik (ITO),
5  Universitaet Stuttgart, Germany
6 
7  This file is part of itom and its software development toolkit (SDK).
8 
9  itom is free software; you can redistribute it and/or modify it
10  under the terms of the GNU Library General Public Licence as published by
11  the Free Software Foundation; either version 2 of the Licence, or (at
12  your option) any later version.
13 
14  In addition, as a special exception, the Institut fuer Technische
15  Optik (ITO) gives you certain additional rights.
16  These rights are described in the ITO LGPL Exception version 1.0,
17  which can be found in the file LGPL_EXCEPTION.txt in this package.
18 
19  itom is distributed in the hope that it will be useful, but
20  WITHOUT ANY WARRANTY; without even the implied warranty of
21  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
22  General Public Licence for more details.
23 
24  You should have received a copy of the GNU Library General Public License
25  along with itom. If not, see <http://www.gnu.org/licenses/>.
26 *********************************************************************** */
27 
28 #ifndef PARAM_H
29 #define PARAM_H
30 
31 /* includes */
32 
33 #include "commonGlobal.h"
34 #include "typeDefs.h"
35 #include "byteArray.h"
36 #include "retVal.h"
37 #include "paramMeta.h"
38 
39 #include <string.h>
40 #include <stdlib.h>
41 #include <stdio.h>
42 #include <stdarg.h>
43 #include <limits>
44 #include <stdexcept>
45 
46 /* definition and macros */
47 /* global variables (avoid) */
48 /* content */
49 
50 namespace ito
51 {
52  class Param;
53  class ParamHelper;
54  template<typename _Tp> struct ItomParamHelper;
55 
56  const uint32 paramFlagMask = 0xFFFF0000;
57  const uint32 paramTypeMask = 0x0000FFFF;
58 
60  struct ITOMCOMMON_EXPORT complex128_
61  {
62  complex128_(float64 r, float64 i) : real(r), imag(i) {};
63  float64 real;
64  float64 imag;
65  };
66 
67  class ITOMCOMMON_EXPORT ParamBase
68  {
69  protected:
70  uint32 m_type;
72 
73  void inOutCheck();
74 
75  static inline uint32 typeFilter(uint32 type) { return type & paramTypeMask; }
76 
77  private:
79  ito::int32 m_iVal;
80  char *m_cVal;
81 
82  public:
83  enum Type {
84  //flags (bit 17-32)
85  NoAutosave = 0x010000,
86  Readonly = 0x020000, // this flag is not used inside Param but you can check for it
87  In = 0x040000,
88  Out = 0x080000,
89  NotAvailable = 0x100000,
90 
91  //type (bit 1-16)
92  Pointer = 0x000001,
93  Char = 0x000002,
94  Int = 0x000004,
95  Double = 0x000008,
96  Complex = 0x000400,
97  DObjPtr = 0x000010 | Pointer | NoAutosave,
98  String = 0x000020 | Pointer,
99  HWRef = 0x000040 | Pointer | NoAutosave,
100  CharArray = Char | Pointer,
101  IntArray = Int | Pointer,
102  DoubleArray = Double | Pointer,
103  ComplexArray = Complex | Pointer,
104  PointCloudPtr = 0x000080 | Pointer | NoAutosave,
105  PointPtr = 0x000100 | Pointer | NoAutosave,
106  PolygonMeshPtr = 0x000200 | Pointer | NoAutosave
107  };
108 
109 
110  //--------------------------------------------------------------------------------------------
111  // CONSTRUCTORS, COPY-CONSTRUCTOR, DESTRUCTOR
112  //--------------------------------------------------------------------------------------------
114  ParamBase() : m_type(0), m_name(NULL), m_dVal(0.0, 0.0), m_iVal(0), m_cVal(NULL) {}
115  ParamBase(const ByteArray &name); // type-less ParamBase with name only
116  ParamBase(const ByteArray &name, const uint32 type); // constructor with type and name
117  ParamBase(const ByteArray &name, const uint32 type, const char *val); // constructor with name and type and char val
118  ParamBase(const ByteArray &name, const uint32 type, const float64 val); // constructor with name and type and float64 val
119  ParamBase(const ByteArray &name, const uint32 type, const int32 val); // constructor with name and type and int32 val
120  ParamBase(const ByteArray &name, const uint32 type, const complex128 val); // constructor with name and type and complex128 val
121  ParamBase(const ByteArray &name, const uint32 type, const uint32 size, const char *values); // array constructor with name and type, size and array
122  ParamBase(const ByteArray &name, const uint32 type, const uint32 size, const int32 *values); // array constructor with name and type, size and array
123  ParamBase(const ByteArray &name, const uint32 type, const uint32 size, const float64 *values); // array constructor with name and type, size and array
124  ParamBase(const ByteArray &name, const uint32 type, const uint32 size, const complex128 *values); // array constructor with name and type, size and array
125  virtual ~ParamBase(); //Destructor
126  ParamBase(const ParamBase &copyConstr); //Copy-Constructor
127 
128  //--------------------------------------------------------------------------------------------
129  // ASSIGNMENT AND OPERATORS
130  //--------------------------------------------------------------------------------------------
131  const ParamBase operator [] (const int num) const;
132  ParamBase& operator = (const ParamBase &rhs);
133  ito::RetVal copyValueFrom(const ito::ParamBase *rhs);
134 
135  //--------------------------------------------------------------------------------------------
136  // COMPARISON OPERATORS (two values are equal if both their type and the content is equal)
137  //--------------------------------------------------------------------------------------------
138  bool operator ==(const ParamBase &rhs) const;
139 
140  inline bool operator !=(const ParamBase &rhs) const
141  {
142  return !(*this == rhs);
143  }
144 
145  //--------------------------------------------------------------------------------------------
146  // SET/GET FURTHER PROPERTIES
147  //--------------------------------------------------------------------------------------------
148 
150  inline bool isNumeric(void) const
151  {
152  static int numericTypeMask = ito::ParamBase::Char | ParamBase::Int | ParamBase::Double | ParamBase::Complex;
153  return ((m_type & numericTypeMask) > 0) && !(m_type & ito::ParamBase::Pointer);
154  }
155 
157  inline bool isNumericArray(void) const
158  {
159  static int numericTypeMask = ito::ParamBase::Char | ParamBase::Int | ParamBase::Double | ParamBase::Complex;
160  return (m_type & (numericTypeMask | ito::ParamBase::Pointer)) > 0;
161  }
162 
164  inline bool isValid(void) const { return m_type != 0; }
165 
167  inline uint32 getType(bool filterFlags = true) const
168  {
169  if (filterFlags)
170  return m_type & paramTypeMask;
171  else
172  return m_type;
173  }
174 
176  inline uint32 getFlags(void) const { return m_type & paramFlagMask; }
177 
179  inline void setFlags(const uint32 flags) { m_type = getType() | (flags & paramFlagMask); }
180 
182  inline const char* getName(void) const { return m_name.data(); }
183 
186  inline bool getAutosave(void) const { return (m_type & NoAutosave) > 0; }
187 
190  inline void setAutosave(const bool autosave) { m_type = autosave ? (m_type | NoAutosave) : (m_type & ~NoAutosave); }
191 
193  int getLen(void) const;
194 
195 
202  template<typename _Tp> inline ito::RetVal setVal(_Tp val)
203  {
204  return ItomParamHelper<_Tp>::setVal(getType(), m_cVal, m_iVal, m_dVal, val, 0);
205  }
206 
214  template<typename _Tp> inline ito::RetVal setVal(_Tp val, int len)
215  {
216  return ItomParamHelper<_Tp>::setVal(getType(), m_cVal, m_iVal, m_dVal, val, len);
217  }
218 
225  template<typename _Tp> inline _Tp getVal(void) const
226  {
227  int len = 0;
228  return ItomParamHelper<_Tp>::getVal(getType(), m_cVal, m_iVal, m_dVal, len);
229  }
230 
237  template<typename _Tp> inline _Tp getVal(int &len) const
238  {
239  return ItomParamHelper<_Tp>::getVal(getType(), m_cVal, m_iVal, m_dVal, len);
240  }
241 
242  };
243 
244  //----------------------------------------------------------------------------------------------------------------------------------
251  class ITOMCOMMON_EXPORT Param : public ParamBase
252  {
253  private:
254  ParamMeta *m_pMeta;
255  ByteArray m_info;
256 
257  public:
258 
259  //--------------------------------------------------------------------------------------------
260  // CONSTRUCTORS, COPY-CONSTRUCTOR, DESTRUCTOR
261  //--------------------------------------------------------------------------------------------
263  Param() : ParamBase(), m_pMeta(NULL), m_info(NULL) {}
264  Param(const ByteArray &name) : ParamBase(name), m_pMeta(NULL), m_info(NULL) {} // type-less Param with name only
265  Param(const ByteArray &name, const uint32 type) : ParamBase(name, type), m_pMeta(NULL), m_info(NULL) {} // constructor with type and name
266  Param(const ByteArray &name, const uint32 type, const char *val, const char *info); // constructor with name and type, char val and optional info
267  Param(const ByteArray &name, const uint32 type, const char minVal, const char maxVal, const char val, const char *info); // constructor with name and type, int val, int minVal, int maxVal and optional info
268  Param(const ByteArray &name, const uint32 type, const int32 minVal, const int32 maxVal, const int32 val, const char *info); // constructor with name and type, int val, int minVal, int maxVal and optional info
269  Param(const ByteArray &name, const uint32 type, const float64 minVal, const float64 maxVal, const float64 val, const char *info); // constructor with name and type, double val, double minVal, double maxVal and optional info
270  Param(const ByteArray &name, const uint32 type, const unsigned int size, const char *values, const char *info); // array constructor with name and type, size and array
271  Param(const ByteArray &name, const uint32 type, const unsigned int size, const int32 *values, const char *info); // array constructor with name and type, size and array
272  Param(const ByteArray &name, const uint32 type, const unsigned int size, const float64 *values, const char *info);// array constructor with name and type, size and array
273  Param(const ByteArray &name, const uint32 type, const unsigned int size, const complex128 *values, const char *info);// array constructor with name and type, size and array
274  Param(const ByteArray &name, const uint32 type, const char val, ParamMeta *meta, const char *info);
275  Param(const ByteArray &name, const uint32 type, const int32 val, ParamMeta *meta, const char *info);
276  Param(const ByteArray &name, const uint32 type, const float64 val, ParamMeta *meta, const char *info);
277  Param(const ByteArray &name, const uint32 type, const complex128 val, ParamMeta *meta, const char *info);
278  Param(const ByteArray &name, const uint32 type, const unsigned int size, const char *values, ParamMeta *meta, const char *info);
279  Param(const ByteArray &name, const uint32 type, const unsigned int size, const int32 *values, ParamMeta *meta, const char *info);
280  Param(const ByteArray &name, const uint32 type, const unsigned int size, const float64 *values, ParamMeta *meta, const char *info);
281  Param(const ByteArray &name, const uint32 type, const unsigned int size, const complex128 *values, ParamMeta *meta, const char *info);
282  ~Param();
283  Param(const Param &copyConstr);
284 
285  //--------------------------------------------------------------------------------------------
286  // ASSIGNMENT AND OPERATORS
287  //--------------------------------------------------------------------------------------------
288  const Param operator [] (const int num) const;
289  Param& operator = (const Param &rhs);
290  ito::RetVal copyValueFrom(const ParamBase *rhs);
291 
292  //--------------------------------------------------------------------------------------------
293  // SET/GET FURTHER PROPERTIES
294  //--------------------------------------------------------------------------------------------
296  inline const char * getInfo(void) const { return m_info.data(); }
297 
299  inline void setInfo(const char *info)
300  {
301  m_info = info;
302  }
303 
304  inline void setInfo(const ByteArray &info)
305  {
306  m_info = info;
307  }
308 
309  inline const ParamMeta* getMeta(void) const { return m_pMeta; }
310  inline ParamMeta* getMeta(void) { return m_pMeta; }
311 
313  /*
314  Example: intParam.getMetaT<ito::IntMeta>();
315  */
316  template<typename _Tp> inline const _Tp* getMetaT(void) const
317  {
318  return static_cast<const _Tp*>(m_pMeta);
319  }
320 
322  /*
323  Example: intParam.getMetaT<ito::IntMeta>();
324  */
325  template<typename _Tp> inline _Tp* getMetaT(void)
326  {
327  return static_cast<_Tp*>(m_pMeta);
328  }
329 
331 
336  void setMeta(ParamMeta* meta, bool takeOwnership = false);
337 
338  float64 getMin() const;
339  float64 getMax() const;
340  };
341 
342  //---------------------------------------------------------------------------------------------------------------------
343  template<typename _Tp>
344  struct ItomParamHelper
345  {
346  static ito::RetVal setVal(uint32 type, char *&cVal, int32 &iVal, complex128_ &/*dVal*/, const _Tp val, int len = 0)
347  {
348  switch (type & paramTypeMask)
349  {
350  case (ito::ParamBase::HWRef & paramTypeMask):
351  case (ito::ParamBase::DObjPtr & paramTypeMask):
352  case ito::ParamBase::PointCloudPtr & paramTypeMask:
353  case ito::ParamBase::PointPtr & paramTypeMask:
354  case ito::ParamBase::PolygonMeshPtr & paramTypeMask:
355 // case ito::ParamBase::Pointer & paramTypeMask:
356  cVal = (char*)(reinterpret_cast<const char*>(val));
357  return ito::retOk;
358 
359  case ito::ParamBase::String & paramTypeMask:
360  {
361  char *cVal_ = cVal;
362  if (val)
363  {
364  cVal = _strdup((const char*)val);
365  iVal = static_cast<int>(strlen(cVal));
366  }
367  else
368  {
369  cVal = 0;
370  iVal = -1;
371  }
372  if (cVal_)
373  {
374  free(cVal_);
375  }
376  }
377  return ito::retOk;
378 
379  case ito::ParamBase::CharArray & ito::paramTypeMask:
380  {
381  char *cVal_ = cVal;
382  if ((val) && (len > 0))
383  {
384  cVal = (char*)malloc(len * sizeof(char));
385  memcpy(cVal, val, len * sizeof(char));
386  iVal = len;
387  }
388  else
389  {
390  cVal = NULL;
391  iVal = -1;
392  }
393  if (cVal_)
394  {
395  free(cVal_);
396  }
397  }
398  return ito::retOk;
399 
400  case ito::ParamBase::IntArray & ito::paramTypeMask:
401  {
402  char *cVal_ = cVal;
403  if ((val) && (len > 0))
404  {
405  cVal = (char*)malloc(len * sizeof(ito::int32));
406  memcpy(cVal, val, len * sizeof(ito::int32));
407  iVal = len;
408  }
409  else
410  {
411  cVal = NULL;
412  iVal = -1;
413  }
414  if (cVal_)
415  {
416  free(cVal_);
417  }
418  }
419  return ito::retOk;
420 
421  case ito::ParamBase::DoubleArray & ito::paramTypeMask:
422  {
423  char *cVal_ = cVal;
424  if ((val) && (len > 0))
425  {
426  cVal = (char*)malloc(len * sizeof(ito::float64));
427  memcpy(cVal, val, len * sizeof(ito::float64));
428  iVal = len;
429  }
430  else
431  {
432  cVal = NULL;
433  iVal = -1;
434  }
435  if (cVal_)
436  {
437  free(cVal_);
438  }
439  }
440  return ito::retOk;
441 
442  case ito::ParamBase::ComplexArray & ito::paramTypeMask:
443  {
444  char *cVal_ = cVal;
445  if ((val) && (len > 0))
446  {
447  cVal = (char*)malloc(len * sizeof(ito::complex128));
448  memcpy(cVal, val, len * sizeof(ito::complex128));
449  iVal = len;
450  }
451  else
452  {
453  cVal = NULL;
454  iVal = -1;
455  }
456  if (cVal_)
457  {
458  free(cVal_);
459  }
460  }
461  return ito::retOk;
462 
463  default:
464  return ito::RetVal(ito::retError, 0, "_Tp parameter of setVal<_Tp> does not match the type of the parameter");
465  }
466  }
467 
468  static _Tp getVal(const uint32 type, const char *cVal, const int32 &iVal, const complex128_ &/*dVal*/, int &len)
469  {
470  switch (type & paramTypeMask)
471  {
472  case ito::ParamBase::String & paramTypeMask:
473  if (cVal)
474  {
475  len = static_cast<int>(strlen(cVal));
476  return reinterpret_cast<_Tp>(const_cast<char*>(cVal));
477  }
478  else
479  {
480  len = 0;
481  return 0;
482  }
483 
484  case ito::ParamBase::CharArray & ito::paramTypeMask:
485  case ito::ParamBase::IntArray & ito::paramTypeMask:
486  case ito::ParamBase::DoubleArray & ito::paramTypeMask:
487  case ito::ParamBase::ComplexArray & ito::paramTypeMask:
488  if (cVal)
489  {
490  len = iVal;
491  return reinterpret_cast<_Tp>(const_cast<char*>(cVal));
492  }
493  else
494  {
495  len = 0;
496  return 0;
497  }
498 
499  case (ito::ParamBase::HWRef & paramTypeMask):
500  case (ito::ParamBase::DObjPtr & paramTypeMask):
501  case ito::ParamBase::PointCloudPtr & paramTypeMask:
502  case ito::ParamBase::PointPtr & paramTypeMask:
503  case ito::ParamBase::PolygonMeshPtr & paramTypeMask:
504  return reinterpret_cast<_Tp>(const_cast<char*>(cVal));
505 
506  default:
507  throw std::logic_error("Param::getVal<_Tp>: Non-matching type!");
508  }
509  }
510  };
511 
512  template<>
513  struct ItomParamHelper<float64>
514  {
515  static ito::RetVal setVal(uint32 type, char *&/*cVal*/, int32 &iVal, complex128_ &dVal, float64 val, int /*len = 0*/)
516  {
517  switch (type & paramTypeMask)
518  {
519  case ito::ParamBase::Complex & ito::paramTypeMask:
520  case ito::ParamBase::Double & ito::paramTypeMask:
521  dVal.real = static_cast<float64>(val);
522  dVal.imag = 0.0;
523  return ito::retOk;
524 
525  case ito::ParamBase::Int & ito::paramTypeMask:
526  case ito::ParamBase::Char & ito::paramTypeMask:
527  iVal = static_cast<int32>(val);
528  return ito::retOk;
529 
530  default:
531  return ito::RetVal(ito::retError, 0, "float64 value passed to setVal<float64> does not match the type of the parameter");
532  }
533  }
534 
535  static float64 getVal(const uint32 type, const char * /*cVal*/, const int32 &iVal, const complex128_ &dVal, int & /*len*/)
536  {
537  switch (type & paramTypeMask)
538  {
539  case ito::ParamBase::Int & ito::paramTypeMask:
540  case ito::ParamBase::Char & ito::paramTypeMask:
541  return static_cast<float64>(iVal);
542 
543  case ito::ParamBase::Complex & ito::paramTypeMask:
544  case ito::ParamBase::Double & ito::paramTypeMask:
545  return dVal.real;
546 
547  default:
548  throw std::logic_error("Param::getVal<float64>: Non-matching type!");
549  }
550  }
551  };
552 
553  template<>
554  struct ItomParamHelper<int32>
555  {
556  static ito::RetVal setVal(uint32 type, char *&/*cVal*/, int32 &iVal, complex128_ &dVal, int32 val, int /*len = 0*/)
557  {
558  switch (type & paramTypeMask)
559  {
560  case ito::ParamBase::Complex & ito::paramTypeMask:
561  case ito::ParamBase::Double & ito::paramTypeMask:
562  dVal.real = static_cast<float64>(val);
563  dVal.imag = 0.0;
564  return ito::retOk;
565 
566  case ito::ParamBase::Int & ito::paramTypeMask:
567  case ito::ParamBase::Char & ito::paramTypeMask:
568  iVal = val;
569  return ito::retOk;
570 
571  default:
572  return ito::RetVal(ito::retError, 0, "int32 value passed to setVal<int32> does not match the type of the parameter");
573  }
574  }
575 
576  static int32 getVal(const uint32 type, const char * /*cVal*/, const int32 &iVal, const complex128_ &dVal, int & /*len*/)
577  {
578  switch (type & paramTypeMask)
579  {
580  case ito::ParamBase::Int & ito::paramTypeMask:
581  case ito::ParamBase::Char & ito::paramTypeMask:
582  return iVal;
583 
584  case ito::ParamBase::Complex & ito::paramTypeMask:
585  case ito::ParamBase::Double & ito::paramTypeMask:
586  return static_cast<int32>(dVal.real);
587 
588  case 0:
589  throw std::invalid_argument("Param::getVal<int32>: non existent parameter");
590 
591  default:
592  throw std::logic_error("Param::getVal<int32>: Non-matching type!");
593  }
594  }
595  };
596 
597  template<>
598  struct ItomParamHelper<char>
599  {
600  static ito::RetVal setVal(uint32 type, char *&/*cVal*/, int32 &iVal, complex128_ &dVal, char val, int /*len = 0*/)
601  {
602  switch (type & paramTypeMask)
603  {
604  case ito::ParamBase::Complex & ito::paramTypeMask:
605  case ito::ParamBase::Double & ito::paramTypeMask:
606  dVal.real = static_cast<float64>(val);
607  dVal.imag = 0.0;
608  return ito::retOk;
609 
610  case ito::ParamBase::Int & ito::paramTypeMask:
611  case ito::ParamBase::Char & ito::paramTypeMask:
612  iVal = static_cast<char>(val);
613  return ito::retOk;
614 
615  default:
616  return ito::RetVal(ito::retError, 0, "char value passed to setVal<char> does not match the type of the parameter");
617  }
618  }
619 
620  static char getVal(const uint32 type, const char * /*cVal*/, const int32 &iVal, const complex128_ &dVal, int & /*len*/)
621  {
622  switch (type & paramTypeMask)
623  {
624  case ito::ParamBase::Int & ito::paramTypeMask:
625  case ito::ParamBase::Char & ito::paramTypeMask:
626  return static_cast<char>(iVal);
627 
628  case ito::ParamBase::Complex & ito::paramTypeMask:
629  case ito::ParamBase::Double & ito::paramTypeMask:
630  return static_cast<char>(dVal.real);
631 
632  case 0:
633  throw std::invalid_argument("Param::getVal<char>: non existent parameter");
634 
635  default:
636  throw std::logic_error("Param::getVal<char>: Non-matching type!");
637  }
638  }
639  };
640 
641  template<>
642  struct ItomParamHelper<unsigned char>
643  {
644  static ito::RetVal setVal(uint32 type, char *&/*cVal*/, int32 &iVal, complex128_ &dVal, char val, int /*len = 0*/)
645  {
646  switch (type & paramTypeMask)
647  {
648  case ito::ParamBase::Complex & ito::paramTypeMask:
649  case ito::ParamBase::Double & ito::paramTypeMask:
650  dVal.real = static_cast<float64>(val);
651  dVal.imag = 0.0;
652  return ito::retOk;
653 
654  case ito::ParamBase::Int & ito::paramTypeMask:
655  case ito::ParamBase::Char & ito::paramTypeMask:
656  iVal = static_cast<unsigned char>(val);
657  return ito::retOk;
658 
659  default:
660  return ito::RetVal(ito::retError, 0, "unsigned char value passed to setVal<unsigned char> does not match the type of the parameter");
661  }
662  }
663 
664  static char getVal(const uint32 type, const char * /*cVal*/, const int32 &iVal, const complex128_ &dVal, int & /*len*/)
665  {
666  switch (type & paramTypeMask)
667  {
668  case ito::ParamBase::Int & ito::paramTypeMask:
669  case ito::ParamBase::Char & ito::paramTypeMask:
670  return static_cast<unsigned char>(iVal);
671 
672  case ito::ParamBase::Complex & ito::paramTypeMask:
673  case ito::ParamBase::Double & ito::paramTypeMask:
674  return static_cast<unsigned char>(dVal.real);
675 
676  case 0:
677  throw std::invalid_argument("Param::getVal<uchar>: non existent parameter");
678 
679  default:
680  throw std::logic_error("Param::getVal<uchar>: Non-matching type!");
681  }
682  }
683  };
684 
685  template<>
686  struct ItomParamHelper<complex128>
687  {
688  static ito::RetVal setVal(uint32 type, char *&/*cVal*/, int32 &iVal, complex128_ &dVal, complex128 val, int /*len = 0*/)
689  {
690  switch (type & paramTypeMask)
691  {
692  case ito::ParamBase::Complex & ito::paramTypeMask:
693  dVal.real = val.real();
694  dVal.imag = val.imag();
695  return ito::retOk;
696 
697  default:
698  return ito::RetVal(ito::retError, 0, "complex128 value passed to setVal<complex128> does not match the type of the parameter");
699  }
700  }
701 
702  static complex128 getVal(const uint32 type, const char * /*cVal*/, const int32 &iVal, const complex128_ &dVal, int & /*len*/)
703  {
704  switch (type & paramTypeMask)
705  {
706  case ito::ParamBase::Int & ito::paramTypeMask:
707  case ito::ParamBase::Char & ito::paramTypeMask:
708  return complex128(iVal, 0.0);
709 
710  case ito::ParamBase::Complex & ito::paramTypeMask:
711  return complex128(dVal.real, dVal.imag);
712 
713  case ito::ParamBase::Double & ito::paramTypeMask:
714  return dVal.real;
715 
716  default:
717  throw std::logic_error("Param::getVal<complex128>: Non-matching type!");
718  }
719  }
720  };
721 
722 } //end namespace ito
723 
724 #endif
bool isNumericArray(void) const
returns true if Param is of type char array, int array, double array or complex array ...
Definition: param.h:157
complex128_ m_dVal
internal value for float64 and complex128 typed values
Definition: param.h:78
void setFlags(const uint32 flags)
sets parameter flagsfor possible flags see tParamType
Definition: param.h:179
bool isNumeric(void) const
returns true if Param is of type char, int, double or complex
Definition: param.h:150
ito::RetVal setVal(_Tp val, int len)
Definition: param.h:214
Definition: typeDefs.h:60
ito::int32 m_iVal
internal value for integer typed values
Definition: param.h:79
Class for managing status values (like errors or warning)
Definition: retVal.h:54
class for parameter handling e.g. to pass paramters to plugins
Definition: param.h:251
bool getAutosave(void) const
Definition: param.h:186
const char * getInfo(void) const
< returns content of info string (string is not copied)
Definition: param.h:296
Definition: param.h:54
ParamMeta * getMeta(void)
returns pointer to meta-information instance or NULL if not available. Cast this pointer to the right...
Definition: param.h:310
This is a Qt-free class for byte arrays (strings) without specific encoding information.
Definition: byteArray.h:69
Param()
default constructor, creates "empty" tParam
Definition: param.h:263
Definition: typeDefs.h:58
ito::RetVal setVal(_Tp val)
Definition: param.h:202
DataObject imag(const DataObject &dObj)
high-level value which calculates the imaginary value of each element of the input source data object...
Definition: dataobj.cpp:9069
Definition: apiFunctionsGraph.cpp:39
const ParamMeta * getMeta(void) const
returns const-pointer to meta-information instance or NULL if not available. Cast this pointer to the...
Definition: param.h:309
bool isValid(void) const
returns whether Param contains a valid type (true) or is an empty parameter (false, type == 0). The default tParam-constructor is always an invalid tParam.
Definition: param.h:164
ParamBase()
default constructor, creates "empty" ParamBase
Definition: param.h:114
uint32 getType(bool filterFlags=true) const
returns parameter type (autosave flag and other flags (like in, out or readonly) are only included if...
Definition: param.h:167
bool operator==(const ByteArray &a1, const char *a2)
comparison operator that returns true if the content of a1 is equal to the given zero-terminated stri...
Definition: byteArray.h:190
void setAutosave(const bool autosave)
Definition: param.h:190
uint32 getFlags(void) const
returns parameter flags
Definition: param.h:176
const char * getName(void) const
returns parameter name (returned string is no copy, do not delete it)
Definition: param.h:182
const uint32 paramTypeMask
bits of param type lying withing this mask describe the type (typeNoAutosave must be included there) ...
Definition: param.h:57
_Tp getVal(void) const
Definition: param.h:225
DataObject real(const DataObject &dObj)
high-level value which calculates the real value of each element of the input source data object and ...
Definition: dataobj.cpp:8985
wrapper class for a complex128 value. This class is used, since the std::complex stl class is not exp...
Definition: param.h:60
const uint32 paramFlagMask
bits of type lying within this mask are flags (e.g. typeNoAutosave, typeReadonly...)
Definition: param.h:56
Base class for all meta-information classes.
Definition: paramMeta.h:59
bool operator!=(const ByteArray &a1, const char *a2)
comparison operator that returns true if the content of a1 is not equal to the given zero-terminated ...
Definition: byteArray.h:202
ByteArray m_name
parameter name
Definition: param.h:71
char * m_cVal
internal pointer for pointer type values (also strings)
Definition: param.h:80
Definition: param.h:67
const char * data() const
return the pointer to the internal character array. If it is empty, the returned pointer still points...
Definition: byteArray.h:136
_Tp getVal(int &len) const
Definition: param.h:237