source: src/Actions/Calculation_impl.hpp@ d93d2c

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
Last change on this file since d93d2c was a82f61, checked in by Frederik Heber <heber@…>, 9 years ago

Added Action::setOptionValue() which allows setting the option via a string.

  • this is preparatory for allowing the creation of MakroActions inside the code. We need to set the options without going through dialogs in some way or another and without being completely inside the Actions as is the case for the COMMAND variants and the python function calls.
  • Property mode set to 100644
File size: 2.0 KB
RevLine 
[7c4e29]1/*
2 * Calculation_impl.hpp
3 *
4 * Created on: Feb 19, 2010
5 * Author: crueger
6 */
7
8#ifndef CALCULATION_IMPL_HPP_
9#define CALCULATION_IMPL_HPP_
10
[56f73b]11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16
[b54ac8]17#include "Actions/Calculation.hpp"
18
[7c4e29]19#include <cassert>
[46b181]20#include <iostream>
[7c4e29]21
[ce7fdc]22using namespace MoleCuilder;
23
[7c4e29]24template<typename T>
[126867]25Calculation<T>::Calculation(int _maxSteps, const ActionTrait &_trait) :
[c09f94]26 Process(_trait),
[ead4e6]27 result(0),
28 done(false)
[c09f94]29{
30 setMaxSteps(_maxSteps);
31}
[7c4e29]32
33template<typename T>
34Calculation<T>::~Calculation()
[b54ac8]35{
36 delete result;
37}
[7c4e29]38
39// methods inherited from Action
40
41template<typename T>
[b5b01e]42ActionState::ptr Calculation<T>::performCall(){
[b54ac8]43 reset();
44 (*this)();
[67e2b3]45 return Action::success;
[7c4e29]46}
47
48template<typename T>
[b5b01e]49ActionState::ptr Calculation<T>::performUndo(ActionState::ptr){
[67e2b3]50 ASSERT(0,"Cannot undo a calculation");
51 return Action::success;
52}
53template<typename T>
[b5b01e]54ActionState::ptr Calculation<T>::performRedo(ActionState::ptr){
[67e2b3]55 ASSERT(0,"Cannot redo a calculation");
56 return Action::success;
57}
[7c4e29]58
59template<typename T>
60bool Calculation<T>::canUndo()
61{
62 return false;
63}
64
[67e2b3]65template<typename T>
66bool Calculation<T>::shouldUndo()
67{
68 return false;
69}
70
[46b181]71template<typename T>
72void Calculation<T>::outputAsCLI(std::ostream &ost) const
73{
74}
75
[477012]76template<typename T>
77void Calculation<T>::outputAsPython(std::ostream &ost, const std::string &prefix) const
78{}
79
[a82f61]80template<typename T>
81void Calculation<T>::setOptionValue(const std::string &_token, const std::string &_value)
82{}
83
[7c4e29]84// methods for calculation infrastructure
85
86template<typename T>
[b54ac8]87T Calculation<T>::operator()(){
[7c4e29]88 if(!done){
89 result = doCalc();
90 done = true;
91 }
[b54ac8]92 return *result;
[7c4e29]93}
94
95template<typename T>
[af5384]96bool Calculation<T>::hasResult() const {
[7c4e29]97 return done;
98}
99
100template<typename T>
[af5384]101T Calculation<T>::getResult() const {
[7c4e29]102 assert(done && "No result calculated");
103 return *result;
104}
105
106template<typename T>
107void Calculation<T>::reset(){
108 done = false;
[b54ac8]109 delete result;
[7c4e29]110 result = 0;
111}
112
113#endif /* CALCULATION_IMPL_HPP_ */
Note: See TracBrowser for help on using the repository browser.