itom  3.0.0
pythonUiTimer.h
1 /* ********************************************************************
2  itom software
3  URL: http://www.uni-stuttgart.de/ito
4  Copyright (C) 2016, 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 #ifndef PYTHONUITIMER_H
24 #define PYTHONUITIMER_H
25 
26 #include "pythonCommon.h"
27 
28 #include <qobject.h>
29 
30 class QTimer; //forward declaration
31 
32 namespace ito
33 {
34 
35 class TimerCallback : public QObject
36 {
37  Q_OBJECT
38  public:
39  TimerCallback() : m_function(NULL), m_boundedInstance(NULL), m_callbackArgs(0), m_boundedMethod(0) {}
40  ~TimerCallback() {}
41  PyObject *m_function; //pyFunctionObject
42  PyObject *m_boundedInstance; //self if bounded method, else null
43  PyObject *m_callbackArgs;
44  bool m_boundedMethod;
45 
46  public slots:
47  void timeout();
48 };
49 
51 {
52 public:
53 
54  //-------------------------------------------------------------------------------------------------
55  // typedefs
56  //-------------------------------------------------------------------------------------------------
57  typedef struct
58  {
59  PyObject_HEAD
60  QTimer *timer;
61  TimerCallback *callbackFunc;
62  }
63  PyTimer;
64 
65  //-------------------------------------------------------------------------------------------------
66  // Timer
67  //-------------------------------------------------------------------------------------------------
68  static void PyTimer_dealloc(PyTimer *self);
69  static PyObject *PyTimer_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
70  static int PyTimer_init(PyTimer *self, PyObject *args, PyObject *kwds);
71  static PyObject *PyTimer_repr(PyTimer *self);
72 
73  static PyGetSetDef PyTimer_getseters[];
74  static PyMemberDef PyTimer_members[];
75  static PyMethodDef PyTimer_methods[];
76  static PyTypeObject PyTimerType;
77  static PyModuleDef PyTimerModule;
78  static PyObject *PyTimer_start(PyTimer *self);
79  static PyObject *PyTimer_stop(PyTimer *self);
80  static PyObject *PyTimer_isActive(PyTimer *self);
81  static PyObject *PyTimer_setInterval(PyTimer *self, PyObject *args);
82 
83 };
84 
85 }; //end namespace ito
86 
87 #endif
Definition: pythonUiTimer.h:57
Definition: pythonUiTimer.h:35
Definition: apiFunctionsGraph.cpp:39
Definition: pythonUiTimer.h:50