Changeset 0d4168 for src/Actions


Ignore:
Timestamp:
May 20, 2014, 8:47:03 AM (11 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
cc6e5c
Parents:
c09f94
git-author:
Frederik Heber <heber@…> (08/28/13 23:05:38)
git-committer:
Frederik Heber <heber@…> (05/20/14 08:47:03)
Message:

Allow setting of invalid values in Value class, Action::performCall() catches ParameterExceptions.

Value changes:

  • Values are now checked with get().
  • having the Actions fill their parameters on instantiation may lead to invalid values because actions that, e.g. add an atom and thereby make a so far invalid atomic id now valid, still have to get executed.
  • hence, we allow setting of invalid values. Validity is check/enforced on get(), i.e. when the Action is actually performed and not before. This is also the very moment where the parameters are first required to be valid.
  • Parameter::clone() and copy cstor must not use get() as invalid values are there still allowed.
  • TESTFIX: Value behavior changed.
  • TESTFIX: regression test add atom outside boundary is working again.
  • TESTFIX: regression tests load/store-session would be skipped as loading non-present file fails now. We use --help --actionname instead.

Action changes:

  • are turned into Action::failure.
  • ActionQueue calling an Action wrapped in try/catch-block for ActionFailure.
  • removed try/catch in doUI().
  • as exception (will) occur in ActionQueue's queue_thread, we need to catch it there. As the only thing we do is set the exit flag of the World. We can do this in ActionQueue as well.
Location:
src/Actions
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/Action.cpp

    rc09f94 r0d4168  
    136136  }
    137137  ActionState::ptr state = Action::failure;
    138 //  try {
    139     startTimer();
     138  startTimer();
     139  try {
    140140    state = performCall();
    141     endTimer();
    142 //  } catch(MissingValueException&) {
    143 //    ELOG(0, "There is a value missing for action " << getName());
    144 //  };
     141  } catch (ParameterException &e) {
     142    if( const std::string *name=boost::get_error_info<ParameterName>(e) )
     143      ELOG(1, "The following parameter value is not valid: " << *name << ".");
     144    state = Action::failure;
     145  }
     146  endTimer();
    145147
    146148  if(shouldUndo() && state != failure){
  • src/Actions/ActionQueue.cpp

    rc09f94 r0d4168  
    4646#include <vector>
    4747
     48#include "Actions/ActionExceptions.hpp"
    4849#include "Actions/ActionHistory.hpp"
    4950#include "Actions/ActionRegistry.hpp"
     51#include "World.hpp"
    5052
    5153using namespace MoleCuilder;
     
    7981  newaction->prepare(state);
    8082  actionqueue.push_back( newaction );
    81   newaction->call();
     83  try {
     84    newaction->call();
     85  } catch(ActionFailureException &e) {
     86    std::cerr << "Action " << *boost::get_error_info<ActionNameString>(e) << " has failed." << std::endl;
     87    World::getInstance().setExitFlag(5);
     88  }
    8289}
    8390
  • src/Actions/GlobalListOfActions.hpp

    rc09f94 r0d4168  
    4848  (CommandHelp) \
    4949  (CommandHelpRedistribute) \
    50   (CommandLoadSession) \
    5150  (CommandSetRandomNumbersEngine) \
    5251  (CommandSetRandomNumbersDistribution) \
     
    170169
    171170// define final list
    172 #define GLOBALLISTOFACTIONS GLOBALLISTOFACTIONS_LEVMAR
     171
     172#ifdef HAVE_PYTHON
     173#define GLOBALLISTOFACTIONS_PYTHON \
     174    BOOST_PP_SEQ_PUSH_BACK( \
     175        GLOBALLISTOFACTIONS_LEVMAR, \
     176        CommandLoadSession \
     177    )
     178#else
     179#define GLOBALLISTOFACTIONS_PYTHON \
     180    GLOBALLISTOFACTIONS_LEVMAR
     181#endif
     182
     183#define GLOBALLISTOFACTIONS GLOBALLISTOFACTIONS_PYTHON
     184
     185// define python list
     186// skips CommandLoadSession as this causes dangerous infinite loops
     187#define GLOBALLISTOFPYTHONACTIONS \
     188  GLOBALLISTOFACTIONS_LEVMAR
    173189
    174190#endif /* GLOBALLISTOFACTIONS_HPP_ */
  • src/Actions/Makefile.am

    rc09f94 r0d4168  
    190190  Actions/CommandAction/HelpAction.cpp \
    191191  Actions/CommandAction/HelpRedistributeAction.cpp \
    192   Actions/CommandAction/LoadSessionAction.cpp \
    193192  Actions/CommandAction/StoreSessionAction.cpp \
    194193  Actions/CommandAction/VerboseAction.cpp \
     
    201200  Actions/CommandAction/HelpAction.hpp \
    202201  Actions/CommandAction/HelpRedistributeAction.hpp \
    203   Actions/CommandAction/LoadSessionAction.hpp \
    204202  Actions/CommandAction/StoreSessionAction.hpp \
    205203  Actions/CommandAction/VerboseAction.hpp \
     
    212210  Actions/CommandAction/HelpAction.def \
    213211  Actions/CommandAction/HelpRedistributeAction.def \
    214   Actions/CommandAction/LoadSessionAction.def \
    215212  Actions/CommandAction/StoreSessionAction.def \
    216213  Actions/CommandAction/VerboseAction.def \
    217214  Actions/CommandAction/VersionAction.def \
    218215  Actions/CommandAction/WarrantyAction.def
     216
     217if CONDPYTHON
     218CMDACTIONSOURCE += \
     219  Actions/CommandAction/LoadSessionAction.cpp
     220CMDACTIONHEADER += \
     221  Actions/CommandAction/LoadSessionAction.hpp
     222CMDACTIONDEFS += \
     223  Actions/CommandAction/LoadSessionAction.def
     224endif
    219225
    220226FILLACTIONSOURCE = \
Note: See TracChangeset for help on using the changeset viewer.