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

Annotation of /trunk/pygtk/interface/solverparameters.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 221 - (hide annotations) (download) (as text)
Fri Jan 27 03:05:38 2006 UTC (14 years, 11 months ago) by johnpye
File MIME type: text/x-c++src
File size: 1548 byte(s)
Added ability to examine solver parameters via python
1 johnpye 208 #include "solverparameters.h"
2 johnpye 221 #include "solverparameteriterator.h"
3 johnpye 208
4     #include <iostream>
5     #include <sstream>
6 johnpye 221 #include <stdexcept>
7 johnpye 208 using namespace std;
8    
9 johnpye 221 //-------------------------------
10     // SolverParameters
11    
12 johnpye 208 SolverParameters::SolverParameters(const slv_parameters_t &p) : p(p){
13     cerr << "CREATED SOLVERPARAMETERS" << endl;
14     }
15    
16     SolverParameters::SolverParameters(){
17     cerr << "CONSTRUCTED SOLVERPARAMETERS NULL" << endl;
18     }
19    
20     SolverParameters::SolverParameters(const SolverParameters &old) : p(old.p){
21     // copy constructor
22     }
23    
24     const string
25     SolverParameters::toString() const{
26     stringstream ss;
27     ss << "SOLVERPARAMETERS:TOSTRING:" << endl;
28     ss << "Number of parameters: " << p.num_parms << endl;
29 johnpye 221
30     iterator i;
31     for(i = begin(); i<end(); ++i){
32     SolverParameter p = *i;
33     ss << p.getLabel() << " [" << p.getDescription() << "]: ";
34     if(p.isInt()){
35     ss << p.getIntValue();
36     }else if(p.isReal()){
37     ss << p.getRealValue();
38     }else if(p.isBool()){
39     ss << (p.getBoolValue() ? "true" : "false");
40     }else if(p.isStr()){
41     ss << p.getStrValue();
42     }else{
43     throw runtime_error("Unhandled case");
44     }
45     ss << endl;
46     }
47 johnpye 208 return ss.str();
48     }
49    
50 johnpye 221 const SolverParameterIterator
51     SolverParameters::begin() const{
52     return SolverParameterIterator(p.parms);
53     }
54    
55     const SolverParameterIterator
56     SolverParameters::end() const{
57     return SolverParameterIterator(p.parms+p.num_parms);
58     }
59    
60     const int
61     SolverParameters::getLength() const{
62     return p.num_parms;
63     }
64    
65     SolverParameter
66     SolverParameters::getParameter(const int &index) const{
67     return SolverParameter(&(p.parms[index]));
68     }
69    
70    

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