| [bcf653] | 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/>. | 
|---|
| [bcf653] | 21 | */ | 
|---|
|  | 22 |  | 
|---|
| [b9c847] | 23 | /* | 
|---|
|  | 24 | * SetOutputFormatsAction.cpp | 
|---|
|  | 25 | * | 
|---|
|  | 26 | *  Created on: May 8, 2010 | 
|---|
|  | 27 | *      Author: heber | 
|---|
|  | 28 | */ | 
|---|
|  | 29 |  | 
|---|
| [bf3817] | 30 | // include config.h | 
|---|
|  | 31 | #ifdef HAVE_CONFIG_H | 
|---|
|  | 32 | #include <config.h> | 
|---|
|  | 33 | #endif | 
|---|
|  | 34 |  | 
|---|
| [9eb71b3] | 35 | //#include "CodePatterns/MemDebug.hpp" | 
|---|
| [b9c847] | 36 |  | 
|---|
|  | 37 | #include "Parser/ChangeTracker.hpp" | 
|---|
|  | 38 | #include "Parser/FormatParserStorage.hpp" | 
|---|
| [ad011c] | 39 | #include "CodePatterns/Log.hpp" | 
|---|
|  | 40 | #include "CodePatterns/Verbose.hpp" | 
|---|
| [b9c847] | 41 | #include "World.hpp" | 
|---|
|  | 42 |  | 
|---|
|  | 43 | #include <iostream> | 
|---|
|  | 44 | #include <string> | 
|---|
|  | 45 |  | 
|---|
| [9cff8b] | 46 | #include "SetOutputFormatsAction.hpp" | 
|---|
| [ff22c5] | 47 |  | 
|---|
| [ce7fdc] | 48 | using namespace MoleCuilder; | 
|---|
|  | 49 |  | 
|---|
| [1fd675] | 50 | // and construct the stuff | 
|---|
|  | 51 | #include "SetOutputFormatsAction.def" | 
|---|
|  | 52 | #include "Action_impl_pre.hpp" | 
|---|
|  | 53 | /** =========== define the function ====================== */ | 
|---|
| [b5b01e] | 54 | ActionState::ptr ParserSetOutputFormatsAction::performCall() { | 
|---|
| [f10b0c] | 55 | LOG(1, "Format list is: " << params.FormatList.get()); | 
|---|
|  | 56 | for (vector<std::string>::const_iterator iter = params.FormatList.get().begin(); iter != params.FormatList.get().end(); ++iter) { | 
|---|
| [5c6946] | 57 | if (!FormatParserStorage::getInstance().add(*iter)) { | 
|---|
| [26b4d62] | 58 | STATUS("Unknown parser format in ParserSetOutputFormatsAction: '"+*iter+"'"); | 
|---|
| [3e93bd4] | 59 | return Action::failure; | 
|---|
| [091838] | 60 | } else { | 
|---|
|  | 61 | FormatParserStorage::getInstance().setOutputFormat(*iter); | 
|---|
| [b9c847] | 62 | } | 
|---|
|  | 63 | } | 
|---|
| [ff22c5] | 64 | return Action::success; | 
|---|
| [b9c847] | 65 | } | 
|---|
|  | 66 |  | 
|---|
| [b5b01e] | 67 | ActionState::ptr ParserSetOutputFormatsAction::performUndo(ActionState::ptr _state) { | 
|---|
| [b9c847] | 68 | //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get()); | 
|---|
|  | 69 |  | 
|---|
| [26b4d62] | 70 | STATUS("Undo of ParserSetOutputFormatsAction not implemented."); | 
|---|
| [b9c847] | 71 | return Action::failure; | 
|---|
|  | 72 | //  string newName = state->mol->getName(); | 
|---|
|  | 73 | //  state->mol->setName(state->lastName); | 
|---|
|  | 74 | // | 
|---|
| [b5b01e] | 75 | //  return ActionState::ptr(new ParserLoadXyzState(state->mol,newName)); | 
|---|
| [b9c847] | 76 | } | 
|---|
|  | 77 |  | 
|---|
| [b5b01e] | 78 | ActionState::ptr ParserSetOutputFormatsAction::performRedo(ActionState::ptr _state){ | 
|---|
| [26b4d62] | 79 | STATUS("Redo of ParserSetOutputFormatsAction not implemented."); | 
|---|
| [b9c847] | 80 | return Action::failure; | 
|---|
|  | 81 | } | 
|---|
|  | 82 |  | 
|---|
| [9cff8b] | 83 | bool ParserSetOutputFormatsAction::canUndo() { | 
|---|
| [b9c847] | 84 | return false; | 
|---|
|  | 85 | } | 
|---|
|  | 86 |  | 
|---|
| [9cff8b] | 87 | bool ParserSetOutputFormatsAction::shouldUndo() { | 
|---|
| [b9c847] | 88 | return false; | 
|---|
|  | 89 | } | 
|---|
| [1fd675] | 90 | /** =========== end of function ====================== */ | 
|---|