itom 1.3.0
D:/git-itom/sources/itom/Qitom/python/pythonCommon.h
00001 /* ********************************************************************
00002     itom software
00003     URL: http://www.uni-stuttgart.de/ito
00004     Copyright (C) 2013, Institut fuer Technische Optik (ITO),
00005     Universitaet Stuttgart, Germany
00006 
00007     This file is part of itom.
00008   
00009     itom is free software; you can redistribute it and/or modify it
00010     under the terms of the GNU Library General Public Licence as published by
00011     the Free Software Foundation; either version 2 of the Licence, or (at
00012     your option) any later version.
00013 
00014     itom is distributed in the hope that it will be useful, but
00015     WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library
00017     General Public Licence for more details.
00018 
00019     You should have received a copy of the GNU Library General Public License
00020     along with itom. If not, see <http://www.gnu.org/licenses/>.
00021 *********************************************************************** */
00022 
00023 #ifndef PYTHONCOMMON_H
00024 #define PYTHONCOMMON_H
00025 
00026 #ifndef NPY_1_7_API_VERSION
00027     #define NPY_1_7_API_VERSION 0x00000007
00028 #endif
00029 #ifndef NPY_1_8_API_VERSION
00030     #define NPY_1_8_API_VERSION 0x00000008
00031 #endif
00032 
00033 #include "pythonPlugins.h"
00034 #include "pythonDataObject.h"
00035 #include "pythonPCL.h"
00036 
00037 #include "../common/sharedStructures.h"
00038 
00039 #include <qvector.h>
00040 #include <qvariant.h>
00041 
00042 namespace ito
00043 {
00044 
00045     ito::RetVal checkAndSetParamVal(PyObject *tempObj, ito::Param *param, int *set);
00046     ito::RetVal checkAndSetParamVal(PyObject *pyObj, const ito::Param *defaultParam, ito::ParamBase &outParam, int *set);
00048     PyObject* PrntOutParams(const QVector<ito::Param> *params, bool asErr, bool addInfos, const int num, bool printToStdStream = true);
00049     void errOutInitParams(const QVector<ito::Param> *params, const int num, const QString reason);
00050     ito::RetVal parseInitParams(QVector<ito::Param> *initParamListMand, QVector<ito::Param> *initParamListOpt, PyObject *args, PyObject *kwds);
00051     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);
00052     ito::RetVal copyParamVector(const QVector<ito::ParamBase> *paramVecIn, QVector<ito::ParamBase> &paramVecOut);
00053     ito::RetVal copyParamVector(const QVector<ito::Param> *paramVecIn, QVector<ito::Param> &paramVecOut);
00054     ito::RetVal copyParamVector(const QVector<ito::Param> *paramVecIn, QVector<ito::ParamBase> &paramVecOut);
00055     ito::RetVal createEmptyParamBaseFromParamVector(const QVector<ito::Param> *paramVecIn, QVector<ito::ParamBase> &paramVecOut);
00056 
00058     ito::RetVal findAndDeleteReservedInitKeyWords(PyObject *kwds, bool * enableAutoLoadParams);
00059 
00060     //PyObject* transformQVariant2PyObject(QVariant *value, ito::RetVal &retValue);
00061     PyObject* buildFilterOutputValues(QVector<QVariant> *outVals, ito::RetVal &retValue);
00062 
00063     class PythonCommon
00064     {
00065         public:
00066 
00067                         enum tErrMsg
00068             {
00069                 noMsg = 0,
00070                 loadPlugin = 1,
00071                 execFunc = 2,
00072                 invokeFunc = 3,
00073                 getProperty = 4,
00074                 runFunc = 5
00075             
00076             };
00077 
00078             static bool transformRetValToPyException(ito::RetVal &retVal, PyObject *exceptionIfError = PyExc_RuntimeError);
00079             static bool setReturnValueMessage(ito::RetVal &retVal, const QString &objName, const tErrMsg &errorMSG, PyObject *exceptionIfError = PyExc_RuntimeError);
00080             static bool setReturnValueMessage(ito::RetVal &retVal, const char *objName, const tErrMsg &errorMSG, PyObject *exceptionIfError = PyExc_RuntimeError);
00081             //static bool setLoadPluginReturnValueMessage(ito::RetVal &retval, QString &pluginName);
00082             //static bool setLoadPluginReturnValueMessage(ito::RetVal &retval, const char *pluginName);
00083             //static bool setReturnValueMessage(ito::RetVal &retval, QString &functionName);
00084             //static bool setReturnValueMessage(ito::RetVal &retval, const char *functionName);
00085 
00086 
00087             
00088 
00089     };
00090 
00091 } //end namespace ito
00092 
00093 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends