[628577] | 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 |
|
---|
[1d3563] | 18 | #include <list>
|
---|
[690741] | 19 | #include <vector>
|
---|
[1d3563] | 20 |
|
---|
[b5b01e] | 21 | #include "Actions/ActionState.hpp"
|
---|
[628577] | 22 |
|
---|
| 23 | namespace MoleCuilder {
|
---|
| 24 |
|
---|
| 25 | class Action;
|
---|
[ed3944] | 26 | class ActionRegistry;
|
---|
| 27 | class ActionTrait;
|
---|
[628577] | 28 |
|
---|
| 29 | /** This class combines the whole handling of Actions into a single class.
|
---|
| 30 | *
|
---|
[1d3563] | 31 | * It spawns new Actions by its internal ActionRegistry. Spawned Actions are
|
---|
| 32 | * automatically queued and placed into a History after execution.
|
---|
[628577] | 33 | */
|
---|
| 34 | class ActionQueue : public Singleton<ActionQueue>
|
---|
| 35 | {
|
---|
| 36 | friend class Singleton<ActionQueue>;
|
---|
| 37 | public:
|
---|
[690741] | 38 | typedef std::vector<std::string> ActionTokens_t;
|
---|
[1d3563] | 39 | typedef std::list<Action *> ActionQueue_t;
|
---|
| 40 |
|
---|
| 41 | /** Returns the spawned action by token \a name.
|
---|
| 42 | *
|
---|
| 43 | * Action is checked into internal queue.
|
---|
| 44 | *
|
---|
| 45 | * \return pointer to newly spawned action
|
---|
| 46 | */
|
---|
[a6ceab] | 47 | Action* getActionByName(const std::string &name);
|
---|
[1d3563] | 48 |
|
---|
| 49 | /** Checks whether the Action is known by the given \a name.
|
---|
| 50 | *
|
---|
| 51 | * \param name token of action to check
|
---|
| 52 | * \return true - token is known, false - else
|
---|
| 53 | */
|
---|
[a6ceab] | 54 | bool isActionKnownByName(const std::string &name) const;
|
---|
[1d3563] | 55 |
|
---|
| 56 | /** Returns the last taken position for the Menu with \a MenuName.
|
---|
| 57 | *
|
---|
| 58 | * \param MenuName name of menu to check for last position
|
---|
| 59 | * \return index of last position
|
---|
| 60 | */
|
---|
| 61 | int getLastPosition(const std::string &MenuName) const;
|
---|
| 62 |
|
---|
[690741] | 63 | /** Returns the vector with the tokens of all currently known Actions.
|
---|
| 64 | *
|
---|
| 65 | * \return list of all tokens
|
---|
| 66 | */
|
---|
| 67 | const ActionTokens_t getListOfActions() const;
|
---|
| 68 |
|
---|
| 69 | /** Returns the trait to an Action.
|
---|
| 70 | *
|
---|
| 71 | * \param name name of Action
|
---|
| 72 | * \return const ref to its default Trait.
|
---|
| 73 | */
|
---|
[a6ceab] | 74 | const ActionTrait& getActionsTrait(const std::string &name) const;
|
---|
[690741] | 75 |
|
---|
[628577] | 76 | /** Getter function for the ActionRegistry for transitional purpose.
|
---|
| 77 | *
|
---|
| 78 | * \return ref to internal ActionRegistry
|
---|
| 79 | */
|
---|
| 80 | ActionRegistry& getActionRegistry() {
|
---|
[ed3944] | 81 | return *AR;
|
---|
[628577] | 82 | }
|
---|
| 83 |
|
---|
| 84 | private:
|
---|
[1d3563] | 85 | /** Private cstor for ActionQueue.
|
---|
| 86 | *
|
---|
| 87 | * Must be private as is singleton.
|
---|
| 88 | *
|
---|
| 89 | */
|
---|
[628577] | 90 | ActionQueue();
|
---|
[1d3563] | 91 |
|
---|
| 92 | /** Dstor for ActionQueue.
|
---|
| 93 | *
|
---|
| 94 | */
|
---|
[628577] | 95 | ~ActionQueue();
|
---|
| 96 |
|
---|
| 97 | //!> ActionRegistry to spawn new actions
|
---|
[ed3944] | 98 | ActionRegistry *AR;
|
---|
[1d3563] | 99 |
|
---|
| 100 | //!> internal queue of actions
|
---|
| 101 | ActionQueue_t queue;
|
---|
[628577] | 102 | };
|
---|
| 103 |
|
---|
| 104 | };
|
---|
| 105 |
|
---|
| 106 | #endif /* ACTIONQUEUE_HPP_ */
|
---|