| [81c980b] | 1 | /*
|
|---|
| 2 | * Project: MoleCuilder
|
|---|
| 3 | * Description: creates and alters molecular systems
|
|---|
| [0aa122] | 4 | * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
|
|---|
| [81c980b] | 5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | /*
|
|---|
| 9 | * SetTremoloAtomdataAction.cpp
|
|---|
| 10 | *
|
|---|
| 11 | * Created on: Aug 9, 2011
|
|---|
| 12 | * Author: heber
|
|---|
| 13 | */
|
|---|
| 14 |
|
|---|
| 15 | // include config.h
|
|---|
| 16 | #ifdef HAVE_CONFIG_H
|
|---|
| 17 | #include <config.h>
|
|---|
| 18 | #endif
|
|---|
| 19 |
|
|---|
| 20 | #include "CodePatterns/MemDebug.hpp"
|
|---|
| 21 |
|
|---|
| 22 | #include "Parser/TremoloParser.hpp"
|
|---|
| 23 | #include "Parser/FormatParserStorage.hpp"
|
|---|
| 24 | #include "CodePatterns/Log.hpp"
|
|---|
| 25 | #include "CodePatterns/Verbose.hpp"
|
|---|
| 26 |
|
|---|
| 27 | #include <iostream>
|
|---|
| 28 | #include <string>
|
|---|
| 29 |
|
|---|
| 30 | #include <boost/filesystem/fstream.hpp>
|
|---|
| 31 |
|
|---|
| 32 | #include "SetTremoloAtomdataAction.hpp"
|
|---|
| 33 |
|
|---|
| [ce7fdc] | 34 | using namespace MoleCuilder;
|
|---|
| 35 |
|
|---|
| [81c980b] | 36 | // and construct the stuff
|
|---|
| 37 | #include "SetTremoloAtomdataAction.def"
|
|---|
| 38 | #include "Action_impl_pre.hpp"
|
|---|
| 39 | /** =========== define the function ====================== */
|
|---|
| 40 | Action::state_ptr ParserSetTremoloAtomdataAction::performCall() {
|
|---|
| [765f16] | 41 | FormatParser<tremolo> &parser = FormatParserStorage::getInstance().getParser<tremolo>();
|
|---|
| [81c980b] | 42 |
|
|---|
| [f10b0c] | 43 | LOG(1, "Setting Tremolo's ATOMDATA to: '" << params.atomdata_string.get() << "'");
|
|---|
| [81c980b] | 44 |
|
|---|
| [ca331c] | 45 | const std::string old_atomdata = parser.getAtomData();
|
|---|
| [81c980b] | 46 |
|
|---|
| [ca331c] | 47 | if (params.atomdata_reset.get())
|
|---|
| 48 | parser.resetAtomData(params.atomdata_string.get());
|
|---|
| 49 | else
|
|---|
| 50 | parser.setAtomData(params.atomdata_string.get());
|
|---|
| 51 |
|
|---|
| 52 | return Action::state_ptr(new ParserSetTremoloAtomdataState(old_atomdata, params));
|
|---|
| [81c980b] | 53 | }
|
|---|
| 54 |
|
|---|
| 55 | Action::state_ptr ParserSetTremoloAtomdataAction::performUndo(Action::state_ptr _state) {
|
|---|
| [ca331c] | 56 | ParserSetTremoloAtomdataState *state = assert_cast<ParserSetTremoloAtomdataState*>(_state.get());
|
|---|
| 57 |
|
|---|
| 58 | FormatParser<tremolo> &parser = FormatParserStorage::getInstance().getParser<tremolo>();
|
|---|
| 59 | LOG(1, "INFO: Reverting to 'ATOMDATA " << state->old_atomdata << "'.");
|
|---|
| 60 | parser.resetAtomData(state->old_atomdata);
|
|---|
| [81c980b] | 61 |
|
|---|
| [ca331c] | 62 | return Action::state_ptr(_state);
|
|---|
| [81c980b] | 63 | }
|
|---|
| 64 |
|
|---|
| 65 | Action::state_ptr ParserSetTremoloAtomdataAction::performRedo(Action::state_ptr _state){
|
|---|
| [ca331c] | 66 | ParserSetTremoloAtomdataState *state = assert_cast<ParserSetTremoloAtomdataState*>(_state.get());
|
|---|
| 67 |
|
|---|
| 68 | FormatParser<tremolo> &parser = FormatParserStorage::getInstance().getParser<tremolo>();
|
|---|
| 69 |
|
|---|
| 70 | if (state->params.atomdata_reset.get())
|
|---|
| 71 | parser.resetAtomData(state->params.atomdata_string.get());
|
|---|
| 72 | else
|
|---|
| 73 | parser.setAtomData(state->params.atomdata_string.get());
|
|---|
| 74 |
|
|---|
| 75 | return Action::state_ptr(_state);
|
|---|
| [81c980b] | 76 | }
|
|---|
| 77 |
|
|---|
| 78 | bool ParserSetTremoloAtomdataAction::canUndo() {
|
|---|
| [ca331c] | 79 | return true;
|
|---|
| [81c980b] | 80 | }
|
|---|
| 81 |
|
|---|
| 82 | bool ParserSetTremoloAtomdataAction::shouldUndo() {
|
|---|
| [ca331c] | 83 | return true;
|
|---|
| [81c980b] | 84 | }
|
|---|
| 85 | /** =========== end of function ====================== */
|
|---|