- Timestamp:
- Aug 5, 2015, 7:12:24 AM (10 years ago)
- 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)
- Location:
- src
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/Action.hpp
r94232b r10aee4 111 111 enum QueryOptions {Interactive, NonInteractive}; 112 112 113 /** Destructor for class Action. 114 * 115 * Needs to be public as clone() is a public function. 116 * 117 */ 118 virtual ~Action(); 119 113 120 protected: 114 121 /** … … 125 132 */ 126 133 Action(const ActionTrait &_Traits); 127 virtual ~Action();128 134 129 135 /** -
src/Actions/ActionQueue.cpp
r94232b r10aee4 94 94 void ActionQueue::queueAction(const std::string &name, enum Action::QueryOptions state) 95 95 { 96 const Action * constregistryaction = AR->getActionByName(name);97 queueAction( registryaction, state);96 const Action & registryaction = AR->getActionByName(name); 97 queueAction(®istryaction, state); 98 98 } 99 99 … … 263 263 #endif 264 264 265 Action*ActionQueue::getActionByName(const std::string &name)265 const Action& ActionQueue::getActionByName(const std::string &name) 266 266 { 267 267 return AR->getActionByName(name); … … 313 313 { 314 314 // this const_cast is just required as long as we have a non-const getActionByName 315 const Action * constaction = const_cast<ActionQueue *>(this)->getActionByName(name);316 return action ->Traits;315 const Action & action = const_cast<ActionQueue *>(this)->getActionByName(name); 316 return action.Traits; 317 317 } 318 318 -
src/Actions/ActionQueue.hpp
r94232b r10aee4 79 79 void queueAction(const std::string &name, enum Action::QueryOptions state = Action::Interactive); 80 80 81 /** Queues the Action with \a name to be called.82 *83 * \param _action action to add84 * \param state whether Actions needs to be filled via a Dialog or not85 */86 void queueAction(const Action * const _action, enum Action::QueryOptions state = Action::Interactive);87 88 81 /** Returns the spawned action by token \a name. 89 82 * 90 83 * Action is checked into internal actionqueue. 91 84 * 92 * \return pointerto newly spawned action93 */ 94 Action*getActionByName(const std::string &name);85 * \return ref to newly spawned action 86 */ 87 const Action& getActionByName(const std::string &name); 95 88 96 89 /** Checks whether the Action is known by the given \a name. … … 164 157 bool getLastActionOk() const 165 158 { return lastActionOk; } 166 167 #ifdef HAVE_ACTION_THREAD168 boost::thread &getRunThread()169 { return run_thread; }170 #endif171 159 172 160 /** Getter to ref to list of status messages. … … 200 188 friend class DryRunAdvocate; 201 189 190 /** Queues the Action with \a name to be called. 191 * 192 * \param _action action to add 193 * \param state whether Actions needs to be filled via a Dialog or not 194 */ 195 void queueAction(const Action * const _action, enum Action::QueryOptions state = Action::Interactive); 196 202 197 /** Wrapper function to add state to ActionHistory. 203 198 * … … 225 220 226 221 #ifdef HAVE_ACTION_THREAD 222 boost::thread &getRunThread() 223 { return run_thread; } 227 224 228 225 /** Clears the temporary queue. -
src/Actions/ActionRegistry.cpp
r94232b r10aee4 62 62 //std::cout << "ActionRegistry::ActionRegistry() called, instance is " << this << "." << std::endl; 63 63 fillRegistry(); 64 prepareAllMakroActions(); 64 65 fillOptionRegistry(); 65 66 completely_instatiated = true; … … 75 76 // add all MakroActions: PLEASE adhere to the alphabetical ordering 76 77 { 77 MakroAction * presentAction = 78 dynamic_cast<MakroAction *>(getActionByName("molecular-dynamics")); 79 ASSERT( presentAction != NULL, 80 "ActionRegistry::fillRegistry() - makro action has not been registered."); 81 presentAction->unprepare(*this); 82 } 83 { 84 MakroAction * presentAction = 85 dynamic_cast<MakroAction *>(getActionByName("optimize-structure")); 86 ASSERT( presentAction != NULL, 87 "ActionRegistry::fillRegistry() - makro action has not been registered."); 88 presentAction->unprepare(*this); 89 } 90 { 91 MakroAction * presentAction = 92 dynamic_cast<MakroAction *>(getActionByName("subgraph-dissection")); 93 ASSERT( presentAction != NULL, 94 "ActionRegistry::fillRegistry() - makro action has not been registered."); 95 presentAction->unprepare(*this); 96 } 97 { 98 MakroAction * presentAction = 99 dynamic_cast<MakroAction *>(getActionByName("translate-molecules")); 100 ASSERT( presentAction != NULL, 101 "ActionRegistry::fillRegistry() - makro action has not been registered."); 102 presentAction->unprepare(*this); 78 MakroAction & presentAction = 79 const_cast<MakroAction &>( 80 dynamic_cast<const MakroAction &>(getActionByName("molecular-dynamics"))); 81 presentAction.unprepare(*this); 82 } 83 { 84 MakroAction & presentAction = 85 const_cast<MakroAction &>( 86 dynamic_cast<const MakroAction &>(getActionByName("optimize-structure"))); 87 presentAction.unprepare(*this); 88 } 89 { 90 MakroAction & presentAction = 91 const_cast<MakroAction &>( 92 dynamic_cast<const MakroAction &>(getActionByName("subgraph-dissection"))); 93 presentAction.unprepare(*this); 94 } 95 { 96 MakroAction & presentAction = 97 const_cast<MakroAction &>( 98 dynamic_cast<const MakroAction &>(getActionByName("translate-molecules"))); 99 presentAction.unprepare(*this); 103 100 } 104 101 … … 124 121 #include BOOST_PP_LOCAL_ITERATE() 125 122 #undef instance_print 126 123 } 124 125 void ActionRegistry::prepareAllMakroActions() 126 { 127 127 // now prepare each macro action that require presence of all primitive ones 128 128 { 129 MakroAction * presentAction = 130 dynamic_cast<MakroAction *>(getActionByName("subgraph-dissection")); 131 ASSERT( presentAction != NULL, 132 "ActionRegistry::fillRegistry() - makro action has not been registered."); 133 presentAction->prepare(*this); 134 } 135 { 136 MakroAction * presentAction = 137 dynamic_cast<MakroAction *>(getActionByName("molecular-dynamics")); 138 ASSERT( presentAction != NULL, 139 "ActionRegistry::fillRegistry() - makro action has not been registered."); 140 presentAction->prepare(*this); 141 } 142 { 143 MakroAction * presentAction = 144 dynamic_cast<MakroAction *>(getActionByName("optimize-structure")); 145 ASSERT( presentAction != NULL, 146 "ActionRegistry::fillRegistry() - makro action has not been registered."); 147 presentAction->prepare(*this); 148 } 149 { 150 MakroAction * presentAction = 151 dynamic_cast<MakroAction *>(getActionByName("translate-molecules")); 152 ASSERT( presentAction != NULL, 153 "ActionRegistry::fillRegistry() - makro action has not been registered."); 154 presentAction->prepare(*this); 129 MakroAction & presentAction = 130 const_cast<MakroAction &>( 131 dynamic_cast<const MakroAction &>(getActionByName("subgraph-dissection"))); 132 presentAction.prepare(*this); 133 } 134 { 135 MakroAction & presentAction = 136 const_cast<MakroAction &>( 137 dynamic_cast<const MakroAction &>(getActionByName("molecular-dynamics"))); 138 presentAction.prepare(*this); 139 } 140 { 141 MakroAction & presentAction = 142 const_cast<MakroAction &>( 143 dynamic_cast<const MakroAction &>(getActionByName("optimize-structure"))); 144 presentAction.prepare(*this); 145 } 146 { 147 MakroAction & presentAction = 148 const_cast<MakroAction &>( 149 dynamic_cast<const MakroAction &>(getActionByName("translate-molecules"))); 150 presentAction.prepare(*this); 155 151 } 156 152 } … … 227 223 /** Just passes on call to Registry<Action>::getByName(). 228 224 * \param name name of Action 229 * \return pointer to Action 230 */ 231 Action* ActionRegistry::getActionByName(const std::string &name) 232 { 233 return getByName(name); 225 * \return const ref to Action 226 */ 227 const Action& ActionRegistry::getActionByName(const std::string &name) 228 { 229 Action * const action = getByName(name); 230 ASSERT( action != NULL, 231 "ActionRegistry::getActionByName() - action "+name+" not present!"); 232 return *action; 234 233 } 235 234 -
src/Actions/ActionRegistry.hpp
r94232b r10aee4 42 42 43 43 public: 44 Action*getActionByName(const std::string &name);44 const Action& getActionByName(const std::string &name); 45 45 bool isActionPresentByName(const std::string &name) const; 46 46 … … 59 59 void fillOptionRegistry() const; 60 60 void clearOptionRegistry() const; 61 void prepareAllMakroActions(); 61 62 62 63 //!> this tells whether ActionRegistry has been completed instantiated. -
src/Actions/ActionSequence.cpp
r94232b r10aee4 22 22 23 23 /* 24 * ActionSequen ze.cpp24 * ActionSequence.cpp 25 25 * 26 26 * Created on: Dec 17, 2009 … … 60 60 61 61 ActionSequence::~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 70 void ActionSequence::addAction(Action* _action) 71 { 72 // actions are already clone on push as ActionRegistry hands out const refs only 66 73 actions.push_back(_action); 67 74 } 68 75 69 bool ActionSequence::removeAction(const std::string &name){ 76 bool ActionSequence::removeAction(const std::string &name) 77 { 70 78 actionSet::iterator it=actions.begin(); 71 79 for(; it!=actions.end(); it++){ 72 80 if ((*it)->getName() == name) { 81 delete *it; 73 82 actions.erase(it); 74 83 break; … … 78 87 } 79 88 80 Action* ActionSequence::removeLastAction(){ 89 Action* ActionSequence::removeLastAction() 90 { 81 91 if(actions.empty()) { 82 92 return 0; … … 92 102 // this method is used outside the ActionModule 93 103 // Each action registers itself with the history 94 Dialog* ActionSequence::fillAllDialogs(Dialog *dialog){ 104 Dialog* ActionSequence::fillAllDialogs(Dialog *dialog) 105 { 95 106 for(actionSet::iterator it=actions.begin(); it!=actions.end(); it++){ 96 107 dialog = (*it)->fillDialog(dialog); … … 101 112 // this method is used outside the ActionModule 102 113 // Each action registers itself with the history 103 void ActionSequence::callAll(){ 114 void ActionSequence::callAll() 115 { 104 116 for (size_t i=0;i<loop;++i) 105 117 for(actionSet::iterator it=actions.begin(); it!=actions.end(); it++){ … … 113 125 // In this case only the makro Action should be registered and 114 126 // handle the states 115 ActionSequence::stateSet ActionSequence::callAll(bool){ 127 ActionSequence::stateSet ActionSequence::callAll(bool) 128 { 116 129 stateSet states; 117 130 for (size_t i=0;i<loop;++i) … … 127 140 } 128 141 129 ActionSequence::stateSet ActionSequence::undoAll(stateSet states){ 142 ActionSequence::stateSet ActionSequence::undoAll(stateSet states) 143 { 130 144 ASSERT(canUndo(),"Trying to undo a sequence that contains methods that can't be undone"); 131 145 stateSet res; … … 147 161 } 148 162 149 ActionSequence::stateSet ActionSequence::redoAll(stateSet states){ 163 ActionSequence::stateSet ActionSequence::redoAll(stateSet states) 164 { 150 165 stateSet res; 151 166 actionSet::iterator actionIt = actions.begin(); … … 164 179 } 165 180 166 bool ActionSequence::canUndo(){ 181 bool ActionSequence::canUndo() 182 { 167 183 bool canUndo=true; 168 184 for(std::deque<Action*>::iterator it=actions.begin(); it!=actions.end(); ++it){ … … 174 190 } 175 191 176 bool ActionSequence::shouldUndo(){ 192 bool ActionSequence::shouldUndo() 193 { 177 194 bool shouldUndo = false; 178 195 for(std::deque<Action*>::iterator it=actions.begin();it!=actions.end();++it){ -
src/Actions/ActionSequence.hpp
r94232b r10aee4 1 1 /* 2 * ActionSequen ze.hpp2 * ActionSequence.hpp 3 3 * 4 4 * Created on: Dec 17, 2009 -
src/Actions/Action_impl_pre.hpp
r94232b r10aee4 394 394 ) 395 395 { 396 ACTION * ToCall = dynamic_cast<ACTION*>(ActionQueue::getInstance().getActionByName( TOKEN )); //->clone(params);396 ACTION * const ToCall = dynamic_cast<ACTION*>(ActionQueue::getInstance().getActionByName( TOKEN ).clone()); 397 397 //ACTION::PARAMS params; 398 398 #if defined paramreferences && BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0) … … 411 411 #endif 412 412 ) { 413 ACTION * ToCall = dynamic_cast<ACTION*>(ActionQueue::getInstance().getActionByName( TOKEN )); //->clone(params);413 ACTION * const ToCall = dynamic_cast<ACTION*>(ActionQueue::getInstance().getActionByName( TOKEN ).clone()); 414 414 //ACTION::PARAMS params; 415 415 #if defined paramtypes && defined paramtypes && BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0) -
src/Actions/CommandAction/HelpAction.cpp
r94232b r10aee4 92 92 // retrieve command from Registry and print its help 93 93 if (AQ.isActionKnownByName(params.actionname.get())) { 94 const Action *instance = AQ.getActionByName(params.actionname.get());94 const Action &instance = AQ.getActionByName(params.actionname.get()); 95 95 // else give description of Action and its option value if present 96 std::cout << instance ->help();96 std::cout << instance.help(); 97 97 std::cout << std::endl; 98 98 std::cout << std::endl; -
src/Actions/FragmentationAction/MolecularDynamicsAction.cpp
r94232b r10aee4 62 62 // present. If not, we still copy the position cleanly into a new step where then 63 63 // forces are set according to summed fragmentary contributions. This is much cleaner. 64 prototype_actions.addAction(AR.getActionByName(std::string("verlet-integration")) );65 prototype_actions.addAction(AR.getActionByName(std::string("output")) );66 prototype_actions.addAction(AR.getActionByName(std::string("clear-fragment-results")) );67 prototype_actions.addAction(AR.getActionByName(std::string("destroy-adjacency")) );68 prototype_actions.addAction(AR.getActionByName(std::string("create-adjacency")) );69 prototype_actions.addAction(AR.getActionByName(std::string("correct-bonddegree")) );70 prototype_actions.addAction(AR.getActionByName(std::string("update-molecules")) );71 prototype_actions.addAction(AR.getActionByName(std::string("fragment-molecule")) );72 prototype_actions.addAction(AR.getActionByName(std::string("fragment-automation")) );73 prototype_actions.addAction(AR.getActionByName(std::string("analyse-fragment-results")) );64 prototype_actions.addAction(AR.getActionByName(std::string("verlet-integration")).clone()); 65 prototype_actions.addAction(AR.getActionByName(std::string("output")).clone()); 66 prototype_actions.addAction(AR.getActionByName(std::string("clear-fragment-results")).clone()); 67 prototype_actions.addAction(AR.getActionByName(std::string("destroy-adjacency")).clone()); 68 prototype_actions.addAction(AR.getActionByName(std::string("create-adjacency")).clone()); 69 prototype_actions.addAction(AR.getActionByName(std::string("correct-bonddegree")).clone()); 70 prototype_actions.addAction(AR.getActionByName(std::string("update-molecules")).clone()); 71 prototype_actions.addAction(AR.getActionByName(std::string("fragment-molecule")).clone()); 72 prototype_actions.addAction(AR.getActionByName(std::string("fragment-automation")).clone()); 73 prototype_actions.addAction(AR.getActionByName(std::string("analyse-fragment-results")).clone()); 74 74 isPrepared = true; 75 75 } … … 78 78 { 79 79 // empty sequence 80 while (prototype_actions.removeLastAction() != NULL); 80 Action *actionremove = NULL; 81 while ((actionremove = prototype_actions.removeLastAction()) != NULL) 82 delete actionremove; 81 83 isPrepared = false; 82 84 } -
src/Actions/FragmentationAction/StructuralOptimizationAction.cpp
r94232b r10aee4 62 62 // present. If not, we still copy the position cleanly into a new step where then 63 63 // forces are set according to summed fragmentary contributions. This is much cleaner. 64 prototype_actions.addAction(AR.getActionByName(std::string("destroy-adjacency")) );65 prototype_actions.addAction(AR.getActionByName(std::string("create-adjacency")) );66 prototype_actions.addAction(AR.getActionByName(std::string("correct-bonddegree")) );67 prototype_actions.addAction(AR.getActionByName(std::string("update-molecules")) );68 prototype_actions.addAction(AR.getActionByName(std::string("fragment-molecule")) );69 prototype_actions.addAction(AR.getActionByName(std::string("fragment-automation")) );70 prototype_actions.addAction(AR.getActionByName(std::string("analyse-fragment-results")) );71 prototype_actions.addAction(AR.getActionByName(std::string("force-annealing")) );72 prototype_actions.addAction(AR.getActionByName(std::string("output")) );73 prototype_actions.addAction(AR.getActionByName(std::string("clear-fragment-results")) );64 prototype_actions.addAction(AR.getActionByName(std::string("destroy-adjacency")).clone()); 65 prototype_actions.addAction(AR.getActionByName(std::string("create-adjacency")).clone()); 66 prototype_actions.addAction(AR.getActionByName(std::string("correct-bonddegree")).clone()); 67 prototype_actions.addAction(AR.getActionByName(std::string("update-molecules")).clone()); 68 prototype_actions.addAction(AR.getActionByName(std::string("fragment-molecule")).clone()); 69 prototype_actions.addAction(AR.getActionByName(std::string("fragment-automation")).clone()); 70 prototype_actions.addAction(AR.getActionByName(std::string("analyse-fragment-results")).clone()); 71 prototype_actions.addAction(AR.getActionByName(std::string("force-annealing")).clone()); 72 prototype_actions.addAction(AR.getActionByName(std::string("output")).clone()); 73 prototype_actions.addAction(AR.getActionByName(std::string("clear-fragment-results")).clone()); 74 74 isPrepared = true; 75 75 } … … 78 78 { 79 79 // empty sequence 80 while (prototype_actions.removeLastAction() != NULL); 80 Action *actionremove = NULL; 81 while ((actionremove = prototype_actions.removeLastAction()) != NULL) 82 delete actionremove; 81 83 isPrepared = false; 82 84 } -
src/Actions/GraphAction/SubgraphDissectionAction.cpp
r94232b r10aee4 63 63 void GraphSubgraphDissectionAction::prepare(ActionRegistry &AR) 64 64 { 65 prototype_actions.addAction(AR.getActionByName(std::string("push-atom-selection")) );66 prototype_actions.addAction(AR.getActionByName(std::string("select-all-atoms")) );67 prototype_actions.addAction(AR.getActionByName(std::string("destroy-adjacency")) );68 prototype_actions.addAction(AR.getActionByName(std::string("create-adjacency")) );69 prototype_actions.addAction(AR.getActionByName(std::string("update-molecules")) );70 prototype_actions.addAction(AR.getActionByName(std::string("pop-atom-selection")) );65 prototype_actions.addAction(AR.getActionByName(std::string("push-atom-selection")).clone()); 66 prototype_actions.addAction(AR.getActionByName(std::string("select-all-atoms")).clone()); 67 prototype_actions.addAction(AR.getActionByName(std::string("destroy-adjacency")).clone()); 68 prototype_actions.addAction(AR.getActionByName(std::string("create-adjacency")).clone()); 69 prototype_actions.addAction(AR.getActionByName(std::string("update-molecules")).clone()); 70 prototype_actions.addAction(AR.getActionByName(std::string("pop-atom-selection")).clone()); 71 71 isPrepared = true; 72 72 } … … 75 75 { 76 76 // empty sequence 77 while (prototype_actions.removeLastAction() != NULL); 77 Action *actionremove = NULL; 78 while ((actionremove = prototype_actions.removeLastAction()) != NULL) 79 delete actionremove; 78 80 isPrepared = false; 79 81 } -
src/Actions/MakroAction.cpp
r94232b r10aee4 74 74 MakroAction::~MakroAction() 75 75 { 76 // emptying the sequence is someone else responsibility 77 // Action* action; 78 // while((action=actions.removeLastAction())){ 79 // delete action; 80 // } 76 // emptying the sequence is done in ActionSequence 81 77 } 82 78 -
src/Actions/MakroAction.hpp
r94232b r10aee4 37 37 MakroAction(const MakroAction &_instance); 38 38 MakroAction(const ActionTrait &_trait,ActionSequence& _actions); 39 virtual ~MakroAction();40 39 41 40 bool canUndo(); … … 56 55 57 56 protected: 57 virtual ~MakroAction(); 58 58 59 /** 59 60 * MakroAction requires an own dialog for global options such as number of loop -
src/Actions/MakroAction_impl_pre.hpp
r94232b r10aee4 362 362 ) 363 363 { 364 ACTION * ToCall = dynamic_cast<ACTION*>(ActionQueue::getInstance().getActionByName( TOKEN )); //->clone(params);364 ACTION * const ToCall = dynamic_cast<ACTION*>(ActionQueue::getInstance().getActionByName( TOKEN ).clone()); 365 365 //ACTION::PARAMS params; 366 366 #if defined paramreferences && BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0) … … 379 379 #endif 380 380 ) { 381 ACTION * ToCall = dynamic_cast<ACTION*>(ActionQueue::getInstance().getActionByName( TOKEN )); //->clone(params);381 ACTION * const ToCall = dynamic_cast<ACTION*>(ActionQueue::getInstance().getActionByName( TOKEN ).clone()); 382 382 //ACTION::PARAMS params; 383 383 #if defined paramtypes && defined paramtypes && BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0) -
src/Actions/MoleculeAction/TranslateAction.cpp
r94232b r10aee4 63 63 // we simply have to select all the molecule's atoms and use the respective 64 64 // translate Action 65 prototype_actions.addAction(AR.getActionByName(std::string("push-atom-selection")) );66 prototype_actions.addAction(AR.getActionByName(std::string("select-molecules-atoms")) );67 prototype_actions.addAction(AR.getActionByName(std::string("translate-atoms")) );68 prototype_actions.addAction(AR.getActionByName(std::string("pop-atom-selection")) );65 prototype_actions.addAction(AR.getActionByName(std::string("push-atom-selection")).clone()); 66 prototype_actions.addAction(AR.getActionByName(std::string("select-molecules-atoms")).clone()); 67 prototype_actions.addAction(AR.getActionByName(std::string("translate-atoms")).clone()); 68 prototype_actions.addAction(AR.getActionByName(std::string("pop-atom-selection")).clone()); 69 69 isPrepared = true; 70 70 } … … 73 73 { 74 74 // empty sequence 75 while (prototype_actions.removeLastAction() != NULL); 75 Action *actionremove = NULL; 76 while ((actionremove = prototype_actions.removeLastAction()) != NULL) 77 delete actionremove; 76 78 isPrepared = false; 77 79 } -
src/Actions/unittests/ActionSequenceUnitTest.cpp
r94232b r10aee4 239 239 { 240 240 ActionSequence *sequence = new ActionSequence(); 241 sequence->addAction(positive1 );242 sequence->addAction(positive2 );241 sequence->addAction(positive1->clone()); 242 sequence->addAction(positive2->clone()); 243 243 CPPUNIT_ASSERT_EQUAL( true, sequence->canUndo() ); 244 244 delete sequence; … … 246 246 { 247 247 ActionSequence *sequence = new ActionSequence(); 248 sequence->addAction(positive1 );249 sequence->addAction(negative2 );248 sequence->addAction(positive1->clone()); 249 sequence->addAction(negative2->clone()); 250 250 CPPUNIT_ASSERT_EQUAL( false, sequence->canUndo() ); 251 251 delete sequence; … … 253 253 { 254 254 ActionSequence *sequence = new ActionSequence(); 255 sequence->addAction(negative1 );256 sequence->addAction(positive2 );255 sequence->addAction(negative1->clone()); 256 sequence->addAction(positive2->clone()); 257 257 CPPUNIT_ASSERT_EQUAL( false, sequence->canUndo() ); 258 258 delete sequence; … … 260 260 { 261 261 ActionSequence *sequence = new ActionSequence(); 262 sequence->addAction(negative1 );263 sequence->addAction(negative2 );262 sequence->addAction(negative1->clone()); 263 sequence->addAction(negative2->clone()); 264 264 CPPUNIT_ASSERT_EQUAL( false, sequence->canUndo() ); 265 265 delete sequence; … … 273 273 CPPUNIT_ASSERT_EQUAL( true, sequence->canUndo() ); 274 274 // if only a positive action is contained it can be undone 275 sequence->addAction(positive1 );275 sequence->addAction(positive1->clone()); 276 276 CPPUNIT_ASSERT_EQUAL( true, sequence->canUndo() ); 277 277 // the single negative action should block the process 278 sequence->addAction(negative1 );278 sequence->addAction(negative1->clone()); 279 279 CPPUNIT_ASSERT_EQUAL( false, sequence->canUndo() ); 280 280 // after removing the negative action all is well again 281 sequence->removeLastAction();281 delete sequence->removeLastAction(); 282 282 CPPUNIT_ASSERT_EQUAL( true, sequence->canUndo() ); 283 283 delete sequence; … … 287 287 void ActionSequenceTest::doesCallTest(){ 288 288 ActionSequence *sequence = new ActionSequence(); 289 sequence->addAction(shouldCall1 );290 sequence->addAction(shouldCall2 );291 sequence->addAction(shouldNotCall1 );292 sequence->addAction(shouldNotCall2 );293 sequence->removeLastAction();294 sequence->removeLastAction();289 sequence->addAction(shouldCall1->clone()); 290 sequence->addAction(shouldCall2->clone()); 291 sequence->addAction(shouldNotCall1->clone()); 292 sequence->addAction(shouldNotCall2->clone()); 293 delete sequence->removeLastAction(); 294 delete sequence->removeLastAction(); 295 295 296 296 sequence->callAll(); 297 297 298 CPPUNIT_ASSERT_EQUAL(true,shouldCall1->wasCalled());299 CPPUNIT_ASSERT_EQUAL(true, shouldCall2->wasCalled());300 CPPUNIT_ASSERT_EQUAL( false,shouldNotCall1->wasCalled());301 CPPUNIT_ASSERT _EQUAL(false,shouldNotCall2->wasCalled());298 ActionSequence::actionSet::const_iterator iter = sequence->actions.begin(); 299 CPPUNIT_ASSERT_EQUAL(true,dynamic_cast<wasCalledActionStub *>(*iter++)->wasCalled()); 300 CPPUNIT_ASSERT_EQUAL(true,dynamic_cast<wasCalledActionStub *>(*iter++)->wasCalled()); 301 CPPUNIT_ASSERT( iter == sequence->actions.end() ); 302 302 303 303 delete sequence; -
src/UIElements/Menu/TextMenu/ActionMenuItem.cpp
r94232b r10aee4 57 57 58 58 bool ActionMenuItem::isActive() const { 59 Action*action = ActionQueue::getInstance().getActionByName(ActionName);60 return action ->isActive();59 const Action& action = ActionQueue::getInstance().getActionByName(ActionName); 60 return action.isActive(); 61 61 } -
src/UIElements/TextUI/TextWindow.cpp
r94232b r10aee4 86 86 87 87 // save has reserved key 's' 88 // Action *saveConfigAction = ActionQueue::getInstance().getActionByName("output");88 // const Action &saveConfigAction = ActionQueue::getInstance().getActionByName("output"); 89 89 new ActionMenuItem('s',"save current setup to config files",main_menu->getMenuInstance(),"output"); 90 90 -
src/documentation/constructs/actions.dox
r94232b r10aee4 34 34 * If an Action is requested via its known token from the ActionQueue 35 35 * (that contains the ActionRegistry), this prototype is cloned and added to the 36 * queue. 36 * queue. Action::clone() is a public function but only certain classes are 37 * allowed to directly add Action instances to the ActionQueue. Normally, an 38 * Action first has to be registered with the ActionRegistry and afterwards it 39 * may be added to the queue via its specific and unique token. 37 40 * 38 41 * Each Action can contain multiple \ref parameters in its specific … … 56 59 * such that the ActionRegistry knows about it and can instantiate a 57 60 * prototype. 61 * 62 * Most of the magic that fills in the remaining gaps of the Action's 63 * declaration and definition is done by boost::preprocessor magic in the 64 * files Action_impl_pre.hpp and Action_impl_header.hpp. There is a pendant 65 * for MakroActions. 66 * 67 * \section actions-types Specific types of actions 68 * 69 * There are some special types of Actions: 70 * -# Calculation: A process with a final result that can be requested 71 * -# MakroAction: A chain of other Actions to be executed various times 72 * -# MethodAction: An action that basically calls a certain bound method 73 * -# Process: An action that takes some time to complete and informs about 74 * how much work remains 75 * 76 * \section actions-types-add Add a specific types of action ... 77 * 78 * Instantiating the MakroAction is simple, only two functions, prepare() 79 * and unprepare(), are required that fill und empty the chain of Actions 80 * from Actions from the ActionRegistry. 81 * 82 * Adding a Process is much the same as adding a normal Action. There is a 83 * keyword BASECLASS in the associated \b .def file which should say Process 84 * and one needs to use Process::setCurrStep(int) to tell the Process and 85 * all listening Observers what the current stage of execution is. Also, 86 * initially a total number of steps must be stated via Process::setMaxSteps() 87 * When the job executes, this is initiated with Process::start() and when 88 * it stops, this is told via Process::stop(). 89 * 90 * A Calculation must be derived by hand and is not supported via the 91 * boost::preprocessor magic but behaves very similar to the Process itself 92 * with respect to informing about the current stage of execution. What's 93 * more is essentially the Calculation::doCalc() function that performs the 94 * actual calculation (must not changed the state of the World and hence 95 * there is not need for undo). The Calculation implementation takes care 96 * of the rest. 97 * 98 * A MethodAction is simply implemented by filling an ActionTraits structure 99 * with the desired values and bind a method that should get executed. 100 * Instantating the MethodAction with these parameters and executing 101 * ActionRegistry()::registerAction() then allows for using it in the context 102 * of the ActionQueue. 58 103 * 59 104 * \section actions-undo-redo Undoing and Redoing actions ... … … 81 126 * 82 127 * 83 * \date 201 4-03-10128 * \date 2015-08-03 84 129 * 85 130 */
Note:
See TracChangeset
for help on using the changeset viewer.