/[ascend]/trunk/ascxx/extmethod.cpp
ViewVC logotype

Contents of /trunk/ascxx/extmethod.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2327 - (show annotations) (download) (as text)
Wed Dec 22 07:17:24 2010 UTC (13 years, 8 months ago) by jpye
File MIME type: text/x-c++src
File size: 1479 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 #include "extmethod.h"
2
3 #include <stdexcept>
4 using namespace std;
5
6 #ifndef ASCXX_USE_PYTHON
7 # error "Where's ASCXX_USE_PYTHON?"
8 #endif
9
10 /*--- WARNING ---
11 In the C++ interface I'm trying to make the nomenclature
12 a bit more systematic. 'ExternalFunc' as listed end up
13 being things that you can call like 'asc_free_all_vars' --
14 they are effectively externally-defined methods on ASCEND
15 models, so I'll call then 'external methods'.
16
17 Meanwhile, external relations I will call 'ExtRelation'.
18
19 External functions, if ever implemented, will be for
20 functions like 'sin', 'exp', etc.
21 */
22
23 ExtMethod::ExtMethod(const struct ExternalFunc *e) : e(e) {
24 // nothing else
25 }
26
27 ExtMethod::ExtMethod(const ExtMethod &old) : e(old.e) {
28 // nothing else
29 }
30
31 ExtMethod::ExtMethod(){
32 throw runtime_error("Can't create empty ExtMethod");
33 }
34
35 #ifdef ASCXX_USE_PYTHON
36 /**
37 Declare and register a new external script method from Python
38
39 @TODO not sure if this is the right place for this... problems when creating
40 the method might cause problems. Perhaps it should be in the 'library'
41 object instead?
42 */
43 ExtMethod::ExtMethod(PyObject *obj){
44 throw runtime_error("Not allowed here");
45 }
46 #endif
47
48
49 const char *
50 ExtMethod::getName() const{
51 return ExternalFuncName(e);
52 }
53
54 const char *
55 ExtMethod::getHelp() const{
56 return e->help;
57 }
58
59 const unsigned long
60 ExtMethod::getNumInputs() const{
61 return NumberInputArgs(e);
62 }
63
64 const unsigned long
65 ExtMethod::getNumOutputs() const{
66 return NumberOutputArgs(e);
67 }

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