1 | /*
|
---|
2 | * FastParsingAction.cpp
|
---|
3 | *
|
---|
4 | * Created on: May 9, 2010
|
---|
5 | * Author: heber
|
---|
6 | */
|
---|
7 |
|
---|
8 | #include "Helpers/MemDebug.hpp"
|
---|
9 |
|
---|
10 | #include "Actions/CmdAction/FastParsingAction.hpp"
|
---|
11 | #include "Actions/ActionRegistry.hpp"
|
---|
12 | #include "config.hpp"
|
---|
13 | #include "Helpers/Log.hpp"
|
---|
14 | #include "Helpers/Verbose.hpp"
|
---|
15 | #include "World.hpp"
|
---|
16 |
|
---|
17 | #include <iostream>
|
---|
18 | #include <string>
|
---|
19 |
|
---|
20 | using namespace std;
|
---|
21 |
|
---|
22 | #include "UIElements/UIFactory.hpp"
|
---|
23 | #include "UIElements/Dialog.hpp"
|
---|
24 | #include "Actions/ValueStorage.hpp"
|
---|
25 |
|
---|
26 | // memento to remember the state when undoing
|
---|
27 |
|
---|
28 | class CommandLineFastParsingState : public ActionState {
|
---|
29 | public:
|
---|
30 | CommandLineFastParsingState(bool _bool) :
|
---|
31 | boolean(_bool)
|
---|
32 | {}
|
---|
33 | bool boolean;
|
---|
34 | };
|
---|
35 |
|
---|
36 |
|
---|
37 | const char CommandLineFastParsingAction::NAME[] = "fastparsing";
|
---|
38 |
|
---|
39 | CommandLineFastParsingAction::CommandLineFastParsingAction() :
|
---|
40 | Action(NAME)
|
---|
41 | {}
|
---|
42 |
|
---|
43 | CommandLineFastParsingAction::~CommandLineFastParsingAction()
|
---|
44 | {}
|
---|
45 |
|
---|
46 | void CommandFastParsing(bool fastparsing) {
|
---|
47 | ValueStorage::getInstance().setCurrentValue(CommandLineFastParsingAction::NAME, fastparsing);
|
---|
48 | ActionRegistry::getInstance().getActionByName(CommandLineFastParsingAction::NAME)->call(Action::NonInteractive);
|
---|
49 | };
|
---|
50 |
|
---|
51 | Dialog* CommandLineFastParsingAction::fillDialog(Dialog *dialog) {
|
---|
52 | ASSERT(dialog,"No Dialog given when filling action dialog");
|
---|
53 |
|
---|
54 | dialog->queryBoolean(NAME, MapOfActions::getInstance().getDescription(NAME));
|
---|
55 |
|
---|
56 | return dialog;
|
---|
57 | }
|
---|
58 |
|
---|
59 | Action::state_ptr CommandLineFastParsingAction::performCall() {
|
---|
60 |
|
---|
61 | config *configuration = World::getInstance().getConfig();
|
---|
62 | ValueStorage::getInstance().queryCurrentValue(NAME, configuration->FastParsing);
|
---|
63 | if (configuration->FastParsing)
|
---|
64 | DoLog(0) && (Log() << Verbose(0) << "I won't parse trajectories." << endl);
|
---|
65 | else
|
---|
66 | DoLog(0) && (Log() << Verbose(0) << "I will parse trajectories." << endl);
|
---|
67 | return Action::success;
|
---|
68 | }
|
---|
69 |
|
---|
70 | Action::state_ptr CommandLineFastParsingAction::performUndo(Action::state_ptr _state) {
|
---|
71 | CommandLineFastParsingState *state = assert_cast<CommandLineFastParsingState*>(_state.get());
|
---|
72 |
|
---|
73 | config *configuration = World::getInstance().getConfig();
|
---|
74 | configuration->FastParsing = state->boolean;
|
---|
75 |
|
---|
76 | return Action::state_ptr(new CommandLineFastParsingState(!state->boolean));
|
---|
77 | }
|
---|
78 |
|
---|
79 | Action::state_ptr CommandLineFastParsingAction::performRedo(Action::state_ptr _state){
|
---|
80 | return performUndo(_state);
|
---|
81 | }
|
---|
82 |
|
---|
83 | bool CommandLineFastParsingAction::canUndo() {
|
---|
84 | return true;
|
---|
85 | }
|
---|
86 |
|
---|
87 | bool CommandLineFastParsingAction::shouldUndo() {
|
---|
88 | return true;
|
---|
89 | }
|
---|
90 |
|
---|
91 | const string CommandLineFastParsingAction::getName() {
|
---|
92 | return NAME;
|
---|
93 | }
|
---|