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 "config.hpp"
|
---|
12 | #include "log.hpp"
|
---|
13 | #include "verbose.hpp"
|
---|
14 | #include "World.hpp"
|
---|
15 |
|
---|
16 | #include <iostream>
|
---|
17 | #include <string>
|
---|
18 |
|
---|
19 | using namespace std;
|
---|
20 |
|
---|
21 | #include "UIElements/UIFactory.hpp"
|
---|
22 | #include "UIElements/Dialog.hpp"
|
---|
23 | #include "UIElements/ValueStorage.hpp"
|
---|
24 |
|
---|
25 | // memento to remember the state when undoing
|
---|
26 |
|
---|
27 | class CommandLineFastParsingState : public ActionState {
|
---|
28 | public:
|
---|
29 | CommandLineFastParsingState(bool _bool) :
|
---|
30 | boolean(_bool)
|
---|
31 | {}
|
---|
32 | bool boolean;
|
---|
33 | };
|
---|
34 |
|
---|
35 |
|
---|
36 | const char CommandLineFastParsingAction::NAME[] = "fastparsing";
|
---|
37 |
|
---|
38 | CommandLineFastParsingAction::CommandLineFastParsingAction() :
|
---|
39 | Action(NAME)
|
---|
40 | {}
|
---|
41 |
|
---|
42 | CommandLineFastParsingAction::~CommandLineFastParsingAction()
|
---|
43 | {}
|
---|
44 |
|
---|
45 | Dialog* CommandLineFastParsingAction::createDialog() {
|
---|
46 | Dialog *dialog = UIFactory::getInstance().makeDialog();
|
---|
47 |
|
---|
48 | dialog->queryBoolean(NAME, MapOfActions::getInstance().getDescription(NAME));
|
---|
49 |
|
---|
50 | return dialog;
|
---|
51 | }
|
---|
52 |
|
---|
53 | Action::state_ptr CommandLineFastParsingAction::performCall() {
|
---|
54 |
|
---|
55 | config *configuration = World::getInstance().getConfig();
|
---|
56 | ValueStorage::getInstance().queryCurrentValue(NAME, configuration->FastParsing);
|
---|
57 | if (configuration->FastParsing)
|
---|
58 | DoLog(0) && (Log() << Verbose(0) << "I won't parse trajectories." << endl);
|
---|
59 | else
|
---|
60 | DoLog(0) && (Log() << Verbose(0) << "I will parse trajectories." << endl);
|
---|
61 | return Action::success;
|
---|
62 | }
|
---|
63 |
|
---|
64 | Action::state_ptr CommandLineFastParsingAction::performUndo(Action::state_ptr _state) {
|
---|
65 | CommandLineFastParsingState *state = assert_cast<CommandLineFastParsingState*>(_state.get());
|
---|
66 |
|
---|
67 | config *configuration = World::getInstance().getConfig();
|
---|
68 | configuration->FastParsing = state->boolean;
|
---|
69 |
|
---|
70 | return Action::state_ptr(new CommandLineFastParsingState(!state->boolean));
|
---|
71 | }
|
---|
72 |
|
---|
73 | Action::state_ptr CommandLineFastParsingAction::performRedo(Action::state_ptr _state){
|
---|
74 | performUndo(_state);
|
---|
75 | }
|
---|
76 |
|
---|
77 | bool CommandLineFastParsingAction::canUndo() {
|
---|
78 | return true;
|
---|
79 | }
|
---|
80 |
|
---|
81 | bool CommandLineFastParsingAction::shouldUndo() {
|
---|
82 | return true;
|
---|
83 | }
|
---|
84 |
|
---|
85 | const string CommandLineFastParsingAction::getName() {
|
---|
86 | return NAME;
|
---|
87 | }
|
---|