source: src/Actions/ActionQueue.hpp@ 9e4655

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
Last change on this file since 9e4655 was 477012, checked in by Frederik Heber <heber@…>, 11 years ago

Added Action::outputAsPython() and ActionQueue::outputAsPython().

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