Ignore:
Timestamp:
Aug 5, 2015, 7:12:24 AM (9 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:
c307ba
Parents:
94232b
git-author:
Frederik Heber <heber@…> (08/03/15 09:25:02)
git-committer:
Frederik Heber <heber@…> (08/05/15 07:12:24)
Message:

Cleaned up ActionQueue's interface: Actions are always cloned.

  • Action's dstor needs to be public as we have a clone() function.
  • ActionRegistrys' (and AQ's) getActionByName now returns const ref. We must not return a ptr as it may not get deleted elsewhere. We are handing out prototypes.
  • queueAction(action*,...) is private to prevent leakage, queueAction(string, ...) is the public interface.
  • some other small functions are now private, too.
  • MakroActions now need to clone() the prototype on prepare() and delete them on unprepare().
  • ActionSequence deletes contained actions.
  • FIX: ActionSequenceUnitTest cannot check on not-called property of removed actions anymore as these are gone now (they are deleted on removal and they are cloned on insertion).
  • DOCU: Updated documentation on Actions.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/ActionSequence.cpp

    r94232b r10aee4  
    2222
    2323/*
    24  * ActionSequenze.cpp
     24 * ActionSequence.cpp
    2525 *
    2626 *  Created on: Dec 17, 2009
     
    6060
    6161ActionSequence::~ActionSequence()
    62 {}
    63 
    64 
    65 void ActionSequence::addAction(Action* _action){
     62{
     63  for (actionSet::iterator iter = actions.begin(); !actions.empty(); iter = actions.begin()) {
     64    delete *iter;
     65    actions.erase(iter);
     66  }
     67}
     68
     69
     70void ActionSequence::addAction(Action* _action)
     71{
     72  // actions are already clone on push as ActionRegistry hands out const refs only
    6673  actions.push_back(_action);
    6774}
    6875
    69 bool ActionSequence::removeAction(const std::string &name){
     76bool ActionSequence::removeAction(const std::string &name)
     77{
    7078  actionSet::iterator it=actions.begin();
    7179  for(; it!=actions.end(); it++){
    7280    if ((*it)->getName() == name) {
     81      delete *it;
    7382      actions.erase(it);
    7483      break;
     
    7887}
    7988
    80 Action* ActionSequence::removeLastAction(){
     89Action* ActionSequence::removeLastAction()
     90{
    8191  if(actions.empty()) {
    8292    return 0;
     
    92102// this method is used outside the ActionModule
    93103// Each action registers itself with the history
    94 Dialog* ActionSequence::fillAllDialogs(Dialog *dialog){
     104Dialog* ActionSequence::fillAllDialogs(Dialog *dialog)
     105{
    95106  for(actionSet::iterator it=actions.begin(); it!=actions.end(); it++){
    96107    dialog = (*it)->fillDialog(dialog);
     
    101112// this method is used outside the ActionModule
    102113// Each action registers itself with the history
    103 void ActionSequence::callAll(){
     114void ActionSequence::callAll()
     115{
    104116  for (size_t i=0;i<loop;++i)
    105117    for(actionSet::iterator it=actions.begin(); it!=actions.end(); it++){
     
    113125// In this case only the makro Action should be registered and
    114126// handle the states
    115 ActionSequence::stateSet ActionSequence::callAll(bool){
     127ActionSequence::stateSet ActionSequence::callAll(bool)
     128{
    116129  stateSet states;
    117130  for (size_t i=0;i<loop;++i)
     
    127140}
    128141
    129 ActionSequence::stateSet ActionSequence::undoAll(stateSet states){
     142ActionSequence::stateSet ActionSequence::undoAll(stateSet states)
     143{
    130144  ASSERT(canUndo(),"Trying to undo a sequence that contains methods that can't be undone");
    131145  stateSet res;
     
    147161}
    148162
    149 ActionSequence::stateSet ActionSequence::redoAll(stateSet states){
     163ActionSequence::stateSet ActionSequence::redoAll(stateSet states)
     164{
    150165  stateSet res;
    151166  actionSet::iterator actionIt = actions.begin();
     
    164179}
    165180
    166 bool ActionSequence::canUndo(){
     181bool ActionSequence::canUndo()
     182{
    167183  bool canUndo=true;
    168184  for(std::deque<Action*>::iterator it=actions.begin(); it!=actions.end(); ++it){
     
    174190}
    175191
    176 bool ActionSequence::shouldUndo(){
     192bool ActionSequence::shouldUndo()
     193{
    177194  bool shouldUndo = false;
    178195  for(std::deque<Action*>::iterator it=actions.begin();it!=actions.end();++it){
Note: See TracChangeset for help on using the changeset viewer.