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.
Location:
src/UIElements/TextUI/Query
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/TextUI/Query/AtomTextQuery.cpp

    r9346af rbf87c2  
    5151TextDialog::AtomTextQuery::~AtomTextQuery() {}
    5252
    53 bool TextDialog::AtomTextQuery::handle() {
     53void TextDialog::AtomTextQuery::handle() {
    5454  int idxOfAtom=-1;
    5555  bool badInput = false;
     
    7474  } while(badInput);
    7575  std::cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
    76   return (idxOfAtom!=-1);
     76  handleSuccess = (idxOfAtom!=-1);
    7777}
    7878
  • src/UIElements/TextUI/Query/AtomsTextQuery.cpp

    r9346af rbf87c2  
    5252TextDialog::AtomsTextQuery::~AtomsTextQuery() {}
    5353
    54 bool TextDialog::AtomsTextQuery::handle() {
     54void TextDialog::AtomsTextQuery::handle() {
    5555  int idxOfAtom=-1;
    5656  std::cout << getDescription() << ": ";
     
    8383  }
    8484
    85   return (idxOfAtom!=-1);
     85  handleSuccess = (idxOfAtom!=-1);
    8686}
    8787
  • src/UIElements/TextUI/Query/BooleanTextQuery.cpp

    r9346af rbf87c2  
    4949TextDialog::BooleanTextQuery::~BooleanTextQuery() {}
    5050
    51 bool TextDialog::BooleanTextQuery::handle() {
     51void TextDialog::BooleanTextQuery::handle() {
    5252  bool badInput = false;
    5353  char input = ' ';
     
    6969  // clear the input buffer of anything still in the line
    7070  std::cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
    71   return true;
     71  handleSuccess = true;
    7272}
    7373
  • src/UIElements/TextUI/Query/DoubleTextQuery.cpp

    r9346af rbf87c2  
    4949TextDialog::DoubleTextQuery::~DoubleTextQuery() {}
    5050
    51 bool TextDialog::DoubleTextQuery::handle() {
     51void TextDialog::DoubleTextQuery::handle() {
    5252  bool badInput = false;
    5353  do{
     
    6363  }while(badInput);
    6464  std::cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
    65   return true;
     65  handleSuccess = true;
    6666}
    6767
  • src/UIElements/TextUI/Query/DoublesTextQuery.cpp

    r9346af rbf87c2  
    4949TextDialog::DoublesTextQuery::~DoublesTextQuery() {}
    5050
    51 bool TextDialog::DoublesTextQuery::handle() {
     51void TextDialog::DoublesTextQuery::handle() {
    5252  std::cout << getDescription() << ": ";
    5353  std::string line;
     
    7070  }
    7171
    72   return true;
     72  handleSuccess = true;
    7373}
    7474
  • src/UIElements/TextUI/Query/ElementTextQuery.cpp

    r9346af rbf87c2  
    5353{}
    5454
    55 bool TextDialog::ElementTextQuery::handle() {
     55void TextDialog::ElementTextQuery::handle() {
    5656  bool badInput=false;
    5757  bool aborted = false;
     
    107107  }while(badInput);
    108108  std::cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
    109   return !aborted;
     109  handleSuccess = !aborted;
    110110}
    111111
  • src/UIElements/TextUI/Query/ElementsTextQuery.cpp

    r9346af rbf87c2  
    5757{}
    5858
    59 bool TextDialog::ElementsTextQuery::handle() {
     59void TextDialog::ElementsTextQuery::handle() {
    6060  std::string shorthand;
    6161  int Z=-1;
     
    9999  }
    100100
    101   return (Z!=-1);
     101  handleSuccess = (Z!=-1);
    102102}
    103103
  • src/UIElements/TextUI/Query/EmptyTextQuery.cpp

    r9346af rbf87c2  
    4949TextDialog::EmptyTextQuery::~EmptyTextQuery() {}
    5050
    51 bool TextDialog::EmptyTextQuery::handle() {
     51void TextDialog::EmptyTextQuery::handle() {
    5252  cout << "Message of " << getTitle() << ":\n" << getDescription() << "\n";
    53   return true;
     53  return;
    5454}
    5555
  • src/UIElements/TextUI/Query/FileTextQuery.cpp

    r9346af rbf87c2  
    5252TextDialog::FileTextQuery::~FileTextQuery() {}
    5353
    54 bool TextDialog::FileTextQuery::handle() {
     54void TextDialog::FileTextQuery::handle() {
    5555  bool badInput = false;
    5656  do{
     
    6767  } while(badInput);
    6868  std::cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
    69   return true;
     69  handleSuccess = true;
    7070}
    7171
  • src/UIElements/TextUI/Query/FilesTextQuery.cpp

    r9346af rbf87c2  
    5252TextDialog::FilesTextQuery::~FilesTextQuery() {}
    5353
    54 bool TextDialog::FilesTextQuery::handle() {
     54void TextDialog::FilesTextQuery::handle() {
    5555  bool badInput = false;
    5656  bool continueflag = true;
     
    7878  } while(continueflag);
    7979  std::cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
    80   return true;
     80  handleSuccess = true;
    8181}
    8282
  • src/UIElements/TextUI/Query/IntTextQuery.cpp

    r9346af rbf87c2  
    4949TextDialog::IntTextQuery::~IntTextQuery() {}
    5050
    51 bool TextDialog::IntTextQuery::handle() {
     51void TextDialog::IntTextQuery::handle() {
    5252  bool badInput = false;
    5353  do{
     
    6464  // clear the input buffer of anything still in the line
    6565  std::cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
    66   return true;
     66  handleSuccess = true;
    6767}
    6868
  • src/UIElements/TextUI/Query/IntsTextQuery.cpp

    r9346af rbf87c2  
    4949TextDialog::IntsTextQuery::~IntsTextQuery() {}
    5050
    51 bool TextDialog::IntsTextQuery::handle() {
     51void TextDialog::IntsTextQuery::handle() {
    5252  std::cout << getDescription() << ": ";
    5353  std::string line;
     
    7070  }
    7171
    72   return true;
     72  handleSuccess = true;
    7373}
    7474
  • src/UIElements/TextUI/Query/KeyValuePairTextQuery.cpp

    r9346af rbf87c2  
    5050TextDialog::KeyValuePairTextQuery::~KeyValuePairTextQuery() {}
    5151
    52 bool TextDialog::KeyValuePairTextQuery::handle() {
     52void TextDialog::KeyValuePairTextQuery::handle() {
    5353  std::cout << getDescription() << ": ";
    5454  getline(std::cin,temp);
    55   return true;
     55  handleSuccess = true;
    5656}
    5757
  • src/UIElements/TextUI/Query/KeyValuePairsTextQuery.cpp

    r9346af rbf87c2  
    5050TextDialog::KeyValuePairsTextQuery::~KeyValuePairsTextQuery() {}
    5151
    52 bool TextDialog::KeyValuePairsTextQuery::handle() {
     52void TextDialog::KeyValuePairsTextQuery::handle() {
    5353  std::cout << getDescription() << ": ";
    5454  std::string temp_element;
     
    6565    temp.push_back(std::string(olditer, temp_element.end()));
    6666
    67   return true;
     67  handleSuccess = true;
    6868}
    6969
  • src/UIElements/TextUI/Query/MoleculeTextQuery.cpp

    r9346af rbf87c2  
    5252TextDialog::MoleculeTextQuery::~MoleculeTextQuery() {}
    5353
    54 bool TextDialog::MoleculeTextQuery::handle() {
     54void TextDialog::MoleculeTextQuery::handle() {
    5555  int idxOfMol=0;
    5656  bool badInput = false;
     
    7575  } while(badInput);
    7676  std::cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
    77   return (idxOfMol!=-1);
     77  handleSuccess = (idxOfMol!=-1);
    7878}
    7979
  • src/UIElements/TextUI/Query/MoleculesTextQuery.cpp

    r9346af rbf87c2  
    5252TextDialog::MoleculesTextQuery::~MoleculesTextQuery() {}
    5353
    54 bool TextDialog::MoleculesTextQuery::handle() {
     54void TextDialog::MoleculesTextQuery::handle() {
    5555  int idxOfMol=-1;
    5656  std::cout << getDescription() << ": ";
     
    8383  }
    8484
    85   return (idxOfMol!=-1);
     85  handleSuccess = (idxOfMol!=-1);
    8686}
    8787
  • src/UIElements/TextUI/Query/RealSpaceMatrixTextQuery.cpp

    r9346af rbf87c2  
    5151{}
    5252
    53 bool TextDialog::RealSpaceMatrixTextQuery::handle() {
     53void TextDialog::RealSpaceMatrixTextQuery::handle() {
    5454  std::cout << getTitle();
    5555
     
    7070  temp.set(2,1, dtemp[4]);
    7171  temp.set(2,2, dtemp[5]);
    72   return true;
     72  handleSuccess = true;
    7373}
    7474
  • src/UIElements/TextUI/Query/StringTextQuery.cpp

    r9346af rbf87c2  
    4949TextDialog::StringTextQuery::~StringTextQuery() {}
    5050
    51 bool TextDialog::StringTextQuery::handle() {
     51void TextDialog::StringTextQuery::handle() {
    5252  std::cout << getDescription() << ": ";
    5353  getline(std::cin,temp);
    54   return true;
     54  handleSuccess = true;
    5555}
    5656
  • src/UIElements/TextUI/Query/StringsTextQuery.cpp

    r9346af rbf87c2  
    4949TextDialog::StringsTextQuery::~StringsTextQuery() {}
    5050
    51 bool TextDialog::StringsTextQuery::handle() {
     51void TextDialog::StringsTextQuery::handle() {
    5252  std::cout << getDescription() << ": ";
    5353  std::string temp_element;
     
    6464    temp.push_back(std::string(olditer, temp_element.end()));
    6565
    66   return true;
     66  handleSuccess = true;
    6767}
    6868
  • src/UIElements/TextUI/Query/TextQuery.hpp

    r9346af rbf87c2  
    2121  EmptyTextQuery(const std::string &_title, const std::string &_description = NULL);
    2222  virtual ~EmptyTextQuery();
    23   virtual bool handle();
     23  virtual void handle();
    2424};
    2525
     
    2828  VectorTextQuery(Parameter<Vector> &_param, const std::string &_title, const std::string &_description = "");
    2929  virtual ~VectorTextQuery();
    30   virtual bool handle();
     30  virtual void handle();
    3131};
    3232
     
    3535  VectorsTextQuery(Parameter< std::vector<Vector> > &_param, const std::string &_title, const std::string &_description = "");
    3636  virtual ~VectorsTextQuery();
    37   virtual bool handle();
     37  virtual void handle();
    3838};
    3939
  • src/UIElements/TextUI/Query/UnsignedIntTextQuery.cpp

    r9346af rbf87c2  
    4949TextDialog::UnsignedIntTextQuery::~UnsignedIntTextQuery() {}
    5050
    51 bool TextDialog::UnsignedIntTextQuery::handle() {
     51void TextDialog::UnsignedIntTextQuery::handle() {
    5252  bool badInput = false;
    5353  do{
     
    6464  // clear the input buffer of anything still in the line
    6565  std::cin.ignore(std::numeric_limits<streamsize>::max(),'\n');
    66   return true;
     66  handleSuccess = true;
    6767}
    6868
  • src/UIElements/TextUI/Query/UnsignedIntsTextQuery.cpp

    r9346af rbf87c2  
    4949TextDialog::UnsignedIntsTextQuery::~UnsignedIntsTextQuery() {}
    5050
    51 bool TextDialog::UnsignedIntsTextQuery::handle() {
     51void TextDialog::UnsignedIntsTextQuery::handle() {
    5252  std::cout << getDescription() << ": ";
    5353  std::string line;
     
    7070  }
    7171
    72   return true;
     72  handleSuccess = true;
    7373}
    7474
  • src/UIElements/TextUI/Query/VectorTextQuery.cpp

    r9346af rbf87c2  
    5353{}
    5454
    55 bool TextDialog::VectorTextQuery::handle() {
     55void TextDialog::VectorTextQuery::handle() {
    5656  std::cout << getDescription() << std::endl;
    5757  const RealSpaceMatrix &M = World::getInstance().getDomain().getM();
     
    8383
    8484  // check vector
    85   return true;
     85  handleSuccess = true;
    8686}
    8787
  • src/UIElements/TextUI/Query/VectorsTextQuery.cpp

    r9346af rbf87c2  
    5454{}
    5555
    56 bool TextDialog::VectorsTextQuery::handle() {
     56void TextDialog::VectorsTextQuery::handle() {
    5757  std::stringstream output;
    5858  std::cout << getDescription() << std::endl;
     
    8383  }
    8484
    85   return true;
     85  handleSuccess = true;
    8686}
    8787
Note: See TracChangeset for help on using the changeset viewer.