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

Annotation of /trunk/pygtk/interface/solver.i

Parent Directory Parent Directory | Revision Log Revision Log


Revision 221 - (hide annotations) (download)
Fri Jan 27 03:05:38 2006 UTC (14 years, 10 months ago) by johnpye
File size: 1670 byte(s)
Added ability to examine solver parameters via python
1 johnpye 221 /*
2     SWIG interface for accessing Solver and choosing solver parameters
3     */
4    
5     class Solver{
6     public:
7     Solver(const std::string &name);
8     Solver(const Solver &);
9    
10     const int &getIndex() const;
11     const std::string getName() const;
12     };
13    
14     // SOLVE PARAMETERS
15    
16     %pythoncode{
17     class SolverParameterIter:
18     def __init__(self, params):
19     self.params = params;
20     self.index = 0;
21    
22     def next(self):
23     if self.index >= self.params.getLength():
24     raise StopIteration
25     self.index = self.index + 1
26     return self.params.getParameter(self.index)
27     }
28    
29     class SolverParameters{
30     public:
31     const std::string toString();
32     SolverParameters(const SolverParameters &);
33     const int getLength() const;
34     SolverParameter getParameter(const int &) const;
35     };
36    
37     %extend SolverParameters{
38     %pythoncode{
39     def __iter__(self):
40     return SolverParameterIter(self)
41     def getitem(self,index):
42     return
43     }
44     }
45    
46     class SolverParameter{
47     public:
48     explicit SolverParameter(slv_parameter *);
49    
50     const std::string getName() const;
51     const std::string getDescription() const;
52     const std::string getLabel() const;
53     const int &getNumber() const;
54     const int &getPage() const;
55    
56     const bool isInt() const;
57     const bool isBool() const;
58     const bool isStr() const;
59     const bool isReal() const;
60    
61     // The following throw execeptions unless the parameter type is correct
62     const int &getIntValue() const;
63     const int &getIntLowerBound() const;
64     const int &getIntUpperBound() const;
65    
66     const bool getBoolValue() const;
67    
68     const std::string getStrValue() const;
69     const std::vector<std::string> getStrOptions() const;
70    
71     const double &getRealValue() const;
72     const double &getRealLowerBound() const;
73     const double &getRealUpperBound() const;
74     };
75    

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