summaryrefslogtreecommitdiff
path: root/python/progress.h
blob: 5859eea052c54261ee9cca717090dea2ef435392 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef PROGRESS_H
#define PROGRESS_H

#include<iostream>

struct PyOpProgressStruct : public OpProgress
{

   PyObject *py_update_callback_func;
   PyObject *py_update_callback_args;

   virtual void Update() {
      if(py_update_callback_func == 0)
	 return;

      // Build up the argument list... 
      PyObject *arglist = Py_BuildValue("fO", Percent,py_update_callback_args);

      // ...for calling the Python compare function.
      PyObject *result = PyEval_CallObject(py_update_callback_func,arglist);

      Py_XDECREF(result);
      Py_DECREF(arglist);

      return;
   };

   PyOpProgressStruct() : OpProgress(), py_update_callback_func(0) {};
};

#endif