SourceForge.net Logo
PythonQt
PythonQtInstanceWrapper.h
Go to the documentation of this file.
1 #ifndef _PYTHONQTINSTANCEWRAPPER_H
2 #define _PYTHONQTINSTANCEWRAPPER_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 "PythonQtClassWrapper.h"
49 #include <QPointer>
50 
51 #include "structmember.h"
52 #include "methodobject.h"
53 #include "compile.h"
54 #include "eval.h"
55 
56 class PythonQtClassInfo;
57 class QObject;
58 
60 
61 //---------------------------------------------------------------
64  PyObject_HEAD
65 
68  { return ((PythonQtClassWrapper*)Py_TYPE(this))->_classInfo; }
69 
71  void setQObject(QObject* object) {
72  _obj = object;
73  _objPointerCopy = object;
74  }
75 
78  // we pass the ownership to C++
79  _ownedByPythonQt = false;
80  // handle shell instance
81  if (_isShellInstance) {
83  // ref count the wrapper, so that the Python part of the shell instance can not go
84  // away until the C++ object gets deleted...
85  Py_INCREF((PyObject*)this);
87  }
88  }
89  }
90 
93  _ownedByPythonQt = true;
94  // if the shell instance was owned by C++ and the ownership goes to Python,
95  // we need to remove the extra ref count that kept the Python part alive from the C++ side.
97  Py_DECREF((PyObject*)this);
99  }
100  }
101 
102 
104  QPointer<QObject> _obj;
108 
110  void* _wrappedPtr;
111 
112  // TODO xxx: put booleans into int that holds flags
113 
116 
119 
122 
125 
127 
129 
131 
132 #endif
133