itom
Loading...
Searching...
No Matches
pythonItomMetaObject.h
1/* ********************************************************************
2 itom software
3 URL: http://www.uni-stuttgart.de/ito
4 Copyright (C) 2020, Institut für Technische Optik (ITO),
5 Universität 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 PYTHONITOMMETAOBJECT_H
24#define PYTHONITOMMETAOBJECT_H
25
26#include "../global.h"
27
28#include <qbytearray.h>
29#include <qmetaobject.h>
30
31namespace ito
32{
33
35 {
36 PythonQObjectMarshal() : m_objectID(0), m_object(NULL) {}
37
38 PythonQObjectMarshal(QByteArray objName, const char* className, QObject *object) :
39 m_objName(objName),
40 m_objectID(0),
41 m_object(object)
42 {
43 m_className = QByteArray(className);
44 }
45
46 PythonQObjectMarshal(QObject *obj) :
47 m_objName(obj->objectName().toLatin1()),
48 m_objectID(0),
49 m_object(obj)
50 {
51 m_className = QByteArray(obj->metaObject()->className());
52 }
53
54 QByteArray m_objName;
55 QByteArray m_className;
56 unsigned int m_objectID;
57 QObject *m_object; //casted from QObject
58 };
59
60
61
62// MethodDescription
64{
65public:
68 QByteArray &name,
69 QByteArray &signature,
70 QMetaMethod::MethodType type,
71 QMetaMethod::Access access,
72 int methodIndex,
73 int retType,
74 int nrOfArgs,
75 int *argTypes
76 );
77 MethodDescription(QMetaMethod &method);
80
81 MethodDescription &operator=(const MethodDescription &other);
82
83 inline bool isValid() const { return (m_methodIndex >= 0); }
84 inline QMetaMethod::MethodType type() const { return m_type; }
85 inline QMetaMethod::Access access() const { return m_access; }
86 inline int methodIndex() const { return m_methodIndex; }
87 inline QByteArray name() const { return m_name; }
88 inline int retType() const { return m_retType; }
89 inline int nrOfArgs() const { return m_nrOfArgs; }
90 inline int* argTypes() const { return m_argTypes; }
91 inline QByteArray signature() const { return m_signature; }
93 inline bool checkMethod(QByteArray &name, int nrOfArgs) const { return (name == m_name && nrOfArgs == m_nrOfArgs); }
94
95private:
96 QByteArray m_name;
98 QByteArray m_signature;
99 QMetaMethod::MethodType m_type;
100 QMetaMethod::Access m_access;
105};
106
107typedef QList<MethodDescription> MethodDescriptionList;
108
122{
123public:
125
131 FctCallParamContainer(int nrOfParams) :
132 m_nrOfParams(nrOfParams),
133 m_sizeArgs(nrOfParams+1)
134 {
135 m_args = new void*[m_sizeArgs];
136 m_argTypes = new int[m_sizeArgs];
137
138 for (int i = 0; i < m_sizeArgs; i++)
139 {
140 m_args[i] = nullptr;
141 m_argTypes[i] = -1;
142 }
143 };
144
146
151 {
152 for (int i = 0; i < m_sizeArgs; i++)
153 {
154 QMetaType(m_argTypes[i]).destroy(m_args[i]);
155 }
156
157 DELETE_AND_SET_NULL_ARRAY(m_argTypes);
158 DELETE_AND_SET_NULL_ARRAY(m_args);
159 }
160
161 inline void** args() { return m_args; };
162 inline int* argTypes() { return m_argTypes; };
163 inline int getRetType() const { return m_argTypes[0]; };
166
172 inline void initRetArg(int type) //reference of ptr is stolen and will be deleted by this class
173 {
174 if (m_args[0])
175 {
176 QMetaType(m_argTypes[0]).destroy(m_args[0]);
177 }
178
179 m_argTypes[0] = type;
180 m_args[0] = QMetaType(type).create(nullptr);
181 };
182
184
194 inline void setParamArg(unsigned int index, void* ptr, int type) //reference of ptr is stolen and will be deleted by this class
195 {
196 if ((int)index < 0 || (int)index >= m_nrOfParams)
197 {
198 return;
199 }
200
201 if (m_args[index + 1])
202 {
203 QMetaType(m_argTypes[index + 1]).destroy(m_args[index + 1]);
204 }
205
206 m_args[index+1] = ptr;
207 m_argTypes[index+1] = type;
208 };
209
210private:
212 FctCallParamContainer( const FctCallParamContainer & /*copy*/ ) = delete;
215 void** m_args;
217};
218
219} //end namespace ito
220
221#endif // PYTHONITOMMETAOBJECT_H
each instance of this class contains the parameters (including return parameter) for any function cal...
Definition pythonItomMetaObject.h:122
int * m_argTypes
Definition pythonItomMetaObject.h:216
int m_nrOfParams
Definition pythonItomMetaObject.h:213
FctCallParamContainer(const FctCallParamContainer &)=delete
copy constructor is not accessible
~FctCallParamContainer()
destructor
Definition pythonItomMetaObject.h:150
int getRetType() const
Definition pythonItomMetaObject.h:163
void initRetArg(int type)
initializes the return value
Definition pythonItomMetaObject.h:172
int m_sizeArgs
Definition pythonItomMetaObject.h:214
void ** m_args
Definition pythonItomMetaObject.h:215
void setParamArg(unsigned int index, void *ptr, int type)
stores a pair of variable-type and corresponding void-pointer as parameter with given index number
Definition pythonItomMetaObject.h:194
FctCallParamContainer(int nrOfParams)
constructor
Definition pythonItomMetaObject.h:131
int * argTypes()
Definition pythonItomMetaObject.h:162
Small wrapper class with all necessary information for any method, signal or slot of class which shou...
Definition pythonItomMetaObject.h:64
QMetaMethod::Access m_access
Definition pythonItomMetaObject.h:100
int methodIndex() const
Definition pythonItomMetaObject.h:86
int retType() const
Definition pythonItomMetaObject.h:88
QByteArray m_signature
Definition pythonItomMetaObject.h:98
QMetaMethod::Access access() const
Definition pythonItomMetaObject.h:85
int * argTypes() const
Definition pythonItomMetaObject.h:90
QByteArray m_name
Definition pythonItomMetaObject.h:96
int m_retType
Definition pythonItomMetaObject.h:101
QByteArray name() const
Definition pythonItomMetaObject.h:87
int nrOfArgs() const
Definition pythonItomMetaObject.h:89
int m_nrOfArgs
Definition pythonItomMetaObject.h:102
QByteArray signature() const
Definition pythonItomMetaObject.h:91
bool isValid() const
Definition pythonItomMetaObject.h:83
QMetaMethod::MethodType m_type
Definition pythonItomMetaObject.h:99
QMetaMethod::MethodType type() const
Definition pythonItomMetaObject.h:84
int m_methodIndex
Definition pythonItomMetaObject.h:97
int * m_argTypes
Definition pythonItomMetaObject.h:103
Definition apiFunctionsGraph.cpp:40
Definition pythonItomMetaObject.h:35