[81c980b] | 1 | /*
|
---|
| 2 | * Project: MoleCuilder
|
---|
| 3 | * Description: creates and alters molecular systems
|
---|
[0aa122] | 4 | * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
|
---|
[94d5ac6] | 5 | *
|
---|
| 6 | *
|
---|
| 7 | * This file is part of MoleCuilder.
|
---|
| 8 | *
|
---|
| 9 | * MoleCuilder is free software: you can redistribute it and/or modify
|
---|
| 10 | * it under the terms of the GNU General Public License as published by
|
---|
| 11 | * the Free Software Foundation, either version 2 of the License, or
|
---|
| 12 | * (at your option) any later version.
|
---|
| 13 | *
|
---|
| 14 | * MoleCuilder is distributed in the hope that it will be useful,
|
---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 17 | * GNU General Public License for more details.
|
---|
| 18 | *
|
---|
| 19 | * You should have received a copy of the GNU General Public License
|
---|
| 20 | * along with MoleCuilder. If not, see <http://www.gnu.org/licenses/>.
|
---|
[81c980b] | 21 | */
|
---|
| 22 |
|
---|
| 23 | /*
|
---|
| 24 | * SetTremoloAtomdataAction.cpp
|
---|
| 25 | *
|
---|
| 26 | * Created on: Aug 9, 2011
|
---|
| 27 | * Author: heber
|
---|
| 28 | */
|
---|
| 29 |
|
---|
| 30 | // include config.h
|
---|
| 31 | #ifdef HAVE_CONFIG_H
|
---|
| 32 | #include <config.h>
|
---|
| 33 | #endif
|
---|
| 34 |
|
---|
| 35 | #include "CodePatterns/MemDebug.hpp"
|
---|
| 36 |
|
---|
| 37 | #include "Parser/TremoloParser.hpp"
|
---|
| 38 | #include "Parser/FormatParserStorage.hpp"
|
---|
| 39 | #include "CodePatterns/Log.hpp"
|
---|
| 40 | #include "CodePatterns/Verbose.hpp"
|
---|
| 41 |
|
---|
| 42 | #include <iostream>
|
---|
| 43 | #include <string>
|
---|
| 44 |
|
---|
| 45 | #include <boost/filesystem/fstream.hpp>
|
---|
| 46 |
|
---|
| 47 | #include "SetTremoloAtomdataAction.hpp"
|
---|
| 48 |
|
---|
[ce7fdc] | 49 | using namespace MoleCuilder;
|
---|
| 50 |
|
---|
[81c980b] | 51 | // and construct the stuff
|
---|
| 52 | #include "SetTremoloAtomdataAction.def"
|
---|
| 53 | #include "Action_impl_pre.hpp"
|
---|
| 54 | /** =========== define the function ====================== */
|
---|
| 55 | Action::state_ptr ParserSetTremoloAtomdataAction::performCall() {
|
---|
[765f16] | 56 | FormatParser<tremolo> &parser = FormatParserStorage::getInstance().getParser<tremolo>();
|
---|
[81c980b] | 57 |
|
---|
[f10b0c] | 58 | LOG(1, "Setting Tremolo's ATOMDATA to: '" << params.atomdata_string.get() << "'");
|
---|
[81c980b] | 59 |
|
---|
[ca331c] | 60 | const std::string old_atomdata = parser.getAtomData();
|
---|
[81c980b] | 61 |
|
---|
[ca331c] | 62 | if (params.atomdata_reset.get())
|
---|
| 63 | parser.resetAtomData(params.atomdata_string.get());
|
---|
| 64 | else
|
---|
| 65 | parser.setAtomData(params.atomdata_string.get());
|
---|
| 66 |
|
---|
| 67 | return Action::state_ptr(new ParserSetTremoloAtomdataState(old_atomdata, params));
|
---|
[81c980b] | 68 | }
|
---|
| 69 |
|
---|
| 70 | Action::state_ptr ParserSetTremoloAtomdataAction::performUndo(Action::state_ptr _state) {
|
---|
[ca331c] | 71 | ParserSetTremoloAtomdataState *state = assert_cast<ParserSetTremoloAtomdataState*>(_state.get());
|
---|
| 72 |
|
---|
| 73 | FormatParser<tremolo> &parser = FormatParserStorage::getInstance().getParser<tremolo>();
|
---|
| 74 | LOG(1, "INFO: Reverting to 'ATOMDATA " << state->old_atomdata << "'.");
|
---|
| 75 | parser.resetAtomData(state->old_atomdata);
|
---|
[81c980b] | 76 |
|
---|
[ca331c] | 77 | return Action::state_ptr(_state);
|
---|
[81c980b] | 78 | }
|
---|
| 79 |
|
---|
| 80 | Action::state_ptr ParserSetTremoloAtomdataAction::performRedo(Action::state_ptr _state){
|
---|
[ca331c] | 81 | ParserSetTremoloAtomdataState *state = assert_cast<ParserSetTremoloAtomdataState*>(_state.get());
|
---|
| 82 |
|
---|
| 83 | FormatParser<tremolo> &parser = FormatParserStorage::getInstance().getParser<tremolo>();
|
---|
| 84 |
|
---|
| 85 | if (state->params.atomdata_reset.get())
|
---|
| 86 | parser.resetAtomData(state->params.atomdata_string.get());
|
---|
| 87 | else
|
---|
| 88 | parser.setAtomData(state->params.atomdata_string.get());
|
---|
| 89 |
|
---|
| 90 | return Action::state_ptr(_state);
|
---|
[81c980b] | 91 | }
|
---|
| 92 |
|
---|
| 93 | bool ParserSetTremoloAtomdataAction::canUndo() {
|
---|
[ca331c] | 94 | return true;
|
---|
[81c980b] | 95 | }
|
---|
| 96 |
|
---|
| 97 | bool ParserSetTremoloAtomdataAction::shouldUndo() {
|
---|
[ca331c] | 98 | return true;
|
---|
[81c980b] | 99 | }
|
---|
| 100 | /** =========== end of function ====================== */
|
---|