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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 500 - (show annotations) (download) (as text)
Tue Apr 18 11:55:12 2006 UTC (15 years, 7 months ago) by johnpye
File MIME type: text/x-c++src
File size: 2171 byte(s)
Reduced some runtime debug messages from Python and C++ and base/generic/compiler/type_descio.c.
Fixed up support for GCC Visibility and add SCons 'sniffer' for this.
Fixed a bug with 'fileopenpath' in PyGTK interface (File->Open location is remembered from last time).
Fixed a bug with missing includes in C++.
1 #include <stdexcept>
2 #include <iostream>
3 #include <sstream>
4 using namespace std;
5
6 #include "reporter.h"
7 #include "solver.h"
8
9 extern "C"{
10 #include <solver/slv0.h>
11 #include <solver/slv1.h>
12 #include <solver/slv2.h>
13 #include <solver/slv3.h>
14 #include <solver/slv9.h>
15 }
16
17 /**
18 Create a solver by name (it must already be registered)
19 Warning, this ctor throws an exception if the name is invalid!
20 */
21 Solver::Solver(const string &name){
22 //cerr << "CREATING SOLVER, name = " << name << endl;
23 this->name = name;
24 }
25
26 Solver::Solver(const Solver &old){
27 this->name = old.name;
28 //cerr << "COPIED SOLVER, name = " << name << endl;
29 }
30
31 const int
32 Solver::getIndex() const{
33 int index = slv_lookup_client(name.c_str());
34 if(index < 0){
35 stringstream ss;
36 ss << "Unknown or unregistered solver '" << name << "'";
37 throw runtime_error(ss.str());
38 }
39 //cerr << "))))))))))))))SOLVER INDEX RETURNED IS " << index << endl;
40 return index;
41 }
42
43 const string &
44 Solver::getName() const{
45 return name;
46 }
47
48 //---------------------------------
49 // >>>> GLOBAL FUNCTIONS <<<<
50 // for registering solvers and querying the complete list
51
52 void
53 registerSolver(SlvRegistration regfuncptr){
54 int newclient =-1;
55 int res = slv_register_client(regfuncptr,NULL,NULL,&newclient);
56 if(res!=0){
57 ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"Unable to register solver");
58 throw runtime_error("Solver::registerSolver: Unable to register solver");
59 }else{
60 string name = slv_solver_name(newclient);
61 cerr << "Registered solver '" << name << "' (index " << newclient << ")" << endl;
62 }
63 }
64
65 const vector<Solver>
66 getSolvers(){
67 extern int g_SlvNumberOfRegisteredClients;
68 vector<Solver> v;
69 for(int i=0; i < g_SlvNumberOfRegisteredClients; ++i){
70 v.push_back(Solver(slv_solver_name(i)));
71 }
72 return v;
73 }
74
75 /**
76 Register the solvers which will be accessible via index number. The order you
77 register them determines the resulting index ids, so don't mess around with the
78 order of stuff in this function.
79
80 Add to this list as you feel necessary...
81 */
82 void
83 registerStandardSolvers(){
84 //cerr << "------------- REGISTERING SOLVERS -----------------" << endl;
85 registerSolver(slv3_register);
86 registerSolver(slv9_register);
87 }
88

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