/[ascend]/trunk/ascxx/reporter.h
ViewVC logotype

Contents of /trunk/ascxx/reporter.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2327 - (show annotations) (download) (as text)
Wed Dec 22 07:17:24 2010 UTC (8 years, 11 months ago) by jpye
File MIME type: text/x-chdr
File size: 2261 byte(s)
Merging in refactor of the C++ code, which is moved out of 'pygtk' and into 'ascxx'.
Adding support for IPOPT 3.9.1, the current latest version.
Support in dtar for parallel builds (possibly needs some testing still).
1 /* ASCEND modelling environment
2 Copyright (C) 2006-2010 Carnegie Mellon University
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA.
18 */
19 #ifndef ASCXX_REPORTER_H
20 #define ASCXX_REPORTER_H
21
22 #include "config.h"
23
24 #ifdef ASCXX_USE_PYTHON
25 # include <Python.h>
26 #endif
27
28 extern "C"{
29 #include <ascend/general/platform.h>
30 #include <ascend/utilities/error.h>
31 }
32
33
34 #ifdef ASCXX_USE_PYTHON
35 extern "C"{
36 /**
37 This function is a hook function that will convey errors
38 back to Python via the C++ 'Reporter' class.
39 */
40 ASC_EXPORT int reporter_error_python(ERROR_REPORTER_CALLBACK_ARGS);
41 }
42 #endif
43
44 /**
45 This class provides C++ abstraction of the error.h error callback
46 interface.
47
48 Initially, it's trying to just handling the conveying of error
49 messages back to python, but it could be used to pass back
50 all sorts of other 'messages' eventually.
51
52 Maybe raising alerts, notifying of the progress of big tasks, etc.
53
54 The client_data pointer allows callback context to be set. This will
55 be used to specify which Python function should be used for error
56 reporting, in the case of the Python extension to this class.
57 */
58 class Reporter{
59 private:
60 void *client_data;
61 Reporter(); // This class will be a singleton
62 ~Reporter();
63 static Reporter *_instance;
64 #ifdef ASCXX_USE_PYTHON
65 bool is_python;
66 #endif
67
68 public:
69 static ASC_EXPORT Reporter * Instance();
70 void setErrorCallback(error_reporter_callback_t, void *client_data=NULL);
71
72 #ifdef ASCXX_USE_PYTHON
73 void setPythonErrorCallback(PyObject *pyfunc);
74 void clearPythonErrorCallback();
75 int reportErrorPython(ERROR_REPORTER_CALLBACK_ARGS);
76 #endif
77
78 };
79
80 Reporter *getReporter();
81
82 #endif // ASCXX_REPORTER_H

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