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

Contents of /trunk/pygtk/solver.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 709 - (show annotations) (download) (as text)
Wed Jun 28 16:28:57 2006 UTC (17 years, 11 months ago) by johnpye
File MIME type: text/x-c++src
File size: 2198 byte(s)
Monster commit!
Lots of recommenting and reorganising of external relations-related stuff.
Replaced a lot of ascmalloc and asccalloc calls with the new ASC_NEW* macros.
Fixed (?) the problem Art is having with icons in PyGTK.
Turned on -Wall in SConstruct and fixed up a stack of warnings.
Removed the redundant exit(2) from after Asc_Panic calls and added __attribute__((noreturn)).
Set doxygen to create callgraphs to level 2, updated doxyfile to version 1.4.7.
Fixed up building of extfntest.c.
1 #include "config.h"
2 #include "reporter.h"
3 #include "solver.h"
4
5 #include <stdexcept>
6 #include <iostream>
7 #include <sstream>
8 using namespace std;
9
10 extern "C"{
11 #include <solver/system.h>
12 #include <solver/slvDOF.h>
13 #include <solver/slv_stdcalls.h>
14 }
15
16 /**
17 Create a solver by name (it must already be registered)
18 Warning, this ctor throws an exception if the name is invalid!
19 */
20 Solver::Solver(const string &name){
21 //cerr << "CREATING SOLVER, name = " << name << endl;
22 this->name = name;
23 }
24
25 Solver::Solver(const Solver &old){
26 this->name = old.name;
27 //cerr << "COPIED SOLVER, name = " << name << endl;
28 }
29
30 const int
31 Solver::getIndex() const{
32 int index = slv_lookup_client(name.c_str());
33 if(index < 0){
34 stringstream ss;
35 ss << "Unknown or unregistered solver '" << name << "'";
36 throw runtime_error(ss.str());
37 }
38 //cerr << "))))))))))))))SOLVER INDEX RETURNED IS " << index << endl;
39 return index;
40 }
41
42 const string &
43 Solver::getName() const{
44 return name;
45 }
46
47 //---------------------------------
48 // >>>> GLOBAL FUNCTIONS <<<<
49 // for registering solvers and querying the complete list
50
51 void
52 registerSolver(SlvRegistration regfuncptr){
53 int newclient =-1;
54 int res = slv_register_client(regfuncptr,NULL,NULL,&newclient);
55 if(res!=0){
56 ERROR_REPORTER_NOLINE(ASC_PROG_ERROR,"Unable to register solver");
57 throw runtime_error("Solver::registerSolver: Unable to register solver");
58 }else{
59 string name = slv_solver_name(newclient);
60 cerr << "Registered solver '" << name << "' (index " << newclient << ")" << endl;
61 }
62 }
63
64 const vector<Solver>
65 getSolvers(){
66 ASC_DLLSPEC(int) g_SlvNumberOfRegisteredClients;
67 vector<Solver> v;
68 for(int i=0; i < g_SlvNumberOfRegisteredClients; ++i){
69 v.push_back(Solver(slv_solver_name(i)));
70 }
71 return v;
72 }
73
74 /**
75 Register the solvers which will be accessible via index number. The order you
76 register them determines the resulting index ids, so don't mess around with the
77 order of stuff in this function.
78
79 Add to this list as you feel necessary...
80 */
81 void
82 registerStandardSolvers(){
83 //cerr << "------------- REGISTERING SOLVERS -----------------" << endl;
84 SlvRegisterStandardClients();
85 /*
86 registerSolver(slv3_register);
87 registerSolver(slv9_register);
88 */
89 }
90

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