source: src/Actions/FragmentationAction/SaveFragmentResultsAction.cpp@ ac9dc8

Action_Thermostats Add_AtomRandomPerturbation Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests AutomationFragmentation_failures Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator Docu_Python_wait EmpiricalPotential_contain_HomologyGraph_documentation Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph Fix_ChronosMutex Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion GeometryObjects Gui_displays_atomic_force_velocity IndependentFragmentGrids_IntegrationTest JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks RotateToPrincipalAxisSystem_UndoRedo StoppableMakroAction TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes
Last change on this file since ac9dc8 was 9eb71b3, checked in by Frederik Heber <frederik.heber@…>, 8 years ago

Commented out MemDebug include and Memory::ignore.

  • MemDebug clashes with various allocation operators that use a specific placement in memory. It is so far not possible to wrap new/delete fully. Hence, we stop this effort which so far has forced us to put ever more includes (with clashes) into MemDebug and thereby bloat compilation time.
  • MemDebug does not add that much usefulness which is not also provided by valgrind.
  • Property mode set to 100644
File size: 3.6 KB
Line 
1/*
2 * Project: MoleCuilder
3 * Description: creates and alters molecular systems
4 * Copyright (C) 2016 Frederik Heber. All rights reserved.
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/>.
21 */
22
23/*
24 * SaveFragmentResultsAction.cpp
25 *
26 * Created on: Sep 04, 2016
27 * Author: heber
28 */
29
30// include config.h
31#ifdef HAVE_CONFIG_H
32#include <config.h>
33#endif
34
35// include headers that implement a archive in simple text format
36// and before MemDebug due to placement new
37#include <boost/archive/text_oarchive.hpp>
38#include <boost/archive/text_iarchive.hpp>
39
40//#include "CodePatterns/MemDebug.hpp"
41
42#include <iostream>
43
44#include "CodePatterns/Log.hpp"
45
46#include "Fragmentation/Summation/Containers/FragmentationResultContainer.hpp"
47
48#include "Actions/FragmentationAction/SaveFragmentResultsAction.hpp"
49
50using namespace MoleCuilder;
51
52// and construct the stuff
53#include "SaveFragmentResultsAction.def"
54#include "Action_impl_pre.hpp"
55/** =========== define the function ====================== */
56
57bool writeFragmentResultsToFile(
58 const boost::filesystem::path &fragmentresults_file
59 )
60{
61 /// if file is given, parse from file into ResultsContainer
62 FragmentationResultContainer& container = FragmentationResultContainer::getInstance();
63 if (!boost::filesystem::exists(fragmentresults_file)) {
64 LOG(1, "INFO: Saving fragment results to " << fragmentresults_file.string() << ".");
65 std::ofstream returnstream(fragmentresults_file.string().c_str());
66 if (returnstream.good()) {
67 boost::archive::text_oarchive oa(returnstream);
68 oa << container;
69 if (returnstream.bad()) { // check if correctly written
70 LOG(1, "Failed to write to file " << fragmentresults_file.string() << ".");
71 return false;
72 } else
73 returnstream.close();
74 }
75 } else {
76 ELOG(1, "Given file" << fragmentresults_file.string() << " already exists.");
77 return false;
78 }
79 return true;
80}
81
82ActionState::ptr FragmentationSaveFragmentResultsAction::performCall()
83{
84 if (!params.fragmentresults_file.get().empty()) {
85 const boost::filesystem::path &fragmentresults_file = params.fragmentresults_file.get();
86 if (writeFragmentResultsToFile(fragmentresults_file)) {
87 STATUS("SUCCESS: Saving fragment results to file "+toString(fragmentresults_file.string())+".");
88 return Action::success;
89 } else {
90 STATUS("FAIL: Failed to write fragment results file.");
91 return Action::failure;
92 }
93 } else {
94 STATUS("FAIL: Fragment results file name empty.");
95 return Action::failure;
96 }
97}
98
99ActionState::ptr FragmentationSaveFragmentResultsAction::performUndo(ActionState::ptr _state) {
100 return Action::success;
101}
102
103ActionState::ptr FragmentationSaveFragmentResultsAction::performRedo(ActionState::ptr _state){
104 return Action::success;
105}
106
107bool FragmentationSaveFragmentResultsAction::canUndo() {
108 return false;
109}
110
111bool FragmentationSaveFragmentResultsAction::shouldUndo() {
112 return false;
113}
114/** =========== end of function ====================== */
Note: See TracBrowser for help on using the repository browser.