| [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" | 
|---|
|  | 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" | 
|---|
| [ccf31f] | 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 |  | 
|---|
| [97ebf8] | 35 |  | 
|---|
|  | 36 | const char CommandLineFastParsingAction::NAME[] = "fastparsing"; | 
|---|
|  | 37 |  | 
|---|
|  | 38 | CommandLineFastParsingAction::CommandLineFastParsingAction() : | 
|---|
|  | 39 | Action(NAME) | 
|---|
|  | 40 | {} | 
|---|
|  | 41 |  | 
|---|
|  | 42 | CommandLineFastParsingAction::~CommandLineFastParsingAction() | 
|---|
|  | 43 | {} | 
|---|
|  | 44 |  | 
|---|
| [ccf31f] | 45 | Dialog* CommandLineFastParsingAction::createDialog() { | 
|---|
| [97ebf8] | 46 | Dialog *dialog = UIFactory::getInstance().makeDialog(); | 
|---|
|  | 47 |  | 
|---|
| [ccf31f] | 48 | dialog->queryBoolean(NAME, MapOfActions::getInstance().getDescription(NAME)); | 
|---|
|  | 49 |  | 
|---|
|  | 50 | return dialog; | 
|---|
|  | 51 | } | 
|---|
|  | 52 |  | 
|---|
|  | 53 | Action::state_ptr CommandLineFastParsingAction::performCall() { | 
|---|
|  | 54 |  | 
|---|
| [97ebf8] | 55 | config *configuration = World::getInstance().getConfig(); | 
|---|
| [ccf31f] | 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; | 
|---|
| [97ebf8] | 62 | } | 
|---|
|  | 63 |  | 
|---|
|  | 64 | Action::state_ptr CommandLineFastParsingAction::performUndo(Action::state_ptr _state) { | 
|---|
| [ccf31f] | 65 | CommandLineFastParsingState *state = assert_cast<CommandLineFastParsingState*>(_state.get()); | 
|---|
|  | 66 |  | 
|---|
|  | 67 | config *configuration = World::getInstance().getConfig(); | 
|---|
|  | 68 | configuration->FastParsing = state->boolean; | 
|---|
| [97ebf8] | 69 |  | 
|---|
| [ccf31f] | 70 | return Action::state_ptr(new CommandLineFastParsingState(!state->boolean)); | 
|---|
| [97ebf8] | 71 | } | 
|---|
|  | 72 |  | 
|---|
|  | 73 | Action::state_ptr CommandLineFastParsingAction::performRedo(Action::state_ptr _state){ | 
|---|
| [ccf31f] | 74 | performUndo(_state); | 
|---|
| [97ebf8] | 75 | } | 
|---|
|  | 76 |  | 
|---|
|  | 77 | bool CommandLineFastParsingAction::canUndo() { | 
|---|
| [ccf31f] | 78 | return true; | 
|---|
| [97ebf8] | 79 | } | 
|---|
|  | 80 |  | 
|---|
|  | 81 | bool CommandLineFastParsingAction::shouldUndo() { | 
|---|
| [ccf31f] | 82 | return true; | 
|---|
| [97ebf8] | 83 | } | 
|---|
|  | 84 |  | 
|---|
|  | 85 | const string CommandLineFastParsingAction::getName() { | 
|---|
|  | 86 | return NAME; | 
|---|
|  | 87 | } | 
|---|