source: src/Actions/MoleculeAction/SaveEnergiesAction.cpp@ 91c409

Candidate_v1.7.0 stable
Last change on this file since 91c409 was 61cc0f, checked in by Frederik Heber <frederik.heber@…>, 5 years ago

Enhanced verbosity of FragmentationAutomation.

  • Property mode set to 100644
File size: 2.9 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2010-2012 University of Bonn. All rights reserved.
5 * Copyright (C) 2019 Frederik Heber
6 *
7 *
8 * This file is part of MoleCuilder.
9 *
10 * MoleCuilder is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * MoleCuilder is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with MoleCuilder. If not, see <http://www.gnu.org/licenses/>.
22 */
23
24/*
25 * SaveEnergiesAction.cpp
26 *
27 * Created on: May 10, 2010
28 * Author: heber
29 */
30
31// include config.h
32#ifdef HAVE_CONFIG_H
33#include <config.h>
34#endif
35
36//#include "CodePatterns/MemDebug.hpp"
37
38#include "Atom/atom.hpp"
39#include "Atom/AtomSet.hpp"
40#include "CodePatterns/Log.hpp"
41#include "CodePatterns/Verbose.hpp"
42#include "Dynamics/OutputEnergies.hpp"
43#include "molecule.hpp"
44#include "World.hpp"
45
46#include <iostream>
47#include <fstream>
48#include <string>
49#include <vector>
50
51#include "Actions/MoleculeAction/SaveEnergiesAction.hpp"
52
53using namespace MoleCuilder;
54
55// and construct the stuff
56#include "SaveEnergiesAction.def"
57#include "Action_impl_pre.hpp"
58/** =========== define the function ====================== */
59ActionState::ptr MoleculeSaveEnergiesAction::performCall() {
60 LOG(1, "Storing temperatures in " << params.energiesfile.get() << ".");
61 ofstream output;
62 output.open(params.energiesfile.get().string().c_str(), ios::trunc);
63 AtomSetMixin<std::vector<const atom *> > set =
64 const_cast<const World &>(World::getInstance()).getSelectedAtoms();
65 const size_t MDSteps = set.getMaxTrajectorySize();
66 OutputEnergies<std::vector<const atom *> > writer(set);
67 if (output.fail() || !writer((ofstream * const) &output, 0, MDSteps)) {
68 STATUS("File could not be written.");
69 return Action::failure;
70 } else
71 LOG(2, "File with " << MDSteps << " steps stored.");
72 output.close();
73 return Action::success;
74}
75
76ActionState::ptr MoleculeSaveEnergiesAction::performUndo(ActionState::ptr _state) {
77// MoleculeSaveEnergiesState *state = assert_cast<MoleculeSaveEnergiesState*>(_state.get());
78
79// string newName = state->mol->getName();
80// state->mol->setName(state->lastName);
81
82 return Action::success;
83}
84
85ActionState::ptr MoleculeSaveEnergiesAction::performRedo(ActionState::ptr _state){
86 // Undo and redo have to do the same for this action
87 return performUndo(_state);
88}
89
90bool MoleculeSaveEnergiesAction::canUndo() {
91 return false;
92}
93
94bool MoleculeSaveEnergiesAction::shouldUndo() {
95 return false;
96}
97/** =========== end of function ====================== */
Note: See TracBrowser for help on using the repository browser.