Skip to content
Snippets Groups Projects
Commit 193b3714 authored by Francois Henrotte's avatar Francois Henrotte
Browse files

adaptations suite à la nouvelle définition de _set

parent 07fd5db5
No related branches found
No related tags found
No related merge requests found
...@@ -610,26 +610,26 @@ void Msg::ExchangeOnelabParameter(const std::string &key, ...@@ -610,26 +610,26 @@ void Msg::ExchangeOnelabParameter(const std::string &key,
if(ps.size()){ // use value from server if(ps.size()){ // use value from server
val[0] = ps[0].getValue(); val[0] = ps[0].getValue();
} }
else{ // send value to server
onelab::number o(name, val[0]); onelab::number o(name);
if(fopt.count("Range") && fopt["Range"].size() == 2){ o.setDefaultValue(val[0]);
o.setMin(fopt["Range"][0]); o.setMax(fopt["Range"][1]); if(fopt.count("Range") && fopt["Range"].size() == 2){
} o.setMin(fopt["Range"][0]); o.setMax(fopt["Range"][1]);
else if(fopt.count("Min") && fopt.count("Max")){ }
o.setMin(fopt["Min"][0]); o.setMax(fopt["Max"][0]); else if(fopt.count("Min") && fopt.count("Max")){
} o.setMin(fopt["Min"][0]); o.setMax(fopt["Max"][0]);
else if(fopt.count("Min")){ }
o.setMin(fopt["Min"][0]); o.setMax(1.e200); else if(fopt.count("Min")){
} o.setMin(fopt["Min"][0]); o.setMax(1.e200);
else if(fopt.count("Max")){ }
o.setMax(fopt["Max"][0]); o.setMin(-1.e200); else if(fopt.count("Max")){
} o.setMax(fopt["Max"][0]); o.setMin(-1.e200);
if(fopt.count("Step")) o.setStep(fopt["Step"][0]);
if(fopt.count("Choices")) o.setChoices(fopt["Choices"]);
if(copt.count("Help")) o.setHelp(copt["Help"][0]);
if(copt.count("ShortHelp")) o.setShortHelp(copt["ShortHelp"][0]);
_onelabClient->set(o);
} }
if(fopt.count("Step")) o.setStep(fopt["Step"][0]);
if(fopt.count("Choices")) o.setChoices(fopt["Choices"]);
if(copt.count("Help")) o.setHelp(copt["Help"][0]);
if(copt.count("ShortHelp")) o.setShortHelp(copt["ShortHelp"][0]);
_onelabClient->set(o);
} }
void Msg::FinalizeOnelab() void Msg::FinalizeOnelab()
......
...@@ -132,19 +132,28 @@ namespace onelab{ ...@@ -132,19 +132,28 @@ namespace onelab{
double _value, _defaultValue, _min, _max, _step; double _value, _defaultValue, _min, _max, _step;
std::vector<double> _choices; std::vector<double> _choices;
public: public:
number(const std::string &name="", double defaultValue=0., number(const std::string &name="", double defaultValue=maxNumber(),
const std::string &shortHelp="", const std::string &help="") const std::string &shortHelp="", const std::string &help="")
: parameter(name, shortHelp, help), _value(defaultValue), : parameter(name, shortHelp, help), _value(defaultValue),
_defaultValue(defaultValue), _min(-maxNumber()), _max(maxNumber()), _defaultValue(defaultValue), _min(-maxNumber()), _max(maxNumber()),
_step(0.) {} _step(0.) {}
void setValue(double value){ _value = value; } void setValue(double value){ _value = value; }
void setDefaultValue(double value){ _defaultValue = value; } void setDefaultValue(double value) { _defaultValue = value; }
void setMin(double min){ _min = min; } void setMin(double min){ _min = min; }
void setMax(double max){ _max = max; } void setMax(double max){ _max = max; }
void setStep(double step){ _step = step; } void setStep(double step){ _step = step; }
void setChoices(std::vector<double> &choices){ _choices = choices; } void setChoices(std::vector<double> &choices){ _choices = choices; }
std::string getType() const { return "number"; } std::string getType() const { return "number"; }
double getValue() const { return _value; } double getValue() const { // never returns an unset value
if( _value != maxNumber())
return _value;
else if( _defaultValue != maxNumber())
return _defaultValue;
else {
std::cerr << "The number " << getName() << " is not set" << std::endl;
exit(1);
}
}
double getDefaultValue() const { return _defaultValue; } double getDefaultValue() const { return _defaultValue; }
double getMin() const { return _min; } double getMin() const { return _min; }
double getMax() const { return _max; } double getMax() const { return _max; }
...@@ -152,11 +161,11 @@ namespace onelab{ ...@@ -152,11 +161,11 @@ namespace onelab{
const std::vector<double> &getChoices(){ return _choices; } const std::vector<double> &getChoices(){ return _choices; }
void update(const number &p) void update(const number &p)
{ {
if(p.getValue() != getValue()){ if( (p._value != maxNumber()/*=is set*/) && (p._value != _value)){
setValue(p.getValue()); setValue(p._value);
setChanged(true); setChanged(true);
} }
if(p.getDefaultValue() && p.getDefaultValue() != getDefaultValue()) if((p.getDefaultValue() != maxNumber()/*=is set*/) && (p.getDefaultValue() != getDefaultValue()))
setDefaultValue(p.getDefaultValue()); setDefaultValue(p.getDefaultValue());
if(p.getMin() != -maxNumber()) if(p.getMin() != -maxNumber())
setMin(p.getMin()); setMin(p.getMin());
...@@ -164,6 +173,10 @@ namespace onelab{ ...@@ -164,6 +173,10 @@ namespace onelab{
setMax(p.getMax()); setMax(p.getMax());
if(p.getStep() != getStep()) if(p.getStep() != getStep())
setStep(p.getStep()); setStep(p.getStep());
if(p.getHelp().size() && p.getHelp() != getHelp())
setHelp(p.getHelp());
if(p.getShortHelp().size() && p.getShortHelp() != getShortHelp())
setHelp(p.getShortHelp());
} }
std::string toChar() std::string toChar()
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment