Ignore:
Timestamp:
Aug 5, 2015, 7:12:24 AM (9 years ago)
Author:
Frederik Heber <heber@…>
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:
c307ba
Parents:
94232b
git-author:
Frederik Heber <heber@…> (08/03/15 09:25:02)
git-committer:
Frederik Heber <heber@…> (08/05/15 07:12:24)
Message:

Cleaned up ActionQueue's interface: Actions are always cloned.

  • Action's dstor needs to be public as we have a clone() function.
  • ActionRegistrys' (and AQ's) getActionByName now returns const ref. We must not return a ptr as it may not get deleted elsewhere. We are handing out prototypes.
  • queueAction(action*,...) is private to prevent leakage, queueAction(string, ...) is the public interface.
  • some other small functions are now private, too.
  • MakroActions now need to clone() the prototype on prepare() and delete them on unprepare().
  • ActionSequence deletes contained actions.
  • FIX: ActionSequenceUnitTest cannot check on not-called property of removed actions anymore as these are gone now (they are deleted on removal and they are cloned on insertion).
  • DOCU: Updated documentation on Actions.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/ActionRegistry.cpp

    r94232b r10aee4  
    6262  //std::cout << "ActionRegistry::ActionRegistry() called, instance is " << this << "." << std::endl;
    6363  fillRegistry();
     64  prepareAllMakroActions();
    6465  fillOptionRegistry();
    6566  completely_instatiated = true;
     
    7576  // add all MakroActions: PLEASE adhere to the alphabetical ordering
    7677  {
    77     MakroAction * presentAction =
    78         dynamic_cast<MakroAction *>(getActionByName("molecular-dynamics"));
    79     ASSERT( presentAction != NULL,
    80         "ActionRegistry::fillRegistry() - makro action has not been registered.");
    81     presentAction->unprepare(*this);
    82   }
    83   {
    84     MakroAction * presentAction =
    85         dynamic_cast<MakroAction *>(getActionByName("optimize-structure"));
    86     ASSERT( presentAction != NULL,
    87         "ActionRegistry::fillRegistry() - makro action has not been registered.");
    88     presentAction->unprepare(*this);
    89   }
    90   {
    91     MakroAction * presentAction =
    92         dynamic_cast<MakroAction *>(getActionByName("subgraph-dissection"));
    93     ASSERT( presentAction != NULL,
    94         "ActionRegistry::fillRegistry() - makro action has not been registered.");
    95     presentAction->unprepare(*this);
    96   }
    97   {
    98     MakroAction * presentAction =
    99         dynamic_cast<MakroAction *>(getActionByName("translate-molecules"));
    100     ASSERT( presentAction != NULL,
    101         "ActionRegistry::fillRegistry() - makro action has not been registered.");
    102     presentAction->unprepare(*this);
     78    MakroAction & presentAction =
     79        const_cast<MakroAction &>(
     80        dynamic_cast<const MakroAction &>(getActionByName("molecular-dynamics")));
     81    presentAction.unprepare(*this);
     82  }
     83  {
     84    MakroAction & presentAction =
     85        const_cast<MakroAction &>(
     86        dynamic_cast<const MakroAction &>(getActionByName("optimize-structure")));
     87    presentAction.unprepare(*this);
     88  }
     89  {
     90    MakroAction & presentAction =
     91        const_cast<MakroAction &>(
     92        dynamic_cast<const MakroAction &>(getActionByName("subgraph-dissection")));
     93    presentAction.unprepare(*this);
     94  }
     95  {
     96    MakroAction & presentAction =
     97        const_cast<MakroAction &>(
     98        dynamic_cast<const MakroAction &>(getActionByName("translate-molecules")));
     99    presentAction.unprepare(*this);
    103100  }
    104101
     
    124121#include BOOST_PP_LOCAL_ITERATE()
    125122#undef instance_print 
    126 
     123}
     124
     125void ActionRegistry::prepareAllMakroActions()
     126{
    127127  // now prepare each macro action that require presence of all primitive ones
    128128  {
    129     MakroAction * presentAction =
    130         dynamic_cast<MakroAction *>(getActionByName("subgraph-dissection"));
    131     ASSERT( presentAction != NULL,
    132         "ActionRegistry::fillRegistry() - makro action has not been registered.");
    133     presentAction->prepare(*this);
    134   }
    135   {
    136     MakroAction * presentAction =
    137         dynamic_cast<MakroAction *>(getActionByName("molecular-dynamics"));
    138     ASSERT( presentAction != NULL,
    139         "ActionRegistry::fillRegistry() - makro action has not been registered.");
    140     presentAction->prepare(*this);
    141   }
    142   {
    143     MakroAction * presentAction =
    144         dynamic_cast<MakroAction *>(getActionByName("optimize-structure"));
    145     ASSERT( presentAction != NULL,
    146         "ActionRegistry::fillRegistry() - makro action has not been registered.");
    147     presentAction->prepare(*this);
    148   }
    149   {
    150     MakroAction * presentAction =
    151         dynamic_cast<MakroAction *>(getActionByName("translate-molecules"));
    152     ASSERT( presentAction != NULL,
    153         "ActionRegistry::fillRegistry() - makro action has not been registered.");
    154     presentAction->prepare(*this);
     129    MakroAction & presentAction =
     130        const_cast<MakroAction &>(
     131        dynamic_cast<const MakroAction &>(getActionByName("subgraph-dissection")));
     132    presentAction.prepare(*this);
     133  }
     134  {
     135    MakroAction & presentAction =
     136        const_cast<MakroAction &>(
     137        dynamic_cast<const MakroAction &>(getActionByName("molecular-dynamics")));
     138    presentAction.prepare(*this);
     139  }
     140  {
     141    MakroAction & presentAction =
     142        const_cast<MakroAction &>(
     143        dynamic_cast<const MakroAction &>(getActionByName("optimize-structure")));
     144    presentAction.prepare(*this);
     145  }
     146  {
     147    MakroAction & presentAction =
     148        const_cast<MakroAction &>(
     149        dynamic_cast<const MakroAction &>(getActionByName("translate-molecules")));
     150    presentAction.prepare(*this);
    155151  }
    156152}
     
    227223/** Just passes on call to Registry<Action>::getByName().
    228224 * \param name name of Action
    229  * \return pointer to Action
    230  */
    231 Action* ActionRegistry::getActionByName(const std::string &name)
    232 {
    233   return getByName(name);
     225 * \return const ref to Action
     226 */
     227const Action& ActionRegistry::getActionByName(const std::string &name)
     228{
     229  Action * const action = getByName(name);
     230  ASSERT( action != NULL,
     231      "ActionRegistry::getActionByName() - action "+name+" not present!");
     232  return *action;
    234233}
    235234
Note: See TracChangeset for help on using the changeset viewer.