| [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 |  | 
|---|
| [ad011c] | 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 ====================== */ | 
|---|
| [9cff8b] | 54 | Action::state_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)) { | 
|---|
| [47d041] | 58 | ELOG(1, "Unknown parser format in ParserSetOutputFormatsAction: '" << *iter << "'"); | 
|---|
| [091838] | 59 | } else { | 
|---|
|  | 60 | FormatParserStorage::getInstance().setOutputFormat(*iter); | 
|---|
| [b9c847] | 61 | } | 
|---|
|  | 62 | } | 
|---|
| [ff22c5] | 63 | return Action::success; | 
|---|
| [b9c847] | 64 | } | 
|---|
|  | 65 |  | 
|---|
| [9cff8b] | 66 | Action::state_ptr ParserSetOutputFormatsAction::performUndo(Action::state_ptr _state) { | 
|---|
| [b9c847] | 67 | //  ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get()); | 
|---|
|  | 68 |  | 
|---|
|  | 69 | return Action::failure; | 
|---|
|  | 70 | //  string newName = state->mol->getName(); | 
|---|
|  | 71 | //  state->mol->setName(state->lastName); | 
|---|
|  | 72 | // | 
|---|
|  | 73 | //  return Action::state_ptr(new ParserLoadXyzState(state->mol,newName)); | 
|---|
|  | 74 | } | 
|---|
|  | 75 |  | 
|---|
| [9cff8b] | 76 | Action::state_ptr ParserSetOutputFormatsAction::performRedo(Action::state_ptr _state){ | 
|---|
| [b9c847] | 77 | return Action::failure; | 
|---|
|  | 78 | } | 
|---|
|  | 79 |  | 
|---|
| [9cff8b] | 80 | bool ParserSetOutputFormatsAction::canUndo() { | 
|---|
| [b9c847] | 81 | return false; | 
|---|
|  | 82 | } | 
|---|
|  | 83 |  | 
|---|
| [9cff8b] | 84 | bool ParserSetOutputFormatsAction::shouldUndo() { | 
|---|
| [b9c847] | 85 | return false; | 
|---|
|  | 86 | } | 
|---|
| [1fd675] | 87 | /** =========== end of function ====================== */ | 
|---|