GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |
GeezerVison is showing mevislab.github.io — PythonQt: PythonQtObjectPtr.h Source File
PythonQtObjectPtr.h
Go to the documentation of this file.
1#ifndef _PYTHONQTOBJECTPTR_H
2#define _PYTHONQTOBJECTPTR_H
3
4/*
5 *
6 * Copyright (C) 2010 MeVis Medical Solutions AG All Rights Reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * Further, this software is distributed without any warranty that it is
19 * free of the rightful claim of any third person regarding infringement
20 * or the like. Any license provided herein, whether implied or
21 * otherwise, applies only to this software file. Patent licenses, if
22 * any, provided herein do not apply to combinations of this program with
23 * other software, or any other product whatsoever.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 *
29 * Contact information: MeVis Medical Solutions AG, Universitaetsallee 29,
30 * 28359 Bremen, Germany or:
31 *
32 * http://www.mevis.de
33 *
34 */
35
36//----------------------------------------------------------------------------------
43//----------------------------------------------------------------------------------
44
45#include "PythonQtPythonInclude.h"
46
47#include "PythonQtSystem.h"
48#include "PythonQtThreadSupport.h"
49#include <QVariant>
50#include <QVariantList>
51#include <QVariantMap>
52
54
57{
58public:
63
65 : _object(nullptr)
66 {
68 }
69
75
78
85
87
89
92
95
97 QVariant toLocalVariant();
98
100 {
102 return *this;
103 }
104
107 {
108 if (_object) {
110 }
111 _object = p.takeObject();
112 return *this;
113 }
114
117
123
129
131
133
135
137
139
141
143
145
148
150
153
157
160
163
166
169
172
175 const QVariantMap& kwargs = QVariantMap());
176
178 QVariant call(const QVariantList& args = QVariantList(), const QVariantMap& kwargs = QVariantMap());
179
188
189protected:
190
192
193private:
194 PyObject* _object;
195};
196
199{
200public:
205
207 : _object(nullptr)
208 {
210 }
211
213 : _object(nullptr)
214 {
216 }
217
220 : _object(p._object)
221 {
222 p._object = nullptr;
223 }
224
230
232
234
236 {
238 return *this;
239 }
240
242 {
244 return *this;
245 }
246
249 {
250 if (_object) {
252 }
253 _object = p._object;
254 p._object = nullptr;
255 return *this;
256 }
257
267
273
275
277
279
281
283
285
287
289
291
300
301protected:
304
305private:
306 PyObject* _object;
307};
308
309// We don't want QVariant to take PythonQtObjectPtr via QVariant::fromValue, because it is unsafe when using multi-threading/GIL
310// A QVariant can still be obtained with PythonQtObjectPtr::toLocalVariant().
311//Q_DECLARE_METATYPE(PythonQtObjectPtr)
312
313// register PythonQtSafeObjectPtr to the meta type system
314Q_DECLARE_METATYPE(PythonQtSafeObjectPtr)
315
316#endif
a smart pointer that stores a PyObject pointer and that handles reference counting automatically Definition PythonQtObjectPtr.h:57 QVariant call(const QVariantList &args=QVariantList(), const QVariantMap &kwargs=QVariantMap()) call the contained python object directly, returns the result converted to a QVariant PythonQtObjectPtr & operator=(const PythonQtObjectPtr &p) Definition PythonQtObjectPtr.h:99 PythonQtObjectPtr(PythonQtObjectPtr &&p) noexcept rvalue copy constructor, does not need any incref/decref. Definition PythonQtObjectPtr.h:71 void setObject(PyObject *o) void addVariable(const QString &name, const QVariant &v) add the given variable to the module PythonQtObjectPtr & operator=(PyObject *o) Definition PythonQtObjectPtr.h:118 void evalFile(const QString &filename) evaluates the given code in the context PythonQtObjectPtr & operator=(const QVariant &variant) Definition PythonQtObjectPtr.h:124 PythonQtObjectPtr(PyObject *o) PythonQtObjectPtr(const PythonQtObjectPtr &p) Definition PythonQtObjectPtr.h:64 PythonQtObjectPtr(PythonQtSafeObjectPtr &&p) rvalue copy constructor, does not need any incref/decref. QVariant toLocalVariant() Returns a PythonQtObjectPtr as a QVariant. Only use this when you know that the variant is only used ... PythonQtObjectPtr & operator=(PythonQtObjectPtr &&p) noexcept rvalue assignment operator that steals the reference from p Definition PythonQtObjectPtr.h:106 PythonQtObjectPtr & operator=(PythonQtSafeObjectPtr &&p) rvalue assignment operator that steals the reference from p ~PythonQtObjectPtr() QVariant evalScript(const QString &script, int start=Py_file_input) evaluates the given script code in the context of this object and returns the result value PythonQtObjectPtr(const QVariant &variant) If the given variant holds a PythonQtObjectPtr, extract the value from it and hold onto the reference... Definition PythonQtObjectPtr.h:80 bool operator!=(const PythonQtObjectPtr &p) const Definition PythonQtObjectPtr.h:132 QVariant toVariant() Returns a PythonQtSafeObjectPtr as a QVariant. It does not return a PythonQtObjectPtr,... void addObject(const QString &name, QObject *object) add the given object to the module as a variable with name (it can be removed via clearVariable) bool fromVariant(const QVariant &variant) If the given variant holds a PythonQtObjectPtr, extract the value from it and hold onto the reference... QVariant getVariable(const QString &name) get the variable with the name of the module, returns an invalid QVariant on error QVariant call(const QString &callable, const QVariantList &args=QVariantList(), const QVariantMap &kwargs=QVariantMap()) call the given python object (in the scope of the current object), returns the result converted to a ... bool operator==(const PythonQtObjectPtr &p) const Definition PythonQtObjectPtr.h:130 QVariant evalCode(PyObject *pycode) void setNewRef(PyObject *o) sets the object and passes the ownership (stealing the reference, in Python slang) a smart pointer that stores a PyObject pointer and that handles reference counting automatically Definition PythonQtObjectPtr.h:199 void setObject(PyObject *o) PythonQtSafeObjectPtr & operator=(PythonQtSafeObjectPtr &&p) noexcept rvalue assignment operator that steals the reference from p Definition PythonQtObjectPtr.h:248 void setObjectUnsafe(PyObject *o) PythonQtSafeObjectPtr(PythonQtSafeObjectPtr &&p) noexcept rvalue copy constructor, does not need any incref/decref. Definition PythonQtObjectPtr.h:219 PythonQtSafeObjectPtr(const PythonQtSafeObjectPtr &p) Definition PythonQtObjectPtr.h:206 PythonQtSafeObjectPtr() Definition PythonQtObjectPtr.h:201 PythonQtSafeObjectPtr & operator=(const PythonQtObjectPtr &p) Definition PythonQtObjectPtr.h:241 bool operator!=(PyObject *p) const Definition PythonQtObjectPtr.h:280 PythonQtSafeObjectPtr(PyObject *o) PythonQtSafeObjectPtr(PythonQtObjectPtr &&p) rvalue copy constructor, does not need any incref/decref. Definition PythonQtObjectPtr.h:226 bool operator==(PyObject *p) const Definition PythonQtObjectPtr.h:278 PythonQtSafeObjectPtr(const PythonQtObjectPtr &p) Definition PythonQtObjectPtr.h:212 PythonQtSafeObjectPtr & operator=(PythonQtObjectPtr &&p) rvalue assignment operator that steals the reference from p Definition PythonQtObjectPtr.h:259 ~PythonQtSafeObjectPtr() PythonQtSafeObjectPtr & operator=(PyObject *o) Definition PythonQtObjectPtr.h:268 PythonQtSafeObjectPtr & operator=(const PythonQtSafeObjectPtr &p) Definition PythonQtObjectPtr.h:235 bool operator!=(const PythonQtSafeObjectPtr &p) const Definition PythonQtObjectPtr.h:276 bool operator==(const PythonQtSafeObjectPtr &p) const Definition PythonQtObjectPtr.h:274 Generated on for PythonQt by | |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |