| [bcf653] | 1 | /*
 | 
|---|
 | 2 |  * Project: MoleCuilder
 | 
|---|
 | 3 |  * Description: creates and alters molecular systems
 | 
|---|
| [0aa122] | 4 |  * Copyright (C)  2010-2012 University of Bonn. All rights reserved.
 | 
|---|
| [bcf653] | 5 |  * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
 | 
|---|
 | 6 |  */
 | 
|---|
 | 7 | 
 | 
|---|
| [97ebf8] | 8 | /*
 | 
|---|
 | 9 |  * FastParsingAction.cpp
 | 
|---|
 | 10 |  *
 | 
|---|
 | 11 |  *  Created on: May 9, 2010
 | 
|---|
 | 12 |  *      Author: heber
 | 
|---|
 | 13 |  */
 | 
|---|
 | 14 | 
 | 
|---|
| [bf3817] | 15 | // include config.h
 | 
|---|
 | 16 | #ifdef HAVE_CONFIG_H
 | 
|---|
 | 17 | #include <config.h>
 | 
|---|
 | 18 | #endif
 | 
|---|
 | 19 | 
 | 
|---|
| [ad011c] | 20 | #include "CodePatterns/MemDebug.hpp"
 | 
|---|
| [112b09] | 21 | 
 | 
|---|
| [97ebf8] | 22 | #include "config.hpp"
 | 
|---|
| [ad011c] | 23 | #include "CodePatterns/Log.hpp"
 | 
|---|
 | 24 | #include "CodePatterns/Verbose.hpp"
 | 
|---|
| [97ebf8] | 25 | #include "World.hpp"
 | 
|---|
 | 26 | 
 | 
|---|
 | 27 | #include <iostream>
 | 
|---|
 | 28 | #include <string>
 | 
|---|
 | 29 | 
 | 
|---|
| [1fd675] | 30 | #include "Actions/CommandAction/FastParsingAction.hpp"
 | 
|---|
| [ccf31f] | 31 | 
 | 
|---|
| [ce7fdc] | 32 | using namespace MoleCuilder;
 | 
|---|
 | 33 | 
 | 
|---|
| [1fd675] | 34 | // and construct the stuff
 | 
|---|
 | 35 | #include "FastParsingAction.def"
 | 
|---|
 | 36 | #include "Action_impl_pre.hpp"
 | 
|---|
 | 37 | /** =========== define the function ====================== */
 | 
|---|
| [53d01c] | 38 | Action::state_ptr CommandFastParsingAction::performCall() {
 | 
|---|
| [97ebf8] | 39 |   config *configuration = World::getInstance().getConfig();
 | 
|---|
| [7e37a3] | 40 |   bool oldvalue = configuration->FastParsing;
 | 
|---|
| [1fd675] | 41 | 
 | 
|---|
 | 42 |   // obtain information
 | 
|---|
 | 43 |   getParametersfromValueStorage();
 | 
|---|
 | 44 | 
 | 
|---|
 | 45 |   configuration->FastParsing = params.fastparsing;
 | 
|---|
| [ccf31f] | 46 |   if (configuration->FastParsing)
 | 
|---|
| [47d041] | 47 |     LOG(0, "I won't parse trajectories.");
 | 
|---|
| [ccf31f] | 48 |   else
 | 
|---|
| [47d041] | 49 |     LOG(0, "I will parse trajectories.");
 | 
|---|
| [1fd675] | 50 |   return Action::state_ptr(new CommandFastParsingState(oldvalue, params));
 | 
|---|
| [97ebf8] | 51 | }
 | 
|---|
 | 52 | 
 | 
|---|
| [53d01c] | 53 | Action::state_ptr CommandFastParsingAction::performUndo(Action::state_ptr _state) {
 | 
|---|
 | 54 |   CommandFastParsingState *state = assert_cast<CommandFastParsingState*>(_state.get());
 | 
|---|
| [ccf31f] | 55 | 
 | 
|---|
 | 56 |   config *configuration = World::getInstance().getConfig();
 | 
|---|
| [7e37a3] | 57 |   configuration->FastParsing = state->oldvalue;
 | 
|---|
 | 58 |   if (configuration->FastParsing)
 | 
|---|
| [47d041] | 59 |     LOG(0, "I won't parse trajectories.");
 | 
|---|
| [7e37a3] | 60 |   else
 | 
|---|
| [47d041] | 61 |     LOG(0, "I will parse trajectories.");
 | 
|---|
| [97ebf8] | 62 | 
 | 
|---|
| [7e37a3] | 63 |   return Action::state_ptr(_state);
 | 
|---|
| [97ebf8] | 64 | }
 | 
|---|
 | 65 | 
 | 
|---|
| [53d01c] | 66 | Action::state_ptr CommandFastParsingAction::performRedo(Action::state_ptr _state){
 | 
|---|
 | 67 |   CommandFastParsingState *state = assert_cast<CommandFastParsingState*>(_state.get());
 | 
|---|
| [7e37a3] | 68 | 
 | 
|---|
 | 69 |   config *configuration = World::getInstance().getConfig();
 | 
|---|
| [1fd675] | 70 |   configuration->FastParsing = state->params.fastparsing;
 | 
|---|
| [7e37a3] | 71 |   if (configuration->FastParsing)
 | 
|---|
| [47d041] | 72 |     LOG(0, "I won't parse trajectories.");
 | 
|---|
| [7e37a3] | 73 |   else
 | 
|---|
| [47d041] | 74 |     LOG(0, "I will parse trajectories.");
 | 
|---|
| [7e37a3] | 75 | 
 | 
|---|
 | 76 |   return Action::state_ptr(_state);
 | 
|---|
| [97ebf8] | 77 | }
 | 
|---|
 | 78 | 
 | 
|---|
| [53d01c] | 79 | bool CommandFastParsingAction::canUndo() {
 | 
|---|
| [ccf31f] | 80 |   return true;
 | 
|---|
| [97ebf8] | 81 | }
 | 
|---|
 | 82 | 
 | 
|---|
| [53d01c] | 83 | bool CommandFastParsingAction::shouldUndo() {
 | 
|---|
| [ccf31f] | 84 |   return true;
 | 
|---|
| [97ebf8] | 85 | }
 | 
|---|
| [1fd675] | 86 | /** =========== end of function ====================== */
 | 
|---|