itom  3.0.0
pythonCommon.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.
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 PYTHONCOMMON_H
24 #define PYTHONCOMMON_H
25 
26 #ifndef NPY_1_7_API_VERSION
27  #define NPY_1_7_API_VERSION 0x00000007
28 #endif
29 #ifndef NPY_1_8_API_VERSION
30  #define NPY_1_8_API_VERSION 0x00000008
31 #endif
32 
33 #ifndef Q_MOC_RUN
34  /* includes */
35  //python
36  // see http://vtk.org/gitweb?p=VTK.git;a=commitdiff;h=7f3f750596a105d48ea84ebfe1b1c4ca03e0bab3
37  #if (defined _DEBUG) && (defined WIN32)
38  #undef _DEBUG
39  #include "Python.h"
40  #define _DEBUG
41  #else
42  #include "Python.h"
43  #endif
44 #endif
45 
46 #include "../../common/sharedStructures.h"
47 
48 #include <qvector.h>
49 #include <qvariant.h>
50 
51 namespace ito
52 {
53 
54  ito::RetVal checkAndSetParamVal(PyObject *tempObj, ito::Param *param, int *set);
55  ito::RetVal checkAndSetParamVal(PyObject *pyObj, const ito::Param *defaultParam, ito::ParamBase &outParam, int *set);
57  PyObject* PrntOutParams(const QVector<ito::Param> *params, bool asErr, bool addInfos, const int num, bool printToStdStream = true);
58  PyObject *parseParamMetaAsDict(const ito::ParamMeta *meta);
59  void errOutInitParams(const QVector<ito::Param> *params, const int num, const char *reason);
60  ito::RetVal parseInitParams(const QVector<ito::Param> *defaultParamListMand, const QVector<ito::Param> *defaultParamListOpt, PyObject *args, PyObject *kwds, QVector<ito::ParamBase> &paramListMandOut, QVector<ito::ParamBase> &paramListOptOut);
61  ito::RetVal copyParamVector(const QVector<ito::ParamBase> *paramVecIn, QVector<ito::ParamBase> &paramVecOut);
62  ito::RetVal copyParamVector(const QVector<ito::Param> *paramVecIn, QVector<ito::Param> &paramVecOut);
63  ito::RetVal copyParamVector(const QVector<ito::Param> *paramVecIn, QVector<ito::ParamBase> &paramVecOut);
64  ito::RetVal createEmptyParamBaseFromParamVector(const QVector<ito::Param> *paramVecIn, QVector<ito::ParamBase> &paramVecOut);
65 
67  ito::RetVal findAndDeleteReservedInitKeyWords(PyObject *kwds, bool * enableAutoLoadParams);
68 
69  PyObject* buildFilterOutputValues(QVector<QVariant> *outVals, ito::RetVal &retValue);
70 
72  {
73  public:
74 
75  enum tErrMsg
76  {
77  noMsg = 0,
78  loadPlugin = 1,
79  execFunc = 2,
80  invokeFunc = 3,
81  getProperty = 4,
82  runFunc = 5
83 
84  };
85 
86  static bool transformRetValToPyException(ito::RetVal &retVal, PyObject *exceptionIfError = PyExc_RuntimeError, PyObject *exceptionIfWarning = PyExc_RuntimeWarning);
87  static bool setReturnValueMessage(ito::RetVal &retVal, const QString &objName, const tErrMsg &errorMSG, PyObject *exceptionIfError = PyExc_RuntimeError, PyObject *exceptionIfWarning = PyExc_RuntimeWarning);
88  static bool setReturnValueMessage(ito::RetVal &retVal, const char *objName, const tErrMsg &errorMSG, PyObject *exceptionIfError = PyExc_RuntimeError, PyObject *exceptionIfWarning = PyExc_RuntimeWarning);
89  };
90 
91 } //end namespace ito
92 
93 #endif
ito::RetVal createEmptyParamBaseFromParamVector(const QVector< ito::Param > *paramVecIn, QVector< ito::ParamBase > &paramVecOut)
This function searches for reserves Keywords (e.g. autoLoadParams) sets the corresponding bool parame...
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
void errOutInitParams(const QVector< ito::Param > *params, const int num, const char *reason)
Definition: pythonCommon.cpp:872
ito::RetVal checkAndSetParamVal(PyObject *tempObj, ito::Param *param, int *set)
Definition: pythonCommon.cpp:49
Definition: apiFunctionsGraph.cpp:39
ito::RetVal copyParamVector(const QVector< ito::ParamBase > *paramVecIn, QVector< ito::ParamBase > &paramVecOut)
Definition: pythonCommon.cpp:1210
ito::RetVal findAndDeleteReservedInitKeyWords(PyObject *kwds, bool *enableAutoLoadParams)
Definition: pythonCommon.cpp:1273
Definition: pythonCommon.h:71
Base class for all meta-information classes.
Definition: paramMeta.h:59
Definition: param.h:67