VTK
vtkPythonUtil.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkPythonUtil.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 
19 #ifndef vtkPythonUtil_h
20 #define vtkPythonUtil_h
21 
22 #include "vtkPython.h"
23 #include "vtkPythonCompatibility.h"
24 #include "PyVTKMutableObject.h"
25 #include "PyVTKNamespace.h"
26 #include "PyVTKObject.h"
27 #include "PyVTKSpecialObject.h"
28 
29 class vtkPythonClassMap;
30 class vtkPythonCommand;
31 class vtkPythonCommandList;
32 class vtkPythonGhostMap;
33 class vtkPythonObjectMap;
34 class vtkPythonSpecialTypeMap;
35 class vtkPythonNamespaceMap;
36 class vtkPythonEnumMap;
37 class vtkStdString;
38 class vtkUnicodeString;
39 class vtkVariant;
40 
41 extern "C" void vtkPythonUtilDelete();
42 
44 {
45 public:
46 
49  static const char *PythonicClassName(const char *classname);
50 
52  static const char *StripModule(const char *tpname);
53 
55 
57  static PyVTKClass *AddClassToMap(
58  PyTypeObject *pytype, PyMethodDef *methods,
59  const char *classname, vtknewfunc constructor);
61 
63  static PyVTKClass *FindClass(const char *classname);
64 
68  static PyVTKClass *FindNearestBaseClass(vtkObjectBase *ptr);
69 
71 
75  static vtkObjectBase *GetPointerFromObject(PyObject *obj,
76  const char *classname);
78 
83  static PyObject *GetObjectFromPointer(vtkObjectBase *ptr);
84 
88  static void *SIPGetPointerFromObject(PyObject *obj, const char *classname);
89 
91 
93  static PyObject *SIPGetObjectFromPointer(
94  const void *ptr, const char* classname, bool is_new);
96 
99  static PyObject *GetObjectFromObject(PyObject *arg, const char *type);
100 
104  static void AddObjectToMap(PyObject *obj, vtkObjectBase *anInstance);
105 
108  static void RemoveObjectFromMap(PyObject *obj);
109 
111 
113  static PyVTKSpecialType *AddSpecialTypeToMap(
114  PyTypeObject *pytype, PyMethodDef *methods, PyMethodDef *constructors,
115  vtkcopyfunc copyfunc);
117 
119  static PyVTKSpecialType *FindSpecialType(const char *classname);
120 
122 
129  static void *GetPointerFromSpecialObject(
130  PyObject *obj, const char *result_type, PyObject **newobj);
132 
135  static void AddNamespaceToMap(PyObject *o);
136 
139  static void RemoveNamespaceFromMap(PyObject *o);
140 
142  static PyObject *FindNamespace(const char *name);
143 
145  static void AddEnumToMap(PyTypeObject *o);
146 
148  static PyTypeObject *FindEnum(const char *name);
149 
152  static PyObject *BuildDocString(const char *docstring[]);
153 
155  static char *ManglePointer(const void *ptr, const char *type);
156 
158  static void *UnmanglePointer(char *ptrText, int *len, const char *type);
159 
161  static Py_hash_t VariantHash(const vtkVariant *variant);
162 
164 
169  static void RegisterPythonCommand(vtkPythonCommand*);
170  static void UnRegisterPythonCommand(vtkPythonCommand*);
172 
173 private:
174  vtkPythonUtil();
175  ~vtkPythonUtil();
176  vtkPythonUtil(const vtkPythonUtil&); // Not implemented.
177  void operator=(const vtkPythonUtil&); // Not implemented.
178 
179  vtkPythonObjectMap *ObjectMap;
180  vtkPythonGhostMap *GhostMap;
181  vtkPythonClassMap *ClassMap;
182  vtkPythonSpecialTypeMap *SpecialTypeMap;
183  vtkPythonNamespaceMap *NamespaceMap;
184  vtkPythonEnumMap *EnumMap;
185  vtkPythonCommandList *PythonCommandList;
186 
187  friend void vtkPythonUtilDelete();
188  friend void vtkPythonUtilCreateIfNeeded();
189 };
190 
191 // For use by SetXXMethod() , SetXXMethodArgDelete()
194 
195 #endif
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:46
void vtkPythonUtilDelete()
A atomic type representing the union of many types.
Definition: vtkVariant.h:78
VTKWRAPPINGPYTHONCORE_EXPORT void vtkPythonVoidFuncArgDelete(void *)
#define VTKWRAPPINGPYTHONCORE_EXPORT
abstract base class for most VTK objects
Definition: vtkObjectBase.h:59
VTKWRAPPINGPYTHONCORE_EXPORT void vtkPythonVoidFunc(void *)
struct _object PyObject
long Py_hash_t
String class that stores Unicode text.