- Timestamp:
- Oct 12, 2011, 2:10:51 PM (13 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- c8b17b
- Parents:
- 35a25a
- git-author:
- Frederik Heber <heber@…> (09/09/11 16:54:58)
- git-committer:
- Frederik Heber <heber@…> (10/12/11 14:10:51)
- Location:
- src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Actions/CommandAction/ElementDbAction.cpp
r35a25a r220cf64 18 18 #endif 19 19 20 // include headers that implement a archive in simple text format 21 #include <boost/archive/text_oarchive.hpp> 22 #include <boost/archive/text_iarchive.hpp> 23 20 24 #include "CodePatterns/MemDebug.hpp" 21 25 22 26 #include "config.hpp" 27 #include "element.hpp" // we need element because of serialization! 28 #include "periodentafel.hpp" 23 29 #include "CodePatterns/Log.hpp" 24 #include "periodentafel.hpp"25 30 #include "CodePatterns/Verbose.hpp" 26 31 #include "World.hpp" 27 32 28 #include <iostream>29 33 #include <string> 30 34 31 using namespace std;32 35 33 36 #include "Actions/CommandAction/ElementDbAction.hpp" … … 35 38 // and construct the stuff 36 39 #include "ElementDbAction.def" 37 #include "Action_impl_pre.hpp" 40 #include "Actions/Action_impl_pre.hpp" 41 38 42 /** =========== define the function ====================== */ 39 43 Action::state_ptr CommandElementDbAction::performCall() { 40 ostringstream usage;44 std::ostringstream usage; 41 45 42 46 // obtain information 43 47 getParametersfromValueStorage(); 48 periodentafel *periode = World::getInstance().getPeriode(); 49 50 // create undo state 51 std::stringstream undostream; 52 boost::archive::text_oarchive oa(undostream); 53 oa << periode; 54 CommandElementDbState *UndoState = 55 new CommandElementDbState( 56 undostream.str(), 57 params 58 ); 44 59 45 60 // get the path … … 49 64 50 65 // load table 66 if (periode->LoadPeriodentafel(configuration->databasepath)) { 67 DoLog(0) && (Log() << Verbose(0) << "Element list loaded successfully." << endl); 68 //periode->Output(); 69 return Action::state_ptr(UndoState); 70 } else { 71 DoLog(0) && (Log() << Verbose(0) << "Element list loading failed." << endl); 72 return Action::failure; 73 } 74 } 75 76 Action::state_ptr CommandElementDbAction::performUndo(Action::state_ptr _state) { 77 CommandElementDbState *state = assert_cast<CommandElementDbState*>(_state.get()); 78 79 periodentafel *periode; 80 81 std::stringstream undostream(state->undostring); 82 boost::archive::text_iarchive ia(undostream); 83 ia >> periode; 84 85 delete World::getInstance().getPeriode(); 86 World::getInstance().getPeriode() = periode; 87 88 return Action::state_ptr(_state); 89 } 90 91 Action::state_ptr CommandElementDbAction::performRedo(Action::state_ptr _state){ 92 CommandElementDbState *state = assert_cast<CommandElementDbState*>(_state.get()); 93 94 // get the path 95 // TODO: Make databasepath a std::string 96 config *configuration = World::getInstance().getConfig(); 97 strcpy(configuration->databasepath, state->params.databasepath.branch_path().string().c_str()); 98 99 // load table 51 100 periodentafel *periode = World::getInstance().getPeriode(); 52 101 if (periode->LoadPeriodentafel(configuration->databasepath)) { 53 102 DoLog(0) && (Log() << Verbose(0) << "Element list loaded successfully." << endl); 54 103 //periode->Output(); 55 return Action::s uccess;104 return Action::state_ptr(_state); 56 105 } else { 57 106 DoLog(0) && (Log() << Verbose(0) << "Element list loading failed." << endl); 58 107 return Action::failure; 59 108 } 60 61 }62 63 Action::state_ptr CommandElementDbAction::performUndo(Action::state_ptr _state) {64 // ParserLoadXyzState *state = assert_cast<ParserLoadXyzState*>(_state.get());65 66 return Action::failure;67 // string newName = state->mol->getName();68 // state->mol->setName(state->lastName);69 //70 // return Action::state_ptr(new ParserLoadXyzState(state->mol,newName));71 }72 73 Action::state_ptr CommandElementDbAction::performRedo(Action::state_ptr _state){74 return Action::failure;75 109 } 76 110 77 111 bool CommandElementDbAction::canUndo() { 78 return false;112 return true; 79 113 } 80 114 81 115 bool CommandElementDbAction::shouldUndo() { 82 return false;116 return true; 83 117 } 84 118 /** =========== end of function ====================== */ -
src/Actions/CommandAction/ElementDbAction.def
r35a25a r220cf64 7 7 8 8 // all includes and forward declarations necessary for non-integral types below 9 9 #include <sstream> 10 10 11 11 // i.e. there is an integer with variable name Z that can be found in … … 18 18 #define paramreferences (databasepath) 19 19 20 # undef statetypes21 # undef statereferences20 #define statetypes (std::string) 21 #define statereferences (undostring) 22 22 23 23 // some defines for all the names, you may use ACTION, STATE and PARAMS -
src/Actions/CommandAction/ElementDbAction.hpp
r35a25a r220cf64 18 18 19 19 #include "ElementDbAction.def" 20 #include "Action _impl_header.hpp"20 #include "Actions/Action_impl_header.hpp" 21 21 22 22 #endif /* ELEMENTDBACTION_HPP_ */ -
src/unittests/PeriodentafelUnitTest.hpp
r35a25a r220cf64 47 47 }; 48 48 49 std::string gatherUndoInformation(const periodentafel &periode); 50 51 49 52 #endif /* PERIODENTAFELUNITTEST_HPP_ */
Note:
See TracChangeset
for help on using the changeset viewer.