- Timestamp:
- Apr 29, 2014, 12:42:44 PM (11 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:
- 7fc447
- Parents:
- 36053c
- git-author:
- Frederik Heber <heber@…> (08/27/13 01:58:34)
- git-committer:
- Frederik Heber <heber@…> (04/29/14 12:42:44)
- Location:
- src
- Files:
-
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/Actions/Action.cpp ¶
r36053c raf5384 112 112 } 113 113 114 Dialog * Action::createDialog(){ 115 Dialog *dialog = UIFactory::getInstance().makeDialog(); 116 return fillDialog(dialog); 117 } 118 119 void Action::call(enum QueryOptions flag){ 120 if(!isActive()){ 121 return; 122 } 123 // forward to private virtual 114 void Action::prepare(enum QueryOptions flag) 115 { 116 // fill with 124 117 if (flag == Interactive) { 125 118 Dialog* dialog = createDialog(); … … 130 123 } 131 124 delete(dialog); 125 } 126 } 127 128 Dialog * Action::createDialog(){ 129 Dialog *dialog = UIFactory::getInstance().makeDialog(); 130 return fillDialog(dialog); 131 } 132 133 void Action::call(){ 134 if(!isActive()){ 135 return; 132 136 } 133 137 ActionState::ptr state = Action::failure; -
TabularUnified src/Actions/Action.hpp ¶
r36053c raf5384 133 133 * is thrown) 134 134 */ 135 void call( enum QueryOptions state = Interactive);135 void call(); 136 136 137 137 public: … … 167 167 */ 168 168 const std::string help() const; 169 170 /** Clones the Action. 171 * 172 */ 173 virtual Action* clone(enum QueryOptions flag = Interactive) const=0; 174 175 /** Prepares the Action's parameters. 176 * 177 */ 178 virtual void prepare(enum QueryOptions flag = Interactive); 169 179 170 180 /** Prints what would be necessary to add the Action from the Command Line Interface. -
TabularUnified src/Actions/ActionQueue.cpp ¶
r36053c raf5384 53 53 ActionQueue::ActionQueue() : 54 54 AR(new ActionRegistry()), 55 history(new ActionHistory) 55 history(new ActionHistory), 56 CurrentAction(0) 56 57 {} 57 58 58 59 ActionQueue::~ActionQueue() 59 60 { 60 queue.clear(); 61 // free all actions contained in queue 62 for (ActionQueue_t::iterator iter = queue.begin(); !queue.empty(); iter = queue.begin()) { 63 delete *iter; 64 queue.erase(iter); 65 } 66 61 67 delete history; 62 68 delete AR; … … 65 71 void ActionQueue::queueAction(const std::string &name, enum Action::QueryOptions state) 66 72 { 67 Action* _action = AR->getActionByName(name); 68 queue.push_back(_action); 69 _action->call(state); 73 queueAction(AR->getActionByName(name), state); 70 74 } 71 75 72 76 void ActionQueue::queueAction(Action *_action, enum Action::QueryOptions state) 73 77 { 74 queue.push_back(_action); 75 _action->call(state); 78 Action *newaction = _action->clone(state); 79 newaction->prepare(state); 80 queue.push_back( newaction ); 81 newaction->call(); 76 82 } 77 83 -
TabularUnified src/Actions/ActionQueue.hpp ¶
r36053c raf5384 16 16 #include "CodePatterns/Singleton.hpp" 17 17 18 #include <list>19 18 #include <vector> 20 19 … … 38 37 public: 39 38 typedef std::vector<std::string> ActionTokens_t; 40 typedef std:: list<Action *> ActionQueue_t;39 typedef std::vector< Action * > ActionQueue_t; 41 40 42 41 /** Queues the Action with \a name to be called. … … 104 103 void outputAsPython(std::ostream &output) const; 105 104 106 /** Undoes last called Ac tion.105 /** Undoes last called Acfriend void ::cleanUp();tion. 107 106 * 108 107 */ … … 113 112 */ 114 113 void redoLast(); 114 115 /** Getter for the last executed action. 116 * 117 * \note this is necessary for Reactions to actually have a chance of getting 118 * the calculated value as Action's are always cloned. 119 * 120 * \return const ref to last action 121 */ 122 const Action &getLastAction() const { 123 return *(queue.back()); 124 } 115 125 116 126 private: … … 151 161 //!> internal queue of actions 152 162 ActionQueue_t queue; 163 164 //!> point to current action in queue 165 size_t CurrentAction; 153 166 }; 154 167 -
TabularUnified src/Actions/ActionSequence.cpp ¶
r36053c raf5384 48 48 loop(1) 49 49 {} 50 51 ActionSequence::ActionSequence(const ActionSequence &_other) : 52 loop(1) 53 { 54 // we need to override copy cstor as we have pointer referenced objects 55 for(actionSet::iterator it=actions.begin(); it!=actions.end(); it++){ 56 actions.push_back((*it)->clone()); 57 } 58 } 50 59 51 60 ActionSequence::~ActionSequence() -
TabularUnified src/Actions/ActionSequence.hpp ¶
r36053c raf5384 32 32 33 33 ActionSequence(); 34 ActionSequence(const ActionSequence &_other); 34 35 virtual ~ActionSequence(); 35 36 -
TabularUnified src/Actions/Action_impl_header.hpp ¶
r36053c raf5384 212 212 bool shouldUndo(); 213 213 214 Action* clone(enum QueryOptions flag = Interactive) const; 215 214 216 void outputAsCLI(std::ostream &ost) const; 215 217 void outputAsPython(std::ostream &ost, const std::string &prefix) const; -
TabularUnified src/Actions/Action_impl_pre.hpp ¶
r36053c raf5384 292 292 {} 293 293 294 // =========== clone Action =========== 295 Action* ACTION::clone(enum QueryOptions flag) const 296 { 297 if (flag == Interactive) 298 return new ACTION(); 299 else 300 return new ACTION(*this); 301 } 302 294 303 // =========== fill a dialog =========== 295 304 Dialog* ACTION::fillDialog(Dialog *dialog) { -
TabularUnified src/Actions/AtomsCalculation.hpp ¶
r36053c raf5384 28 28 virtual ~AtomsCalculation(); 29 29 30 Action* clone(enum Action::QueryOptions flag = Action::Interactive) const; 31 30 32 protected: 31 33 virtual std::vector<T>* doCalc(); -
TabularUnified src/Actions/AtomsCalculation_impl.hpp ¶
r36053c raf5384 52 52 53 53 template<typename T> 54 Action* AtomsCalculation<T>::clone(enum Action::QueryOptions flag) const 55 { 56 if (flag == Action::Interactive) 57 return new AtomsCalculation<T>(op, Action::Traits, descr); 58 else 59 return new AtomsCalculation<T>(*this); 60 } 61 62 template<typename T> 54 63 Dialog *AtomsCalculation<T>::fillDialog(Dialog *dialog){ 55 64 ASSERT(dialog,"No Dialog given when filling action dialog"); -
TabularUnified src/Actions/Calculation.hpp ¶
r36053c raf5384 42 42 virtual bool shouldUndo(); 43 43 44 virtual Action* clone(enum QueryOptions flag = Interactive) const=0; 45 44 46 virtual void outputAsCLI(std::ostream &ost) const; 45 47 virtual void outputAsPython(std::ostream &ost, const std::string &prefix) const; … … 55 57 * Check if a cached result is available. 56 58 */ 57 virtual bool hasResult() ;59 virtual bool hasResult() const; 58 60 59 61 /** … … 61 63 * Fails if there is no cached result. 62 64 */ 63 virtual T getResult() ;65 virtual T getResult() const; 64 66 65 67 /** -
TabularUnified src/Actions/Calculation_impl.hpp ¶
r36053c raf5384 88 88 89 89 template<typename T> 90 bool Calculation<T>::hasResult() {90 bool Calculation<T>::hasResult() const { 91 91 return done; 92 92 } 93 93 94 94 template<typename T> 95 T Calculation<T>::getResult() {95 T Calculation<T>::getResult() const { 96 96 assert(done && "No result calculated"); 97 97 return *result; -
TabularUnified src/Actions/MakroAction.cpp ¶
r36053c raf5384 102 102 103 103 ActionState::ptr MakroAction::performCall(){ 104 // {105 // // create and run our dialog and also of all members of the sequence106 // Dialog* dialog = actions.fillAllDialogs(createDialog());107 // if (dialog->hasQueries()) {108 // if (!dialog->display())109 // // dialog error or aborted -> throw exception110 // throw ActionFailureException() << ActionNameString(getName());111 // }112 // delete(dialog);113 // }114 104 ActionSequence::stateSet states = actions.callAll(true); 115 105 return ActionState::ptr(new MakroActionState(states)); … … 138 128 } 139 129 130 Action* MakroAction::clone(enum QueryOptions flag) const 131 { 132 if (flag == Interactive) 133 return new MakroAction(Traits, actions); 134 else 135 return new MakroAction(*this); 136 } 137 138 void MakroAction::prepare(enum QueryOptions flag) 139 { 140 if (flag == Interactive) { 141 // create and run our dialog and also of all members of the sequence 142 Dialog* dialog = createDialog(); 143 if (dialog->hasQueries()) { 144 if (!dialog->display()) 145 // dialog error or aborted -> throw exception 146 throw ActionFailureException() << ActionNameString(getName()); 147 } 148 delete(dialog); 149 } 150 } 151 140 152 void MakroAction::outputAsCLI(std::ostream &ost) const 141 153 { -
TabularUnified src/Actions/MakroAction.hpp ¶
r36053c raf5384 36 36 bool canUndo(); 37 37 bool shouldUndo(); 38 39 virtual Action* clone(enum QueryOptions flag = Interactive) const; 40 void prepare(enum QueryOptions flag = Interactive); 38 41 39 42 virtual void outputAsCLI(std::ostream &ost) const; -
TabularUnified src/Actions/MakroAction_impl_header.hpp ¶
r36053c raf5384 218 218 bool shouldUndo(); 219 219 220 virtual Action* clone(enum QueryOptions flag = Interactive) const; 221 220 222 void outputAsCLI(std::ostream &ost) const; 221 223 void outputAsPython(std::ostream &ost, const std::string &prefix) const; -
TabularUnified src/Actions/MakroAction_impl_pre.hpp ¶
r36053c raf5384 291 291 {} 292 292 293 // =========== clone Action =========== 294 Action* ACTION::clone(enum QueryOptions flag) const 295 { 296 if (flag == Interactive) 297 return new ACTION(); 298 else 299 return new ACTION(*this); 300 } 301 293 302 // =========== fill a dialog =========== 294 303 Dialog* ACTION::fillOwnDialog(Dialog *dialog) { -
TabularUnified src/Actions/ManipulateAtomsProcess.cpp ¶
r36053c raf5384 103 103 stop(); 104 104 } 105 106 Action* ManipulateAtomsProcess::clone(enum QueryOptions flag) const 107 { 108 if (flag == Interactive) 109 return new ManipulateAtomsProcess(operation, descr, Traits); 110 else 111 return new ManipulateAtomsProcess(*this); 112 } -
TabularUnified src/Actions/ManipulateAtomsProcess.hpp ¶
r36053c raf5384 38 38 virtual bool shouldUndo(); 39 39 40 Action* clone(enum QueryOptions flag = Interactive) const; 41 40 42 void outputAsCLI(std::ostream &ost) const; 41 43 void outputAsPython(std::ostream &ost, const std::string &prefix) const; … … 47 49 * 48 50 */ 49 void call( enum QueryOptions state = Interactive)50 { Process::call( state); }51 void call() 52 { Process::call(); } 51 53 52 54 protected: -
TabularUnified src/Actions/MethodAction.cpp ¶
r36053c raf5384 83 83 } 84 84 85 Action* MethodAction::clone(enum QueryOptions flag) const 86 { 87 if (flag == Interactive) 88 return new MethodAction(Traits, executeMethod); 89 else 90 return new MethodAction(*this); 91 } 92 85 93 void MethodAction::outputAsCLI(std::ostream &ost) const 86 94 {} -
TabularUnified src/Actions/MethodAction.hpp ¶
r36053c raf5384 34 34 virtual bool shouldUndo(); 35 35 36 virtual Action* clone(enum QueryOptions flag = Interactive) const; 37 36 38 void outputAsCLI(std::ostream &ost) const; 37 39 void outputAsPython(std::ostream &ost, const std::string &prefix) const; -
TabularUnified src/Actions/Reaction.hpp ¶
r36053c raf5384 39 39 */ 40 40 virtual bool canUndo(); 41 virtual bool shouldUndo(); 41 42 42 virtual bool shouldUndo();43 virtual Action* clone(enum QueryOptions flag = Interactive) const=0; 43 44 44 45 virtual void outputAsCLI(std::ostream &ost) const; -
TabularUnified src/Actions/Reaction_impl_header.hpp ¶
r36053c raf5384 206 206 virtual ~REACTION(); 207 207 208 Action* clone(enum QueryOptions flag = Interactive) const; 209 208 210 void outputAsCLI(std::ostream &ost) const; 209 211 void outputAsPython(std::ostream &ost, const std::string &prefix) const; -
TabularUnified src/Actions/Reaction_impl_pre.hpp ¶
r36053c raf5384 200 200 } 201 201 202 // =========== clone Action =========== 203 Action* REACTION::clone(enum QueryOptions flag) const 204 { 205 if (flag == Interactive) 206 return new REACTION(); 207 else 208 return new REACTION(*this); 209 } 210 202 211 // =========== fill a dialog =========== 203 212 Dialog* REACTION::fillDialog(Dialog *dialog) { … … 267 276 #endif 268 277 ActionQueue::getInstance().queueAction( ToCall, Action::NonInteractive); 269 Reaction< RETURNTYPE > * resultaction = static_cast<Reaction< RETURNTYPE > *>(ToCall); 270 ASSERT( resultaction != NULL, 271 " COMMAND - static cast to Reaction type failed."); 272 ASSERT( resultaction->hasResult (), 273 " _COMMAND - result is not done yet?"); 274 return resultaction->getResult(); 278 RETURNTYPE result; 279 try { 280 const Reaction< RETURNTYPE > & resultaction = 281 static_cast<const Reaction< RETURNTYPE > &>(ActionQueue::getInstance().getLastAction()); 282 ASSERT( resultaction.hasResult (), 283 " _COMMAND - result is not done yet?"); 284 result = resultaction.getResult(); 285 } ASSERT_NOCATCH(" COMMAND - static cast to Reaction type failed."); 286 return result; 275 287 }; 276 288 … … 290 302 #endif 291 303 ActionQueue::getInstance().queueAction( ToCall, Action::NonInteractive); 292 Reaction< RETURNTYPE > * resultaction = static_cast<Reaction< RETURNTYPE > *>(ToCall); 293 ASSERT( resultaction != NULL, 294 " COMMAND - static cast to Reaction type failed."); 295 ASSERT( resultaction->hasResult (), 296 " _COMMAND - result is not done yet?"); 297 return resultaction->getResult(); 304 RETURNTYPE result; 305 try { 306 const Reaction< RETURNTYPE > & resultaction = 307 static_cast<const Reaction< RETURNTYPE > &>(ActionQueue::getInstance().getLastAction()); 308 ASSERT( resultaction.hasResult (), 309 " _COMMAND - result is not done yet?"); 310 result = resultaction.getResult(); 311 } ASSERT_NOCATCH(" COMMAND - static cast to Reaction type failed."); 312 return result; 298 313 }; 299 314 -
TabularUnified src/Actions/unittests/ActionSequenceUnitTest.cpp ¶
r36053c raf5384 85 85 return true; 86 86 } 87 Action* clone(enum QueryOptions flag = Interactive) const 88 { 89 return new canUndoActionStub(Traits); 90 } 91 void prepare(enum QueryOptions flag = Interactive) 92 {} 87 93 void outputAsCLI(std::ostream &ost) const 88 94 {} … … 118 124 return true; 119 125 } 126 Action* clone(enum QueryOptions flag = Interactive) const 127 { 128 return new cannotUndoActionStub(Traits); 129 } 130 void prepare(enum QueryOptions flag = Interactive) 131 {} 120 132 void outputAsCLI(std::ostream &ost) const 121 133 {} … … 154 166 return true; 155 167 } 168 Action* clone(enum QueryOptions flag = Interactive) const 169 { 170 return new wasCalledActionStub(Traits); 171 } 172 void prepare(enum QueryOptions flag = Interactive) 173 {} 156 174 void outputAsCLI(std::ostream &ost) const 157 175 {} -
TabularUnified src/UIElements/CommandLineUI/CommandLineWindow.cpp ¶
r36053c raf5384 69 69 70 70 // go through all possible actions 71 LOG(0, "Calling Actions ... ");72 71 for (std::list<std::string>::iterator CommandRunner = CommandLineParser::getInstance().SequenceOfActions.begin(); CommandRunner != CommandLineParser::getInstance().SequenceOfActions.end(); ++CommandRunner) { 73 72 if (AQ.isActionKnownByName(*CommandRunner)) { 74 73 // LOG1, "INFO: Checking presence of " << *CommandRunner << ": " << "queuing."); 75 LOG(1, "INFO: Queueing " << *CommandRunner << "...");76 74 AQ.queueAction(*CommandRunner); 77 75 } else { -
TabularUnified src/UIElements/Menu/TextMenu/TxMenuLeaveAction.cpp ¶
r36053c raf5384 71 71 } 72 72 73 Action* TxMenu::LeaveAction::clone(enum QueryOptions flag) const 74 { 75 if (flag == Interactive) 76 return new TxMenu::LeaveAction(menu, Traits); 77 else 78 return new TxMenu::LeaveAction(*this); 79 } 80 73 81 void TxMenu::LeaveAction::outputAsCLI(std::ostream &ost) const 74 82 {} -
TabularUnified src/UIElements/Menu/TextMenu/TxMenuLeaveAction.hpp ¶
r36053c raf5384 33 33 bool shouldUndo(); 34 34 35 Action* clone(enum QueryOptions flag = Interactive) const; 36 35 37 void outputAsCLI(std::ostream &ost) const; 36 38 void outputAsPython(std::ostream &ost, const std::string &prefix) const;
Note:
See TracChangeset
for help on using the changeset viewer.