Changeset 67c75b for src/Actions


Ignore:
Timestamp:
Jun 2, 2010, 11:44:00 AM (15 years ago)
Author:
Tillmann Crueger <crueger@…>
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:
992fd7
Parents:
82b71a (diff), 190326 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'MenuRefactoring' into QT4Refactoring

Conflicts:

molecuilder/src/Makefile.am
molecuilder/src/builder.cpp
molecuilder/src/unittests/Makefile.am
molecuilder/src/vector.cpp

Location:
src/Actions
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/Action.cpp

    r82b71a r67c75b  
    1111#include "Actions/ActionRegistry.hpp"
    1212#include "Actions/ActionHistory.hpp"
     13#include "Helpers/MemDebug.hpp"
    1314
    1415using namespace std;
    1516
    1617// An empty state to indicate success
    17 Action::state_ptr Action::success = Action::state_ptr(new ActionState());
    18 Action::state_ptr Action::failure = Action::state_ptr(new ActionState());
     18Action::state_ptr Action::success = Action::state_ptr(Memory::ignore(new ActionState()));
     19Action::state_ptr Action::failure = Action::state_ptr(Memory::ignore(new ActionState()));
    1920
    2021Action::Action(std::string _name,bool _doRegister) :
  • src/Actions/Action.hpp

    r82b71a r67c75b  
    256256public:
    257257
     258  /**
     259   * This type is used to store pointers to ActionStates while allowing multiple ownership
     260   */
    258261  typedef boost::shared_ptr<ActionState> state_ptr;
    259262
     263  /**
     264   * Standard constructor of Action Base class
     265   *
     266   * All Actions need to have a name. The second flag indicates, whether the action should
     267   * be registered with the ActionRegistry. If the Action is registered the name of the
     268   * Action needs to be unique for all Actions that are registered.
     269   */
    260270  Action(std::string _name,bool _doRegister=true);
    261271  virtual ~Action();
    262272
    263   // this method only handles the infrastructure
    264   // actuall action is passed on to a private virtual
     273  /**
     274   * This method is used to call an action. The basic operations for the Action
     275   * are carried out and if necessary/possible the Action is added to the History
     276   * to allow for undo of this action.
     277   *
     278   * If the call needs to undone you have to use the History, to avoid destroying
     279   * invariants used by the History.
     280   */
    265281  void call();
    266282
     283  /**
     284   * This method provides a flag that indicates if an undo mechanism is implemented
     285   * for this Action. If this is true, and this action was called last, you can
     286   * use the History to undo this action.
     287   */
    267288  virtual bool canUndo()=0;
     289
     290  /**
     291   * This method provides a flag, that indicates if the Action changes the state of
     292   * the application in a way that needs to be undone for the History to work.
     293   *
     294   * If this is false the Action will not be added to the History upon calling. However
     295   * Actions called before this one will still be available for undo.
     296   */
    268297  virtual bool shouldUndo()=0;
    269298
     299  /**
     300   * Indicates whether the Action can do it's work at the moment. If this
     301   * is false calling the action will result in a no-op.
     302   */
    270303  virtual bool isActive();
    271304
     305  /**
     306   * Returns the name of the Action.
     307   */
    272308  virtual const std::string getName();
    273309
    274310protected:
     311  /**
     312   * This method is called by the History, when an undo is performed. It is
     313   * provided with the corresponding state produced by the performCall or
     314   * performRedo method and needs to provide a state that can be used for redo.
     315   */
    275316  state_ptr undo(state_ptr);
     317
     318  /**
     319   * This method is called by the Histor, when a redo is performed. It is
     320   * provided with the corresponding state produced by the undo method and
     321   * needs to produce a State that can then be used for another undo.
     322   */
    276323  state_ptr redo(state_ptr);
    277324
     325  /**
     326   * This special state can be used to indicate that the Action was successfull
     327   * without providing a special state. Use this if your Action does not need
     328   * a speciallized state.
     329   */
    278330  static state_ptr success;
     331
     332  /**
     333   * This special state can be returned, to indicate that the action could not do it's
     334   * work, was abborted by the user etc. If you return this state make sure to transactionize
     335   * your Actions and unroll the complete transaction before this is returned.
     336   */
    279337  static state_ptr failure;
    280338
    281339private:
     340  /**
     341   * This is called internally when the call is being done. Implement this method to do the actuall
     342   * work of the Action. Implement this in your Derived classes. Needs to return a state that can be
     343   * used to undo the action.
     344   */
    282345  virtual state_ptr performCall()=0;
     346
     347  /**
     348   * This is called internally when the undo process is chosen. This Method should use the state
     349   * produced by the performCall method to return the state of the application to the state
     350   * it had before the Action.
     351   */
    283352  virtual state_ptr performUndo(state_ptr)=0;
     353
     354  /**
     355   * This is called internally when the redo process is chosen. This method shoudl use the state
     356   * produced by the performUndo method to return the application to the state it should have after
     357   * the action.
     358   *
     359   * Often this method can be implement to re-use the performCall method. However if user interaction
     360   * or further parameters are needed, those should be taken from the state and not query the user
     361   * again.
     362   */
    284363  virtual state_ptr performRedo(state_ptr)=0;
    285364
  • src/Actions/ActionHistory.cpp

    r82b71a r67c75b  
    1212#include "Patterns/Singleton_impl.hpp"
    1313#include "Helpers/Assert.hpp"
     14#include "Helpers/MemDebug.hpp"
    1415
    1516using namespace std;
  • src/Actions/small_actions.cpp

    r82b71a r67c75b  
    5555
    5656Action::state_ptr ChangeMoleculeNameAction::performUndo(Action::state_ptr _state) {
    57   ChangeMoleculeNameState *state = dynamic_cast<ChangeMoleculeNameState*>(_state.get());
    58   ASSERT(state,"State passed to ChangeMoleculeNameAction::performUndo did not have correct type");
     57  ChangeMoleculeNameState *state = assert_cast<ChangeMoleculeNameState*>(_state.get());
    5958
    6059  string newName = state->mol->getName();
Note: See TracChangeset for help on using the changeset viewer.