itom  4.1.0
paramHelper.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.
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  itom is distributed in the hope that it will be useful, but
15  WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
17  General Public Licence for more details.
18 
19  You should have received a copy of the GNU Library General Public License
20  along with itom. If not, see <http://www.gnu.org/licenses/>.
21 *********************************************************************** */
22 
23 #ifndef PARAMHELPER_H
24 #define PARAMHELPER_H
25 
26 #include "addInMgrDefines.h"
27 #include "../common/sharedStructures.h"
28 
29 #include <qmap.h>
30 #include <qsharedpointer.h>
31 
32 namespace ito
33 {
34  class AddInBase; //forward declaration
35 
36  class ADDINMGR_EXPORT ParamHelper
37  {
38  public:
39 
40  static tCompareResult compareParam(const ito::Param &paramTemplate, const ito::Param &param, ito::RetVal &ret);
41  static tCompareResult compareMetaParam(const ito::ParamMeta *metaTemplate, const ito::ParamMeta *meta, const char* nameTemplate, const char *name, ito::RetVal &ret);
42 
43  static ito::RetVal validateStringMeta(const ito::StringMeta *meta, const char* value, bool mandatory = false, const char* name = NULL);
44  static ito::RetVal validateDoubleMeta(const ito::DoubleMeta *meta, double value, const char* name = NULL);
45  static ito::RetVal validateDoubleMetaAndRoundToStepSize(const ito::DoubleMeta *meta, ito::ParamBase &doubleParam, bool allowRounding = true, const char* name = NULL);
46  static ito::RetVal validateDoubleMetaAndRoundToStepSize(const ito::DoubleMeta *meta, double &value, bool allowRounding = true, const char* name = NULL);
47  static ito::RetVal validateIntMeta(const ito::IntMeta *meta, int value, const char* name = NULL);
48  static ito::RetVal validateCharMeta(const ito::CharMeta *meta, char value, const char* name = NULL);
49  static ito::RetVal validateCharArrayMeta(const ito::ParamMeta *meta, const char* values, size_t len, const char* name = NULL);
50  static ito::RetVal validateIntArrayMeta(const ito::ParamMeta *meta, const int* values, size_t len, const char* name = NULL);
51  static ito::RetVal validateDoubleArrayMeta(const ito::ParamMeta *meta, const double* values, size_t len, const char* name = NULL);
52  static ito::RetVal validateHWMeta(const ito::HWMeta *meta, ito::AddInBase *value, bool mandatory = false, const char* name = NULL);
53  static ito::RetVal validateParam(const ito::Param &templateParam, const ito::ParamBase &param, bool strict = true, bool mandatory = false);
54  static ito::RetVal validateAndCastParam(const ito::Param &templateParam, ito::ParamBase &param, bool strict = true, bool mandatory = false, bool roundToSteps = false);
55  static ito::ParamBase convertParam(const ito::ParamBase &source, int destType, bool *ok = NULL);
56  static ito::RetVal getParamFromMapByKey( QMap<QString,ito::Param> &paramMap, const QString &key, QMap<QString,ito::Param>::iterator &found, bool errorIfReadOnly);
57  static ito::RetVal parseParamName(const QString &name, QString &paramName, bool &hasIndex, int &index, QString &additionalTag);
58 
59  static ito::RetVal getItemFromArray(const ito::Param &arrayParam, const int index, ito::Param &itemParam);
60  static ito::Param getParam(const ito::Param &param, const bool hasIndex, const int index, ito::RetVal &ret);
61 
62  static ito::RetVal updateParameters(QMap<QString, ito::Param> &paramMap, const QVector<QSharedPointer<ito::ParamBase> > &values);
63 
64  private:
65  static bool fitToDoubleStepSize(double min, double step, double val);
66  static QString parseNamePrefix(const char *name);
67 
68  ParamHelper(){};
69  ~ParamHelper(){};
70  };
71 } //end namespace ito
72 
73 #endif
74 
Definition: paramHelper.h:36
Meta-information for Param of type Int.
Definition: paramMeta.h:183
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:283
Base class for all plugins.
Definition: addInInterface.h:385
PyObject * getParam(ito::AddInBase *addInObj, PyObject *args)
Definition: pythonPlugins.cpp:868
tCompareResult
Definition: typeDefs.h:66
Definition: apiFunctionsGraph.cpp:39
Meta-information for ito::Param of type Double.
Definition: paramMeta.h:233
meta-information for Param of type Char.
Definition: paramMeta.h:132
Meta-information for Param of type HWPtr.
Definition: paramMeta.h:302
Base class for all meta-information classes.
Definition: paramMeta.h:59
Definition: param.h:67
Meta-information for Param of type String.
Definition: paramMeta.h:354
ito::RetVal ITOMCOMMONQT_EXPORT parseParamName(const QString &name, QString &paramName, bool &hasIndex, int &index, QString &additionalTag)
parses parameter name with respect to regular expression, assigned for parameter-communcation with pl...
Definition: helperCommon.cpp:413