/[ascend]/trunk/pygtk/interface/solverreporter.cpp
ViewVC logotype

Contents of /trunk/pygtk/interface/solverreporter.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 309 - (show annotations) (download) (as text)
Thu Feb 23 01:16:08 2006 UTC (18 years, 3 months ago) by johnpye
File MIME type: text/x-c++src
File size: 1162 byte(s)
See http://www.swig.org/Doc1.3/Typemaps.html
1 #include "solverreporter.h"
2 #include <iostream>
3 using namespace std;
4
5 SolverReporter::SolverReporter(){
6 // nothing
7 }
8
9 SolverReporter::~SolverReporter(){
10 // nothing
11 }
12
13 SolverReporter::report(const SolverStatus &status) const;
14 cerr << "Iteration: " << status.getIterationNum() << endl;
15 }
16
17 //-----
18
19 PythonSolverReporter::PythonSolverReporter(PyObject *pyfunc){
20 this->pyfunc = pyfunc;
21 Py_INCREF(pyfunc);
22 }
23
24 PythonSolverReporter::~PythonSolverReporter(){
25 Py_DECREF(this->pyfunc);
26 }
27
28 int
29 PythonSolverReporter::report(const SolverStatus *status) const;
30 PyObject pystatus, pyarglist, pyresult;
31 pystatus = SWIG_NewPointerObj((void *)status, SWIGTYPE_p_SolverStatus,1);
32 pyarglist = Py_BuildValue("(O)",pystatus); // THIS WON'T WORK :-D
33 pyresult = PyEval_CallObject(pyfunc,pyarglist);
34 Py_DECREF(pyarglist);
35 }
36
37
38 class SolverReporter{
39 public:
40 Reporter();
41 virtual ~Reporter();
42 virtual int report(const SolverStatus &) const;
43 };
44
45 #ifdef ASCXX_USE_PYTHON
46
47 class PythonSolverReporter{
48 private:
49
50 public:
51 PythonSolverReporter(PyObject *pyfunc);
52 ~PythonSolverReporter();
53
54 virtual int report(const SolverStatus &) const;
55 };
56
57 #endif
58
59 #endif // ASCXX_SOLVERREPORTER_H

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22