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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 208 by johnpye, Tue Jan 24 03:19:37 2006 UTC revision 221 by johnpye, Fri Jan 27 03:05:38 2006 UTC
# Line 1  Line 1 
1  #include "solverparameters.h"  #include "solverparameters.h"
2    #include "solverparameteriterator.h"
3    
4  #include <iostream>  #include <iostream>
5  #include <sstream>  #include <sstream>
6    #include <stdexcept>
7  using namespace std;  using namespace std;
8    
9    //-------------------------------
10    // SolverParameters
11    
12  SolverParameters::SolverParameters(const slv_parameters_t &p) : p(p){  SolverParameters::SolverParameters(const slv_parameters_t &p) : p(p){
13      cerr << "CREATED SOLVERPARAMETERS" << endl;      cerr << "CREATED SOLVERPARAMETERS" << endl;
14  }  }
# Line 21  SolverParameters::toString() const{ Line 26  SolverParameters::toString() const{
26      stringstream ss;      stringstream ss;
27      ss << "SOLVERPARAMETERS:TOSTRING:" << endl;      ss << "SOLVERPARAMETERS:TOSTRING:" << endl;
28      ss << "Number of parameters: " << p.num_parms << endl;      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();      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    

Legend:
Removed from v.208  
changed lines
  Added in v.221

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