source: src/Actions/ActionQueue.hpp@ d9f2b3

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 Candidate_v1.7.0 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
Last change on this file since d9f2b3 was 7fc447, checked in by Frederik Heber <heber@…>, 11 years ago

Renamed ActionsQueue's queue -> actionqueue.

  • Property mode set to 100644
File size: 4.1 KB
Line 
1/*
2 * ActionQueue.hpp
3 *
4 * Created on: Aug 16, 2013
5 * Author: heber
6 */
7
8#ifndef ACTIONQUEUE_HPP_
9#define ACTIONQUEUE_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16#include "CodePatterns/Singleton.hpp"
17
18#include <vector>
19
20#include "Actions/Action.hpp"
21#include "Actions/ActionState.hpp"
22
23namespace MoleCuilder {
24
25class ActionHistory;
26class ActionRegistry;
27class ActionTrait;
28
29/** This class combines the whole handling of Actions into a single class.
30 *
31 * It spawns new Actions by its internal ActionRegistry. Spawned Actions are
32 * automatically queued and placed into a History after execution.
33 */
34class ActionQueue : public Singleton<ActionQueue>
35{
36 friend class Singleton<ActionQueue>;
37public:
38 typedef std::vector<std::string> ActionTokens_t;
39 typedef std::vector< Action * > ActionQueue_t;
40
41 /** Queues the Action with \a name to be called.
42 *
43 * \param name token of Action to actionqueue
44 * \param state whether Actions needs to be filled via a Dialog or not
45 */
46 void queueAction(const std::string &name, enum Action::QueryOptions state = Action::Interactive);
47
48 /** Queues the Action with \a name to be called.
49 *
50 * \param _action action to add
51 * \param state whether Actions needs to be filled via a Dialog or not
52 */
53 void queueAction(Action *_action, enum Action::QueryOptions state = Action::Interactive);
54
55 /** Returns the spawned action by token \a name.
56 *
57 * Action is checked into internal actionqueue.
58 *
59 * \return pointer to newly spawned action
60 */
61 Action* getActionByName(const std::string &name);
62
63 /** Checks whether the Action is known by the given \a name.
64 *
65 * \param name token of action to check
66 * \return true - token is known, false - else
67 */
68 bool isActionKnownByName(const std::string &name) const;
69
70 /** Register an Action with the ActionRegistry.
71 *
72 * \param _action action to add
73 */
74 void registerAction(Action *_action);
75
76 /** Returns the vector with the tokens of all currently known Actions.
77 *
78 * \return list of all tokens
79 */
80 const ActionTokens_t getListOfActions() const;
81
82 /** Returns the trait to an Action.
83 *
84 * \param name name of Action
85 * \return const ref to its default Trait.
86 */
87 const ActionTrait& getActionsTrait(const std::string &name) const;
88
89 /** Print the current contents of the actionqueue as CLI instantiated list of Actions.
90 *
91 * This is useful for storing the current session.
92 *
93 * \param output output stream to print to
94 */
95 void outputAsCLI(std::ostream &output) const;
96
97 /** Print the current contents of the actionqueue as Python instantiated list of Actions.
98 *
99 * This is useful for storing the current session.
100 *
101 * \param output output stream to print to
102 */
103 void outputAsPython(std::ostream &output) const;
104
105 /** Undoes last called Acfriend void ::cleanUp();tion.
106 *
107 */
108 void undoLast();
109
110 /** Redoes last undone Action.
111 *
112 */
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 *(actionqueue.back());
124 }
125
126private:
127 //!> grant Action access to internal history functions.
128 friend class Action;
129
130 /** Wrapper function to add state to ActionHistory.
131 *
132 * \param _Action Action whose state to add
133 * \param _state state to add
134 */
135 void addElement(Action* _Action, ActionState::ptr _state);
136
137 /** Wrapper function to clear ActionHistory.
138 *
139 */
140 void clear();
141
142private:
143 /** Private cstor for ActionQueue.
144 *
145 * Must be private as is singleton.
146 *
147 */
148 ActionQueue();
149
150 /** Dstor for ActionQueue.
151 *
152 */
153 ~ActionQueue();
154
155 //!> ActionRegistry to spawn new actions
156 ActionRegistry *AR;
157
158 //!> ActionHistory is for undoing and redoing actions, requires ActionRegistry fully initialized
159 ActionHistory *history;
160
161 //!> internal actionqueue of actions
162 ActionQueue_t actionqueue;
163
164 //!> point to current action in actionqueue
165 size_t CurrentAction;
166};
167
168};
169
170#endif /* ACTIONQUEUE_HPP_ */
Note: See TracBrowser for help on using the repository browser.