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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 225 - (show annotations) (download) (as text)
Fri Jan 27 14:55:43 2006 UTC (14 years, 10 months ago) by johnpye
File MIME type: text/x-c++src
File size: 1617 byte(s)
Added const-ness to 2nd parameter of slv_set_char_parameter.
Implemented setting of int, real and string parameters via PyGTK interface.
1 #include "solverparameters.h"
2 #include "solverparameteriterator.h"
3
4 #include <iostream>
5 #include <sstream>
6 #include <stdexcept>
7 using namespace std;
8
9 //-------------------------------
10 // SolverParameters
11
12 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
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 return ss.str();
48 }
49
50 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 slv_parameters_t &
71 SolverParameters::getInternalType(){
72 return p;
73 }
74

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