Ignore:
Timestamp:
Apr 4, 2018, 4:59:24 PM (7 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
Adding_MD_integration_tests, Adding_StructOpt_integration_tests, AutomationFragmentation_failures, Candidate_v1.6.1, ChemicalSpaceEvaluator, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Exclude_Hydrogens_annealWithBondGraph, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_contraction-expansion, Gui_displays_atomic_force_velocity, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, PythonUI_with_named_parameters, StoppableMakroAction, TremoloParser_IncreasedPrecision
Children:
0aae02
Parents:
775f3f
git-author:
Frederik Heber <frederik.heber@…> (07/06/17 22:18:13)
git-committer:
Frederik Heber <frederik.heber@…> (04/04/18 16:59:24)
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/CommandLineUI/Query
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • src/UIElements/CommandLineUI/Query/AtomCommandLineQuery.cpp

    r775f3f rf4b6bc9  
    5555CommandLineDialog::AtomCommandLineQuery::~AtomCommandLineQuery() {}
    5656
    57 bool CommandLineDialog::AtomCommandLineQuery::handle() {
     57void CommandLineDialog::AtomCommandLineQuery::handle() {
    5858  int IdxOfAtom = -1;
    5959  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     
    6262    } catch(boost::bad_any_cast &e) {
    6363      IdxOfAtom = -1;
    64       return false;
     64      return;
    6565    }
    6666    temp = const_cast<const World &>(World::getInstance()).getAtom(AtomById(IdxOfAtom));
    67     return true;
     67    handleSuccess = true;
    6868  }
    69   return false;
    7069}
    7170
  • src/UIElements/CommandLineUI/Query/AtomsCommandLineQuery.cpp

    r775f3f rf4b6bc9  
    5050CommandLineDialog::AtomsCommandLineQuery::~AtomsCommandLineQuery() {}
    5151
    52 bool CommandLineDialog::AtomsCommandLineQuery::handle() {
     52void CommandLineDialog::AtomsCommandLineQuery::handle() {
    5353  std::vector<int> IdxOfAtom;
    5454  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     
    5757    } catch(boost::bad_any_cast &e) {
    5858      IdxOfAtom.clear();
    59       return false;
     59      return;
    6060    }
    6161    const atom *temp_element;
     
    6565        temp.push_back(temp_element);
    6666    }
    67     return true;
     67    handleSuccess = true; return;
    6868  }
    69   return false;
    7069}
    7170
  • src/UIElements/CommandLineUI/Query/BooleanCommandLineQuery.cpp

    r775f3f rf4b6bc9  
    4747CommandLineDialog::BooleanCommandLineQuery::~BooleanCommandLineQuery() {}
    4848
    49 bool CommandLineDialog::BooleanCommandLineQuery::handle() {
     49void CommandLineDialog::BooleanCommandLineQuery::handle() {
    5050  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    5151    try {
     
    5353    } catch(boost::bad_any_cast &e) {
    5454      temp = false;
    55       return false;
     55      return;
    5656    }
    57     return true;
     57    handleSuccess = true; return;
    5858  }
    59   return false;
    6059}
    6160
  • src/UIElements/CommandLineUI/Query/CommandLineQuery.hpp

    r775f3f rf4b6bc9  
    2121  EmptyCommandLineQuery(const std::string &_title, const std::string &_description = "");
    2222  virtual ~EmptyCommandLineQuery();
    23   virtual bool handle();
     23  virtual void handle();
    2424};
    2525
     
    2828  VectorCommandLineQuery(Parameter<Vector> &_param, const std::string &_title, const std::string &_description = "");
    2929  virtual ~VectorCommandLineQuery();
    30   virtual bool handle();
     30  virtual void handle();
    3131};
    3232
     
    3535  VectorsCommandLineQuery(Parameter< std::vector<Vector> > &_param, const std::string &_title, const std::string &_description = "");
    3636  virtual ~VectorsCommandLineQuery();
    37   virtual bool handle();
     37  virtual void handle();
    3838};
    3939
  • src/UIElements/CommandLineUI/Query/DoubleCommandLineQuery.cpp

    r775f3f rf4b6bc9  
    4848CommandLineDialog::DoubleCommandLineQuery::~DoubleCommandLineQuery() {}
    4949
    50 bool CommandLineDialog::DoubleCommandLineQuery::handle() {
     50void CommandLineDialog::DoubleCommandLineQuery::handle() {
    5151  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    5252    try {
     
    5454    } catch(boost::bad_any_cast &e) {
    5555      temp = 0.;
    56       return false;
     56      return;
    5757    }
    58     return true;
     58    handleSuccess = true; return;
    5959  }
    60   return false;
    6160}
    6261
  • src/UIElements/CommandLineUI/Query/DoublesCommandLineQuery.cpp

    r775f3f rf4b6bc9  
    4747CommandLineDialog::DoublesCommandLineQuery::~DoublesCommandLineQuery() {}
    4848
    49 bool CommandLineDialog::DoublesCommandLineQuery::handle() {
     49void CommandLineDialog::DoublesCommandLineQuery::handle() {
    5050  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    5151    try {
     
    5353    } catch(boost::bad_any_cast &e) {
    5454      temp.clear();
    55       return false;
     55      return;
    5656    }
    57     return true;
     57    handleSuccess = true; return;
    5858  }
    59   return false;
    6059}
    6160
  • src/UIElements/CommandLineUI/Query/ElementCommandLineQuery.cpp

    r775f3f rf4b6bc9  
    5353{}
    5454
    55 bool CommandLineDialog::ElementCommandLineQuery::handle() {
     55void CommandLineDialog::ElementCommandLineQuery::handle() {
    5656  // TODO: vector of ints and removing first is not correctly implemented yet. How to remove from a vector?
    5757  periodentafel *periode = World::getInstance().getPeriode();
     
    6868      }
    6969    } catch(boost::bad_any_cast &e) {
    70       return false;
     70      return;
    7171    }
    7272    ASSERT(temp != NULL, "Invalid element specified in ElementCommandLineQuery");
    73     return true;
     73    handleSuccess = true; return;
    7474  }
    75   return false;
    7675}
    7776
  • src/UIElements/CommandLineUI/Query/ElementsCommandLineQuery.cpp

    r775f3f rf4b6bc9  
    6868}
    6969
    70 bool CommandLineDialog::ElementsCommandLineQuery::handle() {
     70void CommandLineDialog::ElementsCommandLineQuery::handle() {
    7171  // TODO: vector of ints and removing first is not correctly implemented yet. How to remove from a vector?
    7272  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     
    8080        temp = getElementsFromInput<std::string>(AllArguments);
    8181        } catch(boost::bad_lexical_cast &e) {
    82           return false;
     82          return;
    8383        }
    8484      }
    8585    } catch(boost::bad_any_cast &e) {
    86       return false;
     86      return;
    8787    }
    8888    if (temp.empty())
    89       return false;
     89      return;
    9090    else
    91       return true;
     91      handleSuccess = true; return;
    9292  }
    93   return false;
    9493}
    9594
  • src/UIElements/CommandLineUI/Query/EmptyCommandLineQuery.cpp

    r775f3f rf4b6bc9  
    4848CommandLineDialog::EmptyCommandLineQuery::~EmptyCommandLineQuery() {}
    4949
    50 bool CommandLineDialog::EmptyCommandLineQuery::handle() {
     50void CommandLineDialog::EmptyCommandLineQuery::handle() {
    5151  cout << "Message of " << getTitle() << ":\n" << getDescription() << "\n";
    52   return true;
    5352}
    5453
  • src/UIElements/CommandLineUI/Query/FileCommandLineQuery.cpp

    r775f3f rf4b6bc9  
    4747CommandLineDialog::FileCommandLineQuery::~FileCommandLineQuery() {}
    4848
    49 bool CommandLineDialog::FileCommandLineQuery::handle() {
     49void CommandLineDialog::FileCommandLineQuery::handle() {
    5050  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    5151    try {
     
    5353    } catch(boost::bad_any_cast &e) {
    5454      temp = std::string("");
    55       return false;
     55      return;
    5656    }
    57     return true;
     57    handleSuccess = true; return;
    5858  }
    59   return false;
    6059}
    6160
  • src/UIElements/CommandLineUI/Query/FilesCommandLineQuery.cpp

    r775f3f rf4b6bc9  
    4747CommandLineDialog::FilesCommandLineQuery::~FilesCommandLineQuery() {}
    4848
    49 bool CommandLineDialog::FilesCommandLineQuery::handle() {
     49void CommandLineDialog::FilesCommandLineQuery::handle() {
    5050  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    5151    try {
     
    5353    } catch(boost::bad_any_cast &e) {
    5454      temp.clear();
    55       return false;
     55      return;
    5656    }
    57     return true;
     57    handleSuccess = true; return;
    5858  }
    59   return false;
    6059}
    6160
  • src/UIElements/CommandLineUI/Query/IntCommandLineQuery.cpp

    r775f3f rf4b6bc9  
    4747CommandLineDialog::IntCommandLineQuery::~IntCommandLineQuery() {}
    4848
    49 bool CommandLineDialog::IntCommandLineQuery::handle() {
     49void CommandLineDialog::IntCommandLineQuery::handle() {
    5050  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    5151    try {
     
    5353    } catch(boost::bad_any_cast &e) {
    5454      temp = 0;
    55       return false;
     55      return;
    5656    }
    57     return true;
     57    handleSuccess = true; return;
    5858  }
    59   return false;
    6059}
    6160
  • src/UIElements/CommandLineUI/Query/IntsCommandLineQuery.cpp

    r775f3f rf4b6bc9  
    4747CommandLineDialog::IntsCommandLineQuery::~IntsCommandLineQuery() {}
    4848
    49 bool CommandLineDialog::IntsCommandLineQuery::handle() {
     49void CommandLineDialog::IntsCommandLineQuery::handle() {
    5050  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    5151    try {
     
    5353    } catch(boost::bad_any_cast &e) {
    5454      temp.clear();
    55       return false;
     55      return;
    5656    }
    57     return true;
     57    handleSuccess = true; return;
    5858  }
    59   return false;
    6059}
    6160
  • src/UIElements/CommandLineUI/Query/KeyValuePairCommandLineQuery.cpp

    r775f3f rf4b6bc9  
    4949CommandLineDialog::KeyValuePairCommandLineQuery::~KeyValuePairCommandLineQuery() {}
    5050
    51 bool CommandLineDialog::KeyValuePairCommandLineQuery::handle() {
     51void CommandLineDialog::KeyValuePairCommandLineQuery::handle() {
    5252  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    5353    try {
     
    5555    } catch(boost::bad_any_cast &e) {
    5656      temp = KeyValuePair(std::string(""));
    57       return false;
     57      return;
    5858    }
    59     return true;
     59    handleSuccess = true; return;
    6060  }
    61   return false;
    6261}
    6362
  • src/UIElements/CommandLineUI/Query/KeyValuePairsCommandLineQuery.cpp

    r775f3f rf4b6bc9  
    4848CommandLineDialog::KeyValuePairsCommandLineQuery::~KeyValuePairsCommandLineQuery() {}
    4949
    50 bool CommandLineDialog::KeyValuePairsCommandLineQuery::handle() {
     50void CommandLineDialog::KeyValuePairsCommandLineQuery::handle() {
    5151  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    5252    try {
     
    5454    } catch(boost::bad_any_cast &e) {
    5555      temp.clear();
    56       return false;
     56      return;
    5757    }
    58     return true;
     58    handleSuccess = true; return;
    5959  }
    60   return false;
     60  return;
    6161}
    6262
  • src/UIElements/CommandLineUI/Query/MoleculeCommandLineQuery.cpp

    r775f3f rf4b6bc9  
    5050CommandLineDialog::MoleculeCommandLineQuery::~MoleculeCommandLineQuery() {}
    5151
    52 bool CommandLineDialog::MoleculeCommandLineQuery::handle() {
     52void CommandLineDialog::MoleculeCommandLineQuery::handle() {
    5353  int IdxOfMol = -1;
    5454  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     
    5757    } catch(boost::bad_any_cast &e) {
    5858      IdxOfMol = -1;
    59       return false;
     59      return;
    6060    }
    6161    temp = const_cast<const World &>(World::getInstance()).getMolecule(MoleculeById(IdxOfMol));
    62     return true;
     62    handleSuccess = true; return;
    6363  }
    64   return false;
    6564}
    6665
  • src/UIElements/CommandLineUI/Query/MoleculesCommandLineQuery.cpp

    r775f3f rf4b6bc9  
    5151CommandLineDialog::MoleculesCommandLineQuery::~MoleculesCommandLineQuery() {}
    5252
    53 bool CommandLineDialog::MoleculesCommandLineQuery::handle() {
     53void CommandLineDialog::MoleculesCommandLineQuery::handle() {
    5454  std::vector<int> IdxOfMol;
    5555  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     
    5858    } catch(boost::bad_any_cast &e) {
    5959      IdxOfMol.clear();
    60       return false;
     60      return;
    6161    }
    6262    for (std::vector<int>::iterator iter = IdxOfMol.begin(); iter != IdxOfMol.end(); ++iter) {
     
    6666        temp.push_back(temp_element);
    6767    }
    68     return true;
     68    handleSuccess = true; return;
    6969  }
    70   return false;
    7170}
    7271
  • src/UIElements/CommandLineUI/Query/RealSpaceMatrixCommandLineQuery.cpp

    r775f3f rf4b6bc9  
    5050{}
    5151
    52 bool CommandLineDialog::RealSpaceMatrixCommandLineQuery::handle() {
     52void CommandLineDialog::RealSpaceMatrixCommandLineQuery::handle() {
    5353  RealSpaceMatrixValue _temp;
    5454  if (CommandLineParser::getInstance().vm.count(getTitle())) {
     
    5858      for (size_t i=0;i<(NDIM*(NDIM+1))/2;++i)
    5959        _temp.matrix[i] = 0.;
    60       return false;
     60      return;
    6161    }
    6262    temp = _temp.toRealSpaceMatrix();
    63     return true;
     63    handleSuccess = true; return;
    6464  }
    65   return false;
    6665}
    6766
  • src/UIElements/CommandLineUI/Query/StringCommandLineQuery.cpp

    r775f3f rf4b6bc9  
    4747CommandLineDialog::StringCommandLineQuery::~StringCommandLineQuery() {}
    4848
    49 bool CommandLineDialog::StringCommandLineQuery::handle() {
     49void CommandLineDialog::StringCommandLineQuery::handle() {
    5050  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    5151    try {
     
    5353    } catch(boost::bad_any_cast &e) {
    5454      temp = std::string("");
    55       return false;
     55      return;
    5656    }
    57     return true;
     57    handleSuccess = true; return;
    5858  }
    59   return false;
    6059}
    6160
  • src/UIElements/CommandLineUI/Query/StringsCommandLineQuery.cpp

    r775f3f rf4b6bc9  
    4747CommandLineDialog::StringsCommandLineQuery::~StringsCommandLineQuery() {}
    4848
    49 bool CommandLineDialog::StringsCommandLineQuery::handle() {
     49void CommandLineDialog::StringsCommandLineQuery::handle() {
    5050  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    5151    try {
     
    5353    } catch(boost::bad_any_cast &e) {
    5454      temp.clear();
    55       return false;
     55      return;
    5656    }
    57     return true;
     57    handleSuccess = true; return;
    5858  }
    59   return false;
    6059}
    6160
  • src/UIElements/CommandLineUI/Query/UnsignedIntCommandLineQuery.cpp

    r775f3f rf4b6bc9  
    4747CommandLineDialog::UnsignedIntCommandLineQuery::~UnsignedIntCommandLineQuery() {}
    4848
    49 bool CommandLineDialog::UnsignedIntCommandLineQuery::handle() {
     49void CommandLineDialog::UnsignedIntCommandLineQuery::handle() {
    5050  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    5151    try {
     
    5353    } catch(boost::bad_any_cast &e) {
    5454      temp = -1;
    55       return false;
     55      return;
    5656    }
    57     return true;
     57    handleSuccess = true; return;
    5858  }
    59   return false;
    6059}
    6160
  • src/UIElements/CommandLineUI/Query/UnsignedIntsCommandLineQuery.cpp

    r775f3f rf4b6bc9  
    4747CommandLineDialog::UnsignedIntsCommandLineQuery::~UnsignedIntsCommandLineQuery() {}
    4848
    49 bool CommandLineDialog::UnsignedIntsCommandLineQuery::handle() {
     49void CommandLineDialog::UnsignedIntsCommandLineQuery::handle() {
    5050  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    5151    try {
     
    5353    } catch(boost::bad_any_cast &e) {
    5454      temp.clear();
    55       return false;
     55      return;
    5656    }
    57     return true;
     57    handleSuccess = true; return;
    5858  }
    59   return false;
    6059}
    6160
  • src/UIElements/CommandLineUI/Query/VectorCommandLineQuery.cpp

    r775f3f rf4b6bc9  
    5252{}
    5353
    54 bool CommandLineDialog::VectorCommandLineQuery::handle() {
     54void CommandLineDialog::VectorCommandLineQuery::handle() {
    5555  VectorValue temporary;
    5656  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    5757    temporary = CommandLineParser::getInstance().vm[getTitle()].as< VectorValue >();
    5858    temp = temporary.vectorstring;
    59     return true;
     59    handleSuccess = true; return;
    6060  }
    61   return false;
    6261}
    6362
  • src/UIElements/CommandLineUI/Query/VectorsCommandLineQuery.cpp

    r775f3f rf4b6bc9  
    5252{}
    5353
    54 bool CommandLineDialog::VectorsCommandLineQuery::handle() {
     54void CommandLineDialog::VectorsCommandLineQuery::handle() {
    5555  std::vector<std::string> temporary;
    5656  std::stringstream output;
    5757  if (CommandLineParser::getInstance().vm.count(getTitle())) {
    5858    temp = CommandLineParser::getInstance().vm[getTitle()].as< std::vector<std::string> >();
    59     return true;
     59    handleSuccess = true; return;
    6060  }
    61   return false;
    6261}
    6362
Note: See TracChangeset for help on using the changeset viewer.