| [5bcbc7] | 1 | /*
|
|---|
| 2 | * Project: MoleCuilder
|
|---|
| 3 | * Description: creates and alters molecular systems
|
|---|
| 4 | * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
|
|---|
| 5 | * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | /*
|
|---|
| 9 | * OutputAsAction.cpp
|
|---|
| 10 | *
|
|---|
| 11 | * Created on: Aug 7, 2012
|
|---|
| 12 | * Author: ankele
|
|---|
| 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/FormatParserStorage.hpp"
|
|---|
| 23 | #include "Parser/ChangeTracker.hpp"
|
|---|
| 24 | #include "CodePatterns/Log.hpp"
|
|---|
| 25 | #include "CodePatterns/Verbose.hpp"
|
|---|
| 26 | #include "World.hpp"
|
|---|
| 27 |
|
|---|
| 28 | #include <iostream>
|
|---|
| 29 | #include <string>
|
|---|
| 30 |
|
|---|
| 31 | #include <boost/filesystem/fstream.hpp>
|
|---|
| 32 |
|
|---|
| 33 | #include "Actions/WorldAction/OutputAction.hpp"
|
|---|
| 34 |
|
|---|
| 35 | using namespace MoleCuilder;
|
|---|
| 36 |
|
|---|
| 37 | // and construct the stuff
|
|---|
| 38 | #include "OutputAction.def"
|
|---|
| 39 | #include "Action_impl_pre.hpp"
|
|---|
| 40 | /** =========== define the function ====================== */
|
|---|
| 41 | Action::state_ptr WorldOutputAction::performCall() {
|
|---|
| 42 | LOG(1, "Storing world to input file.");
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 | // Parser configured to save anything?
|
|---|
| 46 | if (!FormatParserStorage::getInstance().isAbleToSave()){
|
|---|
| 47 | ELOG(1, "No parser or file prefix selected.");
|
|---|
| 48 | return Action::failure;
|
|---|
| 49 | }
|
|---|
| 50 |
|
|---|
| 51 | // Save all.
|
|---|
| 52 | FormatParserStorage::getInstance().SaveAll();
|
|---|
| 53 | ChangeTracker::getInstance().saveStatus();
|
|---|
| 54 | return Action::success;
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| 57 | Action::state_ptr WorldOutputAction::performUndo(Action::state_ptr _state) {
|
|---|
| 58 | // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());
|
|---|
| 59 |
|
|---|
| 60 | return Action::failure;
|
|---|
| 61 | // string newName = state->mol->getName();
|
|---|
| 62 | // state->mol->setName(state->lastName);
|
|---|
| 63 | //
|
|---|
| 64 | // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 | Action::state_ptr WorldOutputAction::performRedo(Action::state_ptr _state){
|
|---|
| 68 | return Action::failure;
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 | bool WorldOutputAction::canUndo() {
|
|---|
| 72 | return false;
|
|---|
| 73 | }
|
|---|
| 74 |
|
|---|
| 75 | bool WorldOutputAction::shouldUndo() {
|
|---|
| 76 | return false;
|
|---|
| 77 | }
|
|---|
| 78 | /** =========== end of function ====================== */
|
|---|