[97ebf8] | 1 | /*
|
---|
| 2 | * FastParsingAction.cpp
|
---|
| 3 | *
|
---|
| 4 | * Created on: May 9, 2010
|
---|
| 5 | * Author: heber
|
---|
| 6 | */
|
---|
| 7 |
|
---|
[112b09] | 8 | #include "Helpers/MemDebug.hpp"
|
---|
| 9 |
|
---|
[97ebf8] | 10 | #include "Actions/CmdAction/FastParsingAction.hpp"
|
---|
[ecbc9a] | 11 | #include "Actions/ActionCalls.hpp"
|
---|
[97ebf8] | 12 | #include "config.hpp"
|
---|
| 13 | #include "log.hpp"
|
---|
| 14 | #include "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"
|
---|
[ccf31f] | 24 | #include "UIElements/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 |
|
---|
[97ebf8] | 36 |
|
---|
| 37 | const char CommandLineFastParsingAction::NAME[] = "fastparsing";
|
---|
| 38 |
|
---|
| 39 | CommandLineFastParsingAction::CommandLineFastParsingAction() :
|
---|
| 40 | Action(NAME)
|
---|
| 41 | {}
|
---|
| 42 |
|
---|
| 43 | CommandLineFastParsingAction::~CommandLineFastParsingAction()
|
---|
| 44 | {}
|
---|
| 45 |
|
---|
[ecbc9a] | 46 | void CommandFastParsing(bool fastparsing) {
|
---|
| 47 | ValueStorage::getInstance().setCurrentValue(CommandLineFastParsingAction::NAME, fastparsing);
|
---|
| 48 | ActionRegistry::getInstance().getActionByName(CommandLineFastParsingAction::NAME)->call(Action::NonInteractive);
|
---|
| 49 | };
|
---|
| 50 |
|
---|
[ccf31f] | 51 | Dialog* CommandLineFastParsingAction::createDialog() {
|
---|
[97ebf8] | 52 | Dialog *dialog = UIFactory::getInstance().makeDialog();
|
---|
| 53 |
|
---|
[ccf31f] | 54 | dialog->queryBoolean(NAME, MapOfActions::getInstance().getDescription(NAME));
|
---|
| 55 |
|
---|
| 56 | return dialog;
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | Action::state_ptr CommandLineFastParsingAction::performCall() {
|
---|
| 60 |
|
---|
[97ebf8] | 61 | config *configuration = World::getInstance().getConfig();
|
---|
[ccf31f] | 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;
|
---|
[97ebf8] | 68 | }
|
---|
| 69 |
|
---|
| 70 | Action::state_ptr CommandLineFastParsingAction::performUndo(Action::state_ptr _state) {
|
---|
[ccf31f] | 71 | CommandLineFastParsingState *state = assert_cast<CommandLineFastParsingState*>(_state.get());
|
---|
| 72 |
|
---|
| 73 | config *configuration = World::getInstance().getConfig();
|
---|
| 74 | configuration->FastParsing = state->boolean;
|
---|
[97ebf8] | 75 |
|
---|
[ccf31f] | 76 | return Action::state_ptr(new CommandLineFastParsingState(!state->boolean));
|
---|
[97ebf8] | 77 | }
|
---|
| 78 |
|
---|
| 79 | Action::state_ptr CommandLineFastParsingAction::performRedo(Action::state_ptr _state){
|
---|
[ccf31f] | 80 | performUndo(_state);
|
---|
[97ebf8] | 81 | }
|
---|
| 82 |
|
---|
| 83 | bool CommandLineFastParsingAction::canUndo() {
|
---|
[ccf31f] | 84 | return true;
|
---|
[97ebf8] | 85 | }
|
---|
| 86 |
|
---|
| 87 | bool CommandLineFastParsingAction::shouldUndo() {
|
---|
[ccf31f] | 88 | return true;
|
---|
[97ebf8] | 89 | }
|
---|
| 90 |
|
---|
| 91 | const string CommandLineFastParsingAction::getName() {
|
---|
| 92 | return NAME;
|
---|
| 93 | }
|
---|