C API Documentation
Solver.h
Go to the documentation of this file.
1 // == PREAMBLE ================================================
2 
3 // * Licensed under the Apache License, Version 2.0; see README
4 
5 // == FILEDOC =================================================
6 
14 # ifndef RR_SOLVER_H_
15 # define RR_SOLVER_H_
16 
17 // == INCLUDES ================================================
18 
19 # include "rrLogger.h"
20 # include "rrOSSpecifics.h"
21 # include "Dictionary.h"
22 # include "rrException.h"
23 
24 # include "tr1proxy/rr_memory.h"
25 # include "tr1proxy/rr_unordered_map.h"
26 # include <stdexcept>
27 
28 // == CODE ====================================================
29 
30 namespace rr
31 {
36  class RR_DECLSPEC Solver
37  {
38  public:
39 
40  virtual ~Solver() {};
41 
46  virtual std::string getName() const = 0;
47 
52  virtual std::string getDescription() const = 0;
53 
58  virtual std::string getHint() const = 0;
59 
64  std::vector<std::string> getSettings() const;
65 
70  virtual void resetSettings();
71 
78  virtual Variant getValue(std::string key) const;
79 
84  virtual Variant hasValue(std::string key) const;
85 
90  virtual size_t getNumParams() const;
91 
96  virtual std::string getParamName(size_t n) const;
97 
102  virtual std::string getParamDisplayName(int n) const;
103 
108  virtual std::string getParamHint(int n) const;
109 
114  virtual std::string getParamDesc(int n) const;
115 
116 
121  virtual int getValueAsInt(std::string key);
122 
127  virtual unsigned int getValueAsUInt(std::string key);
128 
133  virtual long getValueAsLong(std::string key);
134 
139  virtual unsigned long getValueAsULong(std::string key);
140 
145  virtual float getValueAsFloat(std::string key);
146 
151  virtual double getValueAsDouble(std::string key);
152 
153 
157  virtual std::vector<double> getValueAsDoubleVector(std::string key);
158 
159 
164  virtual char getValueAsChar(std::string key);
165 
170  virtual unsigned char getValueAsUChar(std::string key);
171 
176  virtual std::string getValueAsString(std::string key);
177 
182  virtual bool getValueAsBool(std::string key);
183 
184 
185  virtual void setValue(std::string key, const Variant& value);
186 
191  const std::string& getDisplayName(std::string key) const;
192 
197  const std::string& getHint(std::string key) const;
198 
203  const std::string& getDescription(std::string key) const;
204 
209  const Variant::TypeId getType(std::string key);
210 
215  std::string getSettingsRepr() const;
216 
221  std::string settingsPyDictRepr() const;
222 
227  virtual std::string toString() const;
228 
233  virtual std::string toRepr() const;
234 
235  protected:
236  typedef std::vector<std::string> SettingsList;
237  typedef RR_UNORDERED_MAP <std::string, Variant> SettingsMap;
238  typedef RR_UNORDERED_MAP <std::string, std::string> DisplayNameMap;
239  typedef RR_UNORDERED_MAP <std::string, std::string> HintMap;
240  typedef RR_UNORDERED_MAP <std::string, std::string> DescriptionMap;
241 
242  SettingsList sorted_settings;
243  SettingsMap settings;
244  DisplayNameMap display_names_;
245  HintMap hints;
246  DescriptionMap descriptions;
247 
248  void addSetting(std::string name, Variant val, string display_name, std::string hint, std::string description);
249  };
250 
251 }
252 
253 # endif /* RR_INTEGRATOR_H_ */
Base class for all integrators and steady state solvers.
Definition: Solver.h:37
virtual unsigned char getValueAsUChar(std::string key)
Wrapper for getValue which converts output to a specific type.
const std::string & getDisplayName(std::string key) const
Gets the hint associated with a given key.
virtual void resetSettings()
Reset all settings to their respective default values.
virtual long getValueAsLong(std::string key)
Wrapper for getValue which converts output to a specific type.
virtual size_t getNumParams() const
Get the number of parameters.
const Variant::TypeId getType(std::string key)
Gets the type associated with a given key.
std::string settingsPyDictRepr() const
Python dictionary-style string representation of settings.
std::string getSettingsRepr() const
Get the solver settings as a string.
virtual std::string getName() const =0
Get the name of this solver.
virtual std::string getParamDesc(int n) const
Get the description of the parameter at index n.
const std::string & getHint(std::string key) const
Gets the hint associated with a given key.
virtual unsigned long getValueAsULong(std::string key)
Wrapper for getValue which converts output to a specific type.
virtual Variant getValue(std::string key) const
Get the value of an integrator setting.
virtual std::string toRepr() const
Return string representation a la Python repr method.
virtual char getValueAsChar(std::string key)
Wrapper for getValue which converts output to a specific type.
virtual float getValueAsFloat(std::string key)
Wrapper for getValue which converts output to a specific type.
virtual std::string getDescription() const =0
Get the description of this solver.
const std::string & getDescription(std::string key) const
Gets the description associated with a given key.
virtual std::string getValueAsString(std::string key)
Wrapper for getValue which converts output to a specific type.
std::vector< std::string > getSettings() const
Get a list of all settings for this solver.
virtual Variant hasValue(std::string key) const
Return true if this setting is supported by the integrator.
virtual bool getValueAsBool(std::string key)
Wrapper for getValue which converts output to a specific type.
virtual std::string getParamHint(int n) const
Get the hint of the parameter at index n.
virtual int getValueAsInt(std::string key)
Wrapper for getValue which converts output to a specific type.
virtual std::string getParamDisplayName(int n) const
Get the display name of the parameter at index n.
virtual unsigned int getValueAsUInt(std::string key)
Wrapper for getValue which converts output to a specific type.
virtual std::string getParamName(size_t n) const
Get the name of the parameter at index n.
virtual std::vector< double > getValueAsDoubleVector(std::string key)
Wrapper for getValue which converts output to a specific type.
virtual double getValueAsDouble(std::string key)
Wrapper for getValue which converts output to a specific type.
virtual std::string getHint() const =0
Get a (user-readable) hint for this solver.
virtual std::string toString() const
Return a string representation of the solver.
Definition: Variant.h:75
TypeId
Definition: Variant.h:82
C_DECL_SPEC bool rrcCallConv setValue(RRHandle handle, const char *symbolId, const double value)
Set the value for a given symbol, use getAvailableTimeCourseSymbols(void) for a list of symbols.