itom  4.1.0
paramMeta.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2020, 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 PARAMMETA_H
29 #define PARAMMETA_H
30 
31 /* includes */
32 
33 #include "commonGlobal.h"
34 #include "typeDefs.h"
35 #include "byteArray.h"
36 #include "retVal.h"
37 
38 #include <limits>
39 
40 
41 
42 /* definition and macros */
43 /* global variables (avoid) */
44 /* content */
45 
46 namespace ito
47 {
59  class ITOMCOMMON_EXPORT ParamMeta
60  {
61  public:
68  enum MetaRtti
69  {
70  rttiUnknown = 0,
71  rttiCharMeta = 1,
72  rttiIntMeta = 2,
73  rttiDoubleMeta = 3,
74  rttiStringMeta = 4,
75  rttiHWMeta = 5,
76  rttiDObjMeta = 6,
77  rttiIntArrayMeta = 7,
78  rttiDoubleArrayMeta = 8,
79  rttiCharArrayMeta = 9,
80  rttiIntervalMeta = 10,
81  rttiDoubleIntervalMeta = 11,
82  rttiRangeMeta = 12,
83  rttiRectMeta = 13
84  };
85 
86 
97  {
98  Linear = 0x0001,
99  Logarithmic = 0x0002,
100  Boolean = 0x0004,
101  PureNumber = 0x0008,
102  HexNumber = 0x0010,
103  IPV4Address = 0x0020,
104  MACAddress = 0x0040,
105  UnknownRepresentation = 0x0080
106  };
107 
108  ParamMeta(ito::ByteArray category = ito::ByteArray());
109  ParamMeta(MetaRtti type, ito::ByteArray category = ito::ByteArray());
110  virtual ~ParamMeta() {}
111  inline MetaRtti getType() const { return m_type; }
112  inline ito::ByteArray getCategory() const { return m_category; }
113  void setCategory(const ito::ByteArray &category);
114 
115  virtual bool operator==(const ParamMeta& other) const;
116  bool operator!=(const ParamMeta& other) const { return !(*this == other); }
117 
118  protected:
119  MetaRtti m_type;
121  };
122 
132  class ITOMCOMMON_EXPORT CharMeta : public ParamMeta
133  {
134  public:
136 
137  explicit CharMeta(char minVal, char maxVal, char stepSize = 1, ito::ByteArray category = ito::ByteArray());
138  static CharMeta* all(ito::ByteArray category = ito::ByteArray());
139  inline char getMin() const { return m_minVal; }
140  inline char getMax() const { return m_maxVal; }
141  inline char getStepSize() const { return m_stepSize; }
142  inline ito::ByteArray getUnit() const { return m_unit; }
143  inline void setUnit(const ito::ByteArray &unit) { m_unit = unit; }
144  inline ParamMeta::tRepresentation getRepresentation() const { return m_representation; }
145  void setRepresentation(ParamMeta::tRepresentation representation);
146 
148 
151  void setMin(char val);
152 
154 
157  void setMax(char val);
158 
160 
163  void setStepSize(char val);
164 
165  virtual bool operator==(const ParamMeta& other) const;
166  private:
167  char m_minVal;
168  char m_maxVal;
169  char m_stepSize; // >= 1
172  };
173 
183  class ITOMCOMMON_EXPORT IntMeta : public ParamMeta
184  {
185  public:
186 
187  explicit IntMeta(int32 minVal, int32 maxVal, int32 stepSize = 1, ito::ByteArray category = ito::ByteArray());
188  static IntMeta* all(ito::ByteArray category = ito::ByteArray());
189  inline int32 getMin() const { return m_minVal; }
190  inline int32 getMax() const { return m_maxVal; }
191  inline int32 getStepSize() const { return m_stepSize; }
192  inline ito::ByteArray getUnit() const { return m_unit; }
193  inline void setUnit(const ito::ByteArray &unit) { m_unit = unit; }
194  inline ParamMeta::tRepresentation getRepresentation() const { return m_representation; }
195  void setRepresentation(ParamMeta::tRepresentation behaviour);
196 
198 
201  void setMin(int32 val);
202 
204 
207  void setMax(int32 val);
208 
210 
213  void setStepSize(int32 val);
214 
215  virtual bool operator==(const ParamMeta& other) const;
216  private:
217  int32 m_minVal;
218  int32 m_maxVal;
219  int32 m_stepSize; // >= 1
222  };
223 
233  class ITOMCOMMON_EXPORT DoubleMeta : public ParamMeta
234  {
235  public:
240  {
243  Scientific
244  };
245 
247 
248  explicit DoubleMeta(float64 minVal, float64 maxVal, float64 stepSize = 0.0 /*0.0 means no specific step size*/, ito::ByteArray category = ito::ByteArray());
249  static DoubleMeta* all(ito::ByteArray category = ito::ByteArray());
250  inline float64 getMin() const { return m_minVal; }
251  inline float64 getMax() const { return m_maxVal; }
252  inline float64 getStepSize() const { return m_stepSize; }
253  inline ito::ByteArray getUnit() const { return m_unit; }
254  inline void setUnit(const ito::ByteArray &unit) { m_unit = unit; }
255  inline int getDisplayPrecision() const { return m_displayPrecision; }
256  inline void setDisplayPrecision(int displayPrecision) { m_displayPrecision = displayPrecision; }
257  inline DoubleMeta::tDisplayNotation getDisplayNotation() const { return m_displayNotation; }
258  inline void setDisplayNotation(DoubleMeta::tDisplayNotation displayNotation) { m_displayNotation = displayNotation; }
259  inline ParamMeta::tRepresentation getRepresentation() const { return m_representation; }
260  void setRepresentation(ParamMeta::tRepresentation representation);
261 
263 
266  void setMin(float64 val);
267 
269 
272  void setMax(float64 val);
273 
275 
278  void setStepSize(float64 val);
279 
280  virtual bool operator==(const ParamMeta& other) const;
281 
282  private:
283  float64 m_minVal;
284  float64 m_maxVal;
285  float64 m_stepSize; // >= 0, 0.0 means no specific step size
290  };
291 
302  class ITOMCOMMON_EXPORT HWMeta : public ParamMeta
303  {
304  public:
306 
313  explicit HWMeta(uint32 minType, ito::ByteArray category = ito::ByteArray()) : ParamMeta(rttiHWMeta, category), m_minType(minType)
314  {
315  }
316 
318 
324  explicit HWMeta(const char *HWAddInName, ito::ByteArray category = ito::ByteArray()) : ParamMeta(rttiHWMeta, category), m_minType(0), m_HWName(HWAddInName)
325  {
326  }
327 
328 
329  HWMeta(const HWMeta& cpy) : ParamMeta(cpy), m_minType(cpy.m_minType), m_HWName(cpy.m_HWName)
330  {
331  }
332 
333  inline uint32 getMinType() const { return m_minType; }
334  inline ito::ByteArray getHWAddInName() const { return m_HWName; }
335 
336  virtual bool operator==(const ParamMeta& other) const;
337  private:
338  uint32 m_minType;
340  };
341 
342  class StringMetaPrivate; //forward declaration
343 
354  class ITOMCOMMON_EXPORT StringMeta : public ParamMeta
355  {
356  public:
357  enum tType
358  {
361  RegExp
362  };
363 
365 
370  StringMeta(tType type, ito::ByteArray category = ito::ByteArray());
371 
373 
379  StringMeta(tType type, const char* val, ito::ByteArray category = ito::ByteArray());
380 
382 
388  StringMeta(tType type, const ito::ByteArray &val, ito::ByteArray category = ito::ByteArray());
389 
391  StringMeta(const StringMeta& cpy);
392 
394  virtual ~StringMeta();
395 
396 
397  tType getStringType() const;
398  void setStringType(tType type);
399  int getLen() const;
400  const char* getString(int idx = 0) const;
401  bool addItem(const char *val);
402  bool addItem(const ito::ByteArray &val);
403  void clearItems();
404  StringMeta & operator += (const char *val);
405  StringMeta & operator = (const StringMeta& rhs);
406  virtual bool operator==(const ParamMeta& other) const;
407 
408  private:
409 
411 
412  };
413 
422  class ITOMCOMMON_EXPORT DObjMeta : public ParamMeta
423  {
424  public:
425 
426  explicit DObjMeta(uint32 allowedTypes = 0xFFFF, int minDim = 0, int maxDim = (std::numeric_limits<int>::max)(), ito::ByteArray category = ito::ByteArray()) : ParamMeta(rttiDObjMeta, category), m_allowedTypes(allowedTypes), m_minDim(minDim), m_maxDim(maxDim) {}
427  inline int getAllowedTypes() const { return m_allowedTypes; }
428  inline int getMinDim() const { return m_minDim; }
429  inline int getMaxDim() const { return m_maxDim; }
430  virtual bool operator==(const ParamMeta& other) const;
431 
432  private:
433  uint32 m_allowedTypes;
434  int m_minDim;
435  int m_maxDim;
436  };
437 
448  class ITOMCOMMON_EXPORT CharArrayMeta : public CharMeta
449  {
450  public:
451 
452  explicit CharArrayMeta(char minVal, char maxVal, char stepSize = 1, ito::ByteArray category = ito::ByteArray());
453  explicit CharArrayMeta(char minVal, char maxVal, char stepSize, size_t numMin, size_t numMax, size_t numStepSize = 1, ito::ByteArray category = ito::ByteArray());
454  inline size_t getNumMin() const { return m_numMin; }
455  inline size_t getNumMax() const { return m_numMax; }
456  inline size_t getNumStepSize() const { return m_numStep; }
457 
459 
462  void setNumMin(size_t val);
463 
465 
468  void setNumMax(size_t val);
469 
471 
474  void setNumStepSize(size_t val);
475 
476  virtual bool operator==(const ParamMeta& other) const;
477 
478  private:
479  size_t m_numMin;
480  size_t m_numMax;
481  size_t m_numStep;
482  };
483 
494  class ITOMCOMMON_EXPORT IntArrayMeta : public IntMeta
495  {
496  public:
497 
498  explicit IntArrayMeta(int32 minVal, int32 maxVal, int stepSize = 1, ito::ByteArray category = ito::ByteArray());
499  explicit IntArrayMeta(int32 minVal, int32 maxVal, int stepSize, size_t numMin, size_t numMax, size_t numStepSize = 1, ito::ByteArray category = ito::ByteArray());
500  inline size_t getNumMin() const { return m_numMin; }
501  inline size_t getNumMax() const { return m_numMax; }
502  inline size_t getNumStepSize() const { return m_numStep; }
503 
505 
508  void setNumMin(size_t val);
509 
511 
514  void setNumMax(size_t val);
515 
517 
520  void setNumStepSize(size_t val);
521 
522  virtual bool operator==(const ParamMeta& other) const;
523 
524  private:
525  size_t m_numMin;
526  size_t m_numMax;
527  size_t m_numStep;
528  };
529 
540  class ITOMCOMMON_EXPORT DoubleArrayMeta : public DoubleMeta
541  {
542  public:
543 
544  explicit DoubleArrayMeta(float64 minVal, float64 maxVal, float64 stepSize = 0.0, ito::ByteArray category = ito::ByteArray());
545  explicit DoubleArrayMeta(float64 minVal, float64 maxVal, float64 stepSize, size_t numMin, size_t numMax, size_t numStepSize = 1, ito::ByteArray category = ito::ByteArray());
546  inline size_t getNumMin() const { return m_numMin; }
547  inline size_t getNumMax() const { return m_numMax; }
548  inline size_t getNumStepSize() const { return m_numStep; }
549 
551 
554  void setNumMin(size_t val);
555 
557 
560  void setNumMax(size_t val);
561 
563 
566  void setNumStepSize(size_t val);
567 
568  virtual bool operator==(const ParamMeta& other) const;
569 
570  private:
571  size_t m_numMin;
572  size_t m_numMax;
573  size_t m_numStep;
574  };
575 
576 
588  class ITOMCOMMON_EXPORT DoubleIntervalMeta : public DoubleMeta
589  {
590  public:
591 
592  explicit DoubleIntervalMeta(float64 minVal, float64 maxVal, float64 stepSize = 0.0, ito::ByteArray category = ito::ByteArray());
593  explicit DoubleIntervalMeta(float64 minVal, float64 maxVal, float64 stepSize, float64 sizeMin, float64 sizeMax, float64 sizeStep = 0.0, ito::ByteArray category = ito::ByteArray());
594  inline float64 getSizeMin() const { return m_sizeMin; }
595  inline float64 getSizeMax() const { return m_sizeMax; }
596  inline float64 getSizeStepSize() const { return m_sizeStep; }
597 
599 
602  void setSizeMin(float64 val);
603 
605 
608  void setSizeMax(float64 val);
609 
611 
614  void setSizeStep(float64 val);
615 
616  virtual bool operator==(const ParamMeta& other) const;
617 
618  private:
619  float64 m_sizeMin;
620  float64 m_sizeMax;
621  float64 m_sizeStep;
622  };
623 
624 
638  class ITOMCOMMON_EXPORT IntervalMeta : public IntMeta
639  {
640  public:
641  explicit IntervalMeta(int32 minVal, int32 maxVal, int32 stepSize = 1, ito::ByteArray category = ito::ByteArray());
642  explicit IntervalMeta(int32 minVal, int32 maxVal, int32 stepSize, int32 sizeMin, int32 sizeMax, int32 intervalStep = 1, ito::ByteArray category = ito::ByteArray());
643  inline int getSizeMin() const { return m_sizeMin; }
644  inline int getSizeMax() const { return m_sizeMax; }
645  inline int getSizeStepSize() const { return m_sizeStep; }
646  inline bool isIntervalNotRange() const { return m_isIntervalNotRange; }
647 
649 
652  void setIntervalMin(int32 val);
653 
655 
658  void setIntervalMax(int32 val);
659 
661 
664  void setIntervalStep(int32 val);
665 
666  virtual bool operator==(const ParamMeta& other) const;
667 
668  protected:
669  int32 m_sizeMin;
670  int32 m_sizeMax;
671  int32 m_sizeStep;
673  };
674 
675 
693  class ITOMCOMMON_EXPORT RangeMeta : public IntervalMeta
694  {
695  public:
696  explicit RangeMeta(int32 minVal, int32 maxVal, int32 stepSize = 1, ito::ByteArray category = ito::ByteArray());
697  explicit RangeMeta(int32 minVal, int32 maxVal, int32 stepSize, size_t sizeMin, size_t sizeMax, size_t sizeStep = 1, ito::ByteArray category = ito::ByteArray());
698  };
699 
700 
712  class ITOMCOMMON_EXPORT RectMeta : public ParamMeta
713  {
714  public:
715  explicit RectMeta(const ito::RangeMeta &widthMeta, const ito::RangeMeta &heightMeta, ito::ByteArray category = ito::ByteArray());
716  inline const ito::RangeMeta& getWidthRangeMeta() const { return m_widthMeta; }
717  inline const ito::RangeMeta& getHeightRangeMeta() const { return m_heightMeta; }
718 
719  void setWidthRangeMeta(const ito::RangeMeta &widthMeta);
720  void setHeightRangeMeta(const ito::RangeMeta &heightMeta);
721 
722  inline ito::ByteArray getUnit() const { return m_heightMeta.getUnit(); }
723  inline void setUnit(const ito::ByteArray &unit) { m_heightMeta.setUnit(unit); }
724 
725  virtual bool operator==(const ParamMeta& other) const;
726 
727  protected:
728  ito::RangeMeta m_heightMeta;
729  ito::RangeMeta m_widthMeta;
730  };
731 
732 
733 
734 } //end namespace ito
735 
736 #endif
Definition: paramMeta.h:494
float64 getSizeMin() const
returns minimum size of range
Definition: paramMeta.h:594
int getDisplayPrecision() const
returns display precision
Definition: paramMeta.h:255
if possible, the double number should be shown as fixed number, e.g. 1000.00
Definition: paramMeta.h:242
Meta-information for Param of type DObjPtr.
Definition: paramMeta.h:422
ParamMeta::tRepresentation getRepresentation() const
returns display representation
Definition: paramMeta.h:194
Meta-information for Param of type Int.
Definition: paramMeta.h:183
int getSizeStepSize() const
returns step size of size of interval or range
Definition: paramMeta.h:645
ParamMeta::tRepresentation m_representation
hint for display behaviour in GUI widget
Definition: paramMeta.h:221
float64 getStepSize() const
returns step size
Definition: paramMeta.h:252
ito::ByteArray getHWAddInName() const
returns name of specific hardware plugin
Definition: paramMeta.h:334
DoubleMeta::tDisplayNotation getDisplayNotation() const
returns display notation
Definition: paramMeta.h:257
ParamMeta::tRepresentation m_representation
hint for display representation in GUI widget
Definition: paramMeta.h:171
Definition: paramMeta.cpp:276
void setDisplayPrecision(int displayPrecision)
sets display precision
Definition: paramMeta.h:256
ParamMeta::tRepresentation m_representation
hint for display representation in GUI widget
Definition: paramMeta.h:289
string elements should be considered as strings (exact match)
Definition: paramMeta.h:359
HWMeta(uint32 minType, ito::ByteArray category=ito::ByteArray())
constructor
Definition: paramMeta.h:313
int m_displayPrecision
hint for the number of decimal digits that should be shown in any GUI widget, default: 3 ...
Definition: paramMeta.h:287
ito::ByteArray getUnit() const
returns unit
Definition: paramMeta.h:722
ParamMeta::tRepresentation getRepresentation() const
returns display representation
Definition: paramMeta.h:144
This is a Qt-free class for byte arrays (strings) without specific encoding information.
Definition: byteArray.h:64
double number is automatically rendered in any GUI element
Definition: paramMeta.h:241
char getMax() const
returns maximum value
Definition: paramMeta.h:140
Meta-information for Param of type CharArrayMeta.
Definition: paramMeta.h:448
ito::ByteArray getUnit() const
returns unit
Definition: paramMeta.h:192
MetaRtti
Runtime type information.
Definition: paramMeta.h:68
void setUnit(const ito::ByteArray &unit)
sets unit string of this parameter
Definition: paramMeta.h:723
ito::ByteArray m_unit
unit of value, e.g. 'mm', ...
Definition: paramMeta.h:170
size_t getNumStepSize() const
returns step size of number of values
Definition: paramMeta.h:502
float64 getMax() const
returns maximum value
Definition: paramMeta.h:251
tDisplayNotation m_displayNotation
indicates how this double number should be rendered (e.g. in GUI widgets)
Definition: paramMeta.h:288
Definition: apiFunctionsGraph.cpp:39
size_t getNumMin() const
returns minimum number of values
Definition: paramMeta.h:500
bool m_isIntervalNotRange
this flag describes if this object is an interval where its interval/range is (end-begin) or a range ...
Definition: paramMeta.h:672
int32 getMax() const
returns maximum value
Definition: paramMeta.h:190
int32 getMin() const
returns minimum value
Definition: paramMeta.h:189
ito::ByteArray getCategory() const
returns category name of this parameter (default: empty ByteArray)
Definition: paramMeta.h:112
HWMeta(const char *HWAddInName, ito::ByteArray category=ito::ByteArray())
constructor
Definition: paramMeta.h:324
size_t getNumStepSize() const
returns step size of number of values
Definition: paramMeta.h:548
virtual ~ParamMeta()
destructor
Definition: paramMeta.h:110
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:185
tDisplayNotation
Display notation style if the related parameters is displayed in any widget.
Definition: paramMeta.h:239
float64 getMin() const
returns minimum value
Definition: paramMeta.h:250
uint32 m_minType
type-bitmask which is minimally required. default: 0
Definition: paramMeta.h:338
char getStepSize() const
returns step size
Definition: paramMeta.h:141
ito::ByteArray m_category
optional category name of this parameter
Definition: paramMeta.h:120
Meta-information for ito::Param of type Double.
Definition: paramMeta.h:233
ParamMeta::tRepresentation getRepresentation() const
returns display representation
Definition: paramMeta.h:259
size_t getNumMin() const
returns minimum number of values
Definition: paramMeta.h:546
meta-information for Param of type Char.
Definition: paramMeta.h:132
void setUnit(const ito::ByteArray &unit)
sets unit string of this parameter
Definition: paramMeta.h:193
tRepresentation
The representation of number types indicates the type of widget that is suited best to display and ch...
Definition: paramMeta.h:96
Meta-information for Param of type HWPtr.
Definition: paramMeta.h:302
int getSizeMin() const
returns minimum size of interval or range
Definition: paramMeta.h:643
void setUnit(const ito::ByteArray &unit)
sets unit string of this parameter
Definition: paramMeta.h:254
string elements should be considered as wildcard-expressions (e.g. *.doc)
Definition: paramMeta.h:360
Meta-information for Param of type IntArrayMeta that represent an interval [minimum, maximum).
Definition: paramMeta.h:638
char getMin() const
returns minimum value
Definition: paramMeta.h:139
void setDisplayNotation(DoubleMeta::tDisplayNotation displayNotation)
sets display notation
Definition: paramMeta.h:258
size_t getNumMax() const
returns maximum number of values
Definition: paramMeta.h:455
size_t getNumMax() const
returns maximum number of values
Definition: paramMeta.h:501
uint32 getMinType() const
returns type-bitmask which is minimally required by plugin-reference. Default 0.
Definition: paramMeta.h:333
ito::ByteArray m_unit
unit of value, e.g. 'mm', ...
Definition: paramMeta.h:220
float64 getSizeMax() const
returns maximum size of range
Definition: paramMeta.h:595
size_t getNumMin() const
returns minimum number of values
Definition: paramMeta.h:454
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:197
int getMaxDim() const
returns minimum number of dimensions of data object
Definition: paramMeta.h:429
Meta-information for Param of type IntArrayMeta that represent a range [minVal, maxVal].
Definition: paramMeta.h:693
Meta-information for Param of type DoubleArrayMeta.
Definition: paramMeta.h:540
void setUnit(const ito::ByteArray &unit)
sets unit string of this parameter
Definition: paramMeta.h:143
ito::ByteArray m_HWName
zero-terminated name of specific plugin-name or invalid if not defined
Definition: paramMeta.h:339
int getSizeMax() const
returns maximum size of interval or range
Definition: paramMeta.h:644
ito::ByteArray m_unit
unit of value, e.g. 'mm', ...
Definition: paramMeta.h:286
Meta-information for Param of type String.
Definition: paramMeta.h:354
size_t getNumStepSize() const
returns step size of number of values
Definition: paramMeta.h:456
size_t getNumMax() const
returns maximum number of values
Definition: paramMeta.h:547
float64 getSizeStepSize() const
returns step size of size of range
Definition: paramMeta.h:596
Meta-information for Param of type IntArrayMeta that represent a rectangle (left, top...
Definition: paramMeta.h:712
int32 getStepSize() const
returns step size
Definition: paramMeta.h:191
ito::ByteArray getUnit() const
returns unit
Definition: paramMeta.h:142
Meta-information for Param of type DoubleIntervalMeta.
Definition: paramMeta.h:588
ito::ByteArray getUnit() const
returns unit
Definition: paramMeta.h:253
tType
Definition: paramMeta.h:357
int getMinDim() const
returns maximum allowed dimensions of data object
Definition: paramMeta.h:428
MetaRtti getType() const
returns runtime type information value
Definition: paramMeta.h:111