itom  4.1.0
pythonStream.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2020, Institut fuer Technische Optik (ITO),
5  Universitaet 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 //###################
24 //# pythonStream.h #
25 //###################
26 
27 #ifndef PYTHONSTREAM_H
28 #define PYTHONSTREAM_H
29 
30 #ifndef Q_MOC_RUN
31  //python
32  // see http://vtk.org/gitweb?p=VTK.git;a=commitdiff;h=7f3f750596a105d48ea84ebfe1b1c4ca03e0bab3
33  #if (defined _DEBUG) && (defined WIN32)
34  #undef _DEBUG
35  #include "python/pythonWrapper.h"
36  #define _DEBUG
37  #else
38  #include "python/pythonWrapper.h"
39  #endif
40 #endif
41 
42 namespace ito
43 {
44 
45  class PyStream
46  {
47 
48  public:
49 
51  /*
52  The struct's name is PythonStream. This python type consists of the basic elements for every python type,
53  included an integer value type, which indicates whether this stream corresponds to the stream \a cout or \a cerr.
54  */
55  typedef struct
56  {
57  PyObject_HEAD
58  int type;
59  PyObject *encoding;
60  char closed;
61  }
63 
64  static void PythonStream_dealloc(PythonStream* self);
65  //static PyObject *PythonStream_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
66  static int PythonStream_init(PythonStream *self, PyObject *args, PyObject *kwds);
67 
68  static PyObject *PythonStream_name(PythonStream* self);
69  static PyObject *PythonStream_fileno(PythonStream* self);
70  static PyObject *PythonStream_write(PythonStream* self, PyObject *args);
71  static PyObject *PythonStream_flush(PythonStream* self, PyObject *args);
72  static PyObject *PythonStream_readline(PythonStream* self, PyObject *args);
73  static PyObject *PythonStream_isatty(PythonStream* self, PyObject *args);
74  static PyObject *PythonStream_seekable(PythonStream* self, PyObject *args);
75  static PyObject *PythonStream_writable(PythonStream* self, PyObject *args);
76  static PyObject *PythonStream_readable(PythonStream* self, PyObject *args);
77 
78  static PyMemberDef PythonStream_members[];
79  static PyMethodDef PythonStream_methods[];
80  static PyTypeObject PythonStreamType;
81  };
82 
83 } //end namespace ito
84 
85 
86 #endif
Definition: pythonStream.h:55
static PyTypeObject PythonStreamType
static PyTypeObject for type PyStream with function pointers to all required static methods...
Definition: pythonStream.h:80
static PyObject * PythonStream_write(PythonStream *self, PyObject *args)
static method invoked if string has been written to stream
Definition: pythonStream.cpp:170
static void PythonStream_dealloc(PythonStream *self)
static method which is called if variable of type PyStream in python workspace has been deleted in or...
Definition: pythonStream.cpp:43
static PyMemberDef PythonStream_members[]
static PyMemberDef table which describes every member of PyStream type
Definition: pythonStream.h:78
Definition: apiFunctionsGraph.cpp:39
static class which implements a new python type. The members cout and cerr of the python system are s...
Definition: pythonStream.h:45
static PyObject * PythonStream_isatty(PythonStream *self, PyObject *args)
setting IOBase params to False since help(bla) will open a terminal if True.idfc. ...
Definition: pythonStream.cpp:91
static PyMethodDef PythonStream_methods[]
static table of type PyMethodDef which contains function pointers and descriptions to all methods...
Definition: pythonStream.h:79
static PyObject * PythonStream_flush(PythonStream *self, PyObject *args)
static method is invoked if stream has been flushed
Definition: pythonStream.cpp:247
static int PythonStream_init(PythonStream *self, PyObject *args, PyObject *kwds)
static init method, which is called if any variable of type PyStream is initialized. This method extracts type value from args.
Definition: pythonStream.cpp:50
static PyObject * PythonStream_name(PythonStream *self)
static method returning name representation of this type
Definition: pythonStream.cpp:81
PyObject_HEAD int type
Definition: pythonStream.h:58