Ignore:
Timestamp:
Jul 17, 2017, 12:28:51 PM (8 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
Action_Thermostats, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults
Children:
3bd4a66
Parents:
9346af
git-author:
Frederik Heber <frederik.heber@…> (07/06/17 22:18:13)
git-committer:
Frederik Heber <frederik.heber@…> (07/17/17 12:28:51)
Message:

Query::handle() no longer returns bool but has internal result flag.

  • we use this flag conditionally in setResult(), i.e. if the handle() has failed, then we should not set its result which might overwrite a present default value in the parameter.
  • this fixes the problem with StepWorldTime which has a default value of 1 but which was overwritten with 0 because of the non-conditionally calling of setResult().
  • this required change of "output-types" default parameter to an empty vector. So far, we were just lucky that this actually worked.
  • also StoreSaturatedFragmentAction needed the same change as default values have to be consistent over the specific token.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/Dialog.hpp

    r9346af rbf87c2  
    242242    Query(const std::string _title, const std::string _description = "");
    243243    virtual ~Query();
    244     virtual bool handle()=0;
     244    virtual void handle()=0;
    245245    virtual bool isValid()=0;
    246246    virtual void setResult()=0;
     
    257257  public:
    258258    TQuery(Parameter<T> &_param, const std::string title, const std::string _description = "") :
    259       Query(title, _description), param(_param) {}
     259      Query(title, _description), handleSuccess(false), param(_param) {}
    260260    virtual ~TQuery(){}
    261     virtual bool handle()=0;
     261    virtual void handle()=0;
    262262    virtual bool isValid(){ return param.isValid(temp);  }
    263     virtual void setResult(){ param.set(temp);  }
     263    virtual void setResult(){ if (handleSuccess) param.set(temp);  }
    264264  protected:
    265265    T temp;
     266    bool handleSuccess;
    266267    Parameter<T> &param;
    267268  };
     
    272273    EmptyQuery(const std::string title, const std::string _description = "");
    273274    virtual ~EmptyQuery();
    274     virtual bool handle()=0;
     275    virtual void handle()=0;
    275276    virtual bool isValid(){ return true;  }
    276277    virtual void setResult();
     
    301302public:
    302303  TQuery(Parameter<Vector> &_param, const std::string title, const std::string _description = "") :
    303     Query(title, _description), param(_param) {}
     304    Query(title, _description), handleSuccess(false), param(_param) {}
    304305  virtual ~TQuery(){}
    305   virtual bool handle()=0;
     306  virtual void handle()=0;
    306307  virtual bool isValid(){ return param.isValidAsString(temp);  }
    307   virtual void setResult(){ param.setAsString(temp);  }
     308  virtual void setResult(){ if (handleSuccess) param.setAsString(temp);  }
    308309protected:
    309310  std::string temp;
     311  bool handleSuccess;
    310312  Parameter<Vector> &param;
    311313};
     
    315317public:
    316318  TQuery(Parameter< std::vector<Vector> > &_param, const std::string title, const std::string _description = "") :
    317     Query(title, _description), param(_param) {}
     319    Query(title, _description), handleSuccess(false), param(_param) {}
    318320  virtual ~TQuery(){}
    319   virtual bool handle()=0;
     321  virtual void handle()=0;
    320322  virtual bool isValid();
    321323  virtual void setResult();
    322324protected:
    323325  std::vector<std::string> temp;
     326  bool handleSuccess;
    324327  Parameter< std::vector<Vector> > &param;
    325328};
Note: See TracChangeset for help on using the changeset viewer.