Changeset 22b786 for src/Actions


Ignore:
Timestamp:
Apr 8, 2013, 11:56:08 AM (12 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:
8652a30
Parents:
560cbf
git-author:
Frederik Heber <heber@…> (03/01/13 21:15:10)
git-committer:
Frederik Heber <heber@…> (04/08/13 11:56:08)
Message:

Made SubgraphDissection a MakroAction and added UpdateMoleculesAction.

  • MakroAction does not delete the ActionSequence eventually and it now obtains just a ref, not pointer.
  • TESTFIX: Changed ActionSequenceUnitTest::doesUndoTest() accordingly.
  • SubgraphDissection is right now still very ugly with lots of copy&paste from the preprocessor header files to get every function in place.
  • it could be made into a MakroAction because all three internal Actions do not require any options. How to achieve this with options is unsolved.
Location:
src/Actions
Files:
3 added
9 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/ActionRegistry.cpp

    r560cbf r22b786  
    3535#include "CodePatterns/MemDebug.hpp"
    3636
     37#include "CodePatterns/Assert.hpp"
     38
    3739#include "Actions/ActionRegistry.hpp"
    3840#include "CodePatterns/Singleton_impl.hpp"
     
    6567ActionRegistry::~ActionRegistry()
    6668{
     69  // first clear each macro action that require presence of all primitive ones
     70  MakroAction * presentAction =
     71      dynamic_cast<MakroAction *>(getActionByName("subgraph-dissection"));
     72  ASSERT( presentAction != NULL,
     73      "ActionRegistry::fillRegistry() - makro action has not been registered.");
     74  presentAction->unprepare(*this);
     75
    6776  //std::cout << "ActionRegistry::~ActionRegistry() called, instance is " << this << "." << std::endl;
    6877  cleanup();
     
    8695#include BOOST_PP_LOCAL_ITERATE()
    8796#undef instance_print 
     97
     98  // now prepare each macro action that require presence of all primitive ones
     99  MakroAction * presentAction =
     100      dynamic_cast<MakroAction *>(getActionByName("subgraph-dissection"));
     101  ASSERT( presentAction != NULL,
     102      "ActionRegistry::fillRegistry() - makro action has not been registered.");
     103  presentAction->prepare(*this);
    88104}
    89105
  • src/Actions/GlobalListOfActions.hpp

    r560cbf r22b786  
    1919#define GLOBALLISTOFACTIONS_initial \
    2020  (Redo) \
    21   (GraphSubgraphDissection) \
     21  (GraphUpdateMolecules) \
    2222  (GraphCreateAdjacency) \
    2323  (GraphDepthFirstSearch) \
    2424  (GraphDestroyAdjacency) \
     25  (GraphSubgraphDissection) \
    2526  (MoleculeSaveTemperature) \
    2627  (MoleculeCopy) \
  • src/Actions/GraphAction/SubgraphDissectionAction.cpp

    r560cbf r22b786  
    22 * Project: MoleCuilder
    33 * Description: creates and alters molecular systems
    4  * Copyright (C)  2010-2012 University of Bonn. All rights reserved.
     4 * Copyright (C)  2013 University of Bonn. All rights reserved.
    55 *
    66 *
     
    2424 * SubgraphDissectionAction.cpp
    2525 *
    26  *  Created on: May 9, 2010
     26 *  Created on: Mar 1, 2013
    2727 *      Author: heber
    2828 */
     
    3535#include "CodePatterns/MemDebug.hpp"
    3636
    37 #include "Descriptors/AtomIdDescriptor.hpp"
    38 #include "Descriptors/MoleculeDescriptor.hpp"
     37#include "CodePatterns/Chronos.hpp"
    3938
    40 #include "Atom/atom.hpp"
    41 #include "Bond/bond.hpp"
    42 #include "CodePatterns/Log.hpp"
    43 #include "CodePatterns/Verbose.hpp"
    44 #include "Graph/BondGraph.hpp"
    45 #include "Graph/DepthFirstSearchAnalysis.hpp"
    46 #include "molecule.hpp"
    47 #include "MoleculeListClass.hpp"
    48 #include "World.hpp"
     39#include "Actions/GraphAction/CreateAdjacencyAction.hpp"
     40#include "Actions/GraphAction/DestroyAdjacencyAction.hpp"
     41#include "Actions/GraphAction/UpdateMoleculesAction.hpp"
     42#include "Actions/GraphAction/SubgraphDissectionAction.hpp"
     43#include "Actions/ActionRegistry.hpp"
    4944
    50 #include <iostream>
    51 #include <string>
     45#include "Descriptors/AtomDescriptor.hpp"
    5246
    53 typedef std::map< moleculeId_t, std::vector<atomId_t> > MolAtomList;
    54 typedef std::map< atomId_t, atomId_t > AtomAtomList;
     47#include "SubgraphDissectionAction.def"
    5548
    56 #include "Actions/GraphAction/SubgraphDissectionAction.hpp"
     49// some derived names: if CATEGORY is not given, we don't prefix with it
     50#ifdef CATEGORY
     51#define ACTION BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, Action))
     52#define COMMAND BOOST_PP_CAT(CATEGORY, ACTIONNAME)
     53#define PARAMS BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, Parameters))
     54#else
     55#define ACTION BOOST_PP_CAT(ACTIONNAME, Action)
     56#define COMMAND ACTIONNAME
     57#define PARAMS BOOST_PP_CAT(ACTIONNAME, Parameters)
     58#endif
     59// check if no lists given
     60#ifndef paramtypes
     61#define MAXPARAMTYPES 0
     62#else
     63#define MAXPARAMTYPES BOOST_PP_SEQ_SIZE(paramtypes)
     64#endif
     65#ifndef paramdefaults
     66#define MAXPARAMDEFAULTS 0
     67#else
     68#define MAXPARAMDEFAULTS BOOST_PP_SEQ_SIZE(paramdefaults)
     69#endif
    5770
    58 using namespace MoleCuilder;
     71namespace MoleCuilder {
    5972
    60 // and construct the stuff
    61 #include "SubgraphDissectionAction.def"
    62 #include "Action_impl_pre.hpp"
    63 /** =========== define the function ====================== */
    64 Action::state_ptr GraphSubgraphDissectionAction::performCall() {
    65   // first create stuff for undo state
    66   LOG(0, "STATUS: Creating undo state.");
    67   MolAtomList moleculelist;
    68   vector<molecule *> allmolecules = World::getInstance().getAllMolecules();
    69   for (vector<molecule *>::const_iterator moliter = allmolecules.begin(); moliter != allmolecules.end(); ++moliter) {
    70     std::vector<atomId_t> atomlist;
    71     atomlist.resize((*moliter)->size());
    72     for (molecule::const_iterator atomiter = (*moliter)->begin(); atomiter != (*moliter)->end(); ++atomiter) {
    73       atomlist.push_back((*atomiter)->getId());
    74     }
    75     moleculelist.insert( std::pair< moleculeId_t, std::vector<atomId_t> > ((*moliter)->getId(), atomlist));
    76   }
    77   GraphSubgraphDissectionState *UndoState = new GraphSubgraphDissectionState(moleculelist, params);
     73// static instances
     74ActionSequence GraphSubgraphDissectionAction::actions;
     75bool GraphSubgraphDissectionAction::isPrepared = false;
    7876
    79   // 0a. remove all present molecules
    80   LOG(0, "STATUS: Removing all present molecules.");
    81   MoleculeListClass *molecules = World::getInstance().getMolecules();
    82   for (vector<molecule *>::iterator MolRunner = allmolecules.begin(); MolRunner != allmolecules.end(); ++MolRunner) {
    83     molecules->erase(*MolRunner);
    84     World::getInstance().destroyMolecule(*MolRunner);
    85   }
     77GraphSubgraphDissectionAction::GraphSubgraphDissectionAction() :
     78  MakroAction(ActionTraits< GraphSubgraphDissectionAction >(), actions, false)
     79{}
    8680
    87   // 1. create the bond structure of the single molecule
    88   LOG(0, "STATUS: (Re-)constructing adjacency.");
    89   BondGraph *BG = World::getInstance().getBondGraph();
    90   World::AtomComposite Set = World::getInstance().getAllAtoms();
    91   BG->CreateAdjacency(Set);
     81GraphSubgraphDissectionAction::~GraphSubgraphDissectionAction()
     82{}
    9283
    93   // 2. scan for connected subgraphs
    94   DepthFirstSearchAnalysis DFS;
    95   DFS();
    96   DFS.UpdateMoleculeStructure();
    97   if (World::getInstance().numMolecules() == 0) {
    98     //World::getInstance().destroyMolecule(mol);
    99     ELOG(1, "There are no molecules.");
    100     return Action::failure;
    101   }
     84void GraphSubgraphDissectionAction::prepare(ActionRegistry &AR)
     85{
     86  actions.addAction(AR.getActionByName(std::string("destroy-adjacency")));
     87  actions.addAction(AR.getActionByName(std::string("create-adjacency")));
     88  actions.addAction(AR.getActionByName(std::string("update-molecules")));
     89  isPrepared = true;
     90}
    10291
    103   LOG(1, "I scanned " << World::getInstance().numMolecules() << " molecules.");
     92void GraphSubgraphDissectionAction::unprepare(ActionRegistry &AR)
     93{
     94  // empty sequence
     95  while (actions.removeLastAction() != NULL);
     96  isPrepared = false;
     97}
    10498
    105   return Action::state_ptr(UndoState);
     99void reselectAtoms(const std::vector<atom *> &selected_atoms)
     100{
     101  World::getInstance().clearAtomSelection();
     102  for (std::vector<atom *>::const_iterator iter = selected_atoms.begin();
     103      iter != selected_atoms.end();
     104      ++iter)
     105    World::getInstance().selectAtom(*iter);
     106}
     107
     108Action::state_ptr GraphSubgraphDissectionAction::performCall(){
     109  // we need to "emulate" that all atoms have been selected without destroying
     110  // current selection
     111  Chronos::getInstance().startTiming(TOKEN);
     112  const std::vector<atom *> selected_atoms = World::getInstance().getSelectedAtoms();
     113  World::getInstance().selectAllAtoms(AllAtoms());
     114  Action::state_ptr state(MakroAction::performCall());
     115  reselectAtoms(selected_atoms);
     116  Chronos::getInstance().endTiming(TOKEN);
     117
     118  return state;
    106119}
    107120
    108121Action::state_ptr GraphSubgraphDissectionAction::performUndo(Action::state_ptr _state) {
    109   GraphSubgraphDissectionState *state = assert_cast<GraphSubgraphDissectionState*>(_state.get());
     122  // we need to "emulate" that all atoms have been selected without destroying
     123  // current selection
     124  const std::vector<atom *> selected_atoms = World::getInstance().getSelectedAtoms();
     125  World::getInstance().selectAllAtoms(AllAtoms());
     126  Action::state_ptr state(MakroAction::performUndo(_state));
     127  reselectAtoms(selected_atoms);
    110128
    111   {
    112     // remove all present molecules
    113     MoleculeListClass *molecules = World::getInstance().getMolecules();
    114     vector<molecule *> allmolecules = World::getInstance().getAllMolecules();
    115     for (vector<molecule *>::iterator MolRunner = allmolecules.begin(); MolRunner != allmolecules.end(); ++MolRunner) {
    116       molecules->erase(*MolRunner);
    117       World::getInstance().destroyMolecule(*MolRunner);
    118     }
    119   }
    120 
    121   {
    122     // construct the old state
    123     MoleculeListClass *molecules = World::getInstance().getMolecules();
    124     molecule *mol = NULL;
    125     for (MolAtomList::const_iterator iter = state->moleculelist.begin(); iter != state->moleculelist.end(); ++iter) {
    126       mol = World::getInstance().createMolecule();
    127       if (mol->getId() != (*iter).first)
    128         World::getInstance().changeMoleculeId(mol->getId(), (*iter).first);
    129       for (std::vector<atomId_t>::const_iterator atomiter = (*iter).second.begin(); atomiter != (*iter).second.end(); ++atomiter) {
    130         atom *Walker = World::getInstance().getAtom(AtomById(*atomiter));
    131         mol->AddAtom(Walker);
    132       }
    133       molecules->insert(mol);
    134     }
    135   }
    136 
    137   return Action::state_ptr(_state);
     129  return state;
    138130}
    139131
    140132Action::state_ptr GraphSubgraphDissectionAction::performRedo(Action::state_ptr _state){
    141   return performCall();
     133  // we need to "emulate" that all atoms have been selected without destroying
     134  // current selection
     135  const std::vector<atom *> selected_atoms = World::getInstance().getSelectedAtoms();
     136  World::getInstance().selectAllAtoms(AllAtoms());
     137  Action::state_ptr state(MakroAction::performRedo(_state));
     138  reselectAtoms(selected_atoms);
     139
     140  return state;
    142141}
    143142
    144 bool GraphSubgraphDissectionAction::canUndo() {
    145   return true;
     143// =========== command for calling action directly ===========
     144void COMMAND(
     145#if defined paramtypes && defined paramreferences && BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0)
     146#define BOOST_PP_LOCAL_MACRO(n) type_list(~, n, paramtypes, paramreferences)
     147#define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1)
     148#include BOOST_PP_LOCAL_ITERATE()
     149#endif
     150)
     151{
     152  ACTION *ToCall = dynamic_cast<ACTION*>(ActionRegistry::getInstance().getActionByName( TOKEN )); //->clone(params);
     153  //ACTION::PARAMS params;
     154#if defined paramreferences && BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0)
     155#define BOOST_PP_LOCAL_MACRO(n) value_print(~, n, paramreferences, ToCall->params.)
     156#define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1)
     157#include BOOST_PP_LOCAL_ITERATE()
     158#endif
     159  ToCall->call(Action::NonInteractive);
     160};
     161
     162void BOOST_PP_CAT( COMMAND, _stringargs)(
     163#if defined paramtypes && defined paramreferences && BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0)
     164#define BOOST_PP_LOCAL_MACRO(n) type_list(~, n, BOOST_PP_SEQ_TRANSFORM( type2string, , paramtypes), paramreferences)
     165#define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1)
     166#include BOOST_PP_LOCAL_ITERATE()
     167#endif
     168  ) {
     169  ACTION *ToCall = dynamic_cast<ACTION*>(ActionRegistry::getInstance().getActionByName( TOKEN )); //->clone(params);
     170  //ACTION::PARAMS params;
     171#if defined paramtypes && defined paramtypes && BOOST_PP_NOT_EQUAL(MAXPARAMTYPES,0)
     172#define BOOST_PP_LOCAL_MACRO(n) valuetype_print(~, n, paramreferences, paramtypes, ToCall->params. )
     173#define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1)
     174#include BOOST_PP_LOCAL_ITERATE()
     175#endif
     176  ToCall->call(MoleCuilder::Action::NonInteractive);
     177};
     178
    146179}
    147 
    148 bool GraphSubgraphDissectionAction::shouldUndo() {
    149   return true;
    150 }
    151 /** =========== end of function ====================== */
  • src/Actions/GraphAction/SubgraphDissectionAction.def

    r560cbf r22b786  
    22 * SubgraphDissectionAction.def
    33 *
    4  *  Created on: Aug 26, 2010
     4 *  Created on: Mar 1, 2013
    55 *      Author: heber
    66 */
  • src/Actions/GraphAction/SubgraphDissectionAction.hpp

    r560cbf r22b786  
    22 * SubgraphDissectionAction.hpp
    33 *
    4  *  Created on: May 9, 2010
     4 *  Created on: Mar 1, 2013
    55 *      Author: heber
    66 */
     
    1414#endif
    1515
    16 
    17 #include "Actions/Action.hpp"
     16#include "Actions/ActionSequence.hpp"
     17#include "Actions/ActionTraits.hpp"
     18#include "Actions/MakroAction.hpp"
    1819
    1920#include "SubgraphDissectionAction.def"
    20 #include "Action_impl_header.hpp"
     21
     22// some derived names: if CATEGORY is not given, we don't prefix with it
     23#ifdef CATEGORY
     24#define ACTION BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, Action))
     25#define COMMAND BOOST_PP_CAT(CATEGORY, ACTIONNAME)
     26#define PARAMS BOOST_PP_CAT(CATEGORY, BOOST_PP_CAT(ACTIONNAME, Parameters))
     27#else
     28#define ACTION BOOST_PP_CAT(ACTIONNAME, Action)
     29#define COMMAND ACTIONNAME
     30#define PARAMS BOOST_PP_CAT(ACTIONNAME, Parameters)
     31#endif
     32// check if no lists given
     33#ifndef paramtypes
     34#define MAXPARAMTYPES 0
     35#else
     36#define MAXPARAMTYPES BOOST_PP_SEQ_SIZE(paramtypes)
     37#endif
     38#ifndef paramdefaults
     39#define MAXPARAMDEFAULTS 0
     40#else
     41#define MAXPARAMDEFAULTS BOOST_PP_SEQ_SIZE(paramdefaults)
     42#endif
     43
     44namespace MoleCuilder {
     45
     46// print a list of type ref followed, i.e. "int i, double position"
     47#define type_list(z,n,TYPELIST, VARLIST) \
     48  BOOST_PP_COMMA_IF(n)\
     49  BOOST_PP_SEQ_ELEM(n, TYPELIST) \
     50  BOOST_PP_SEQ_ELEM(n, VARLIST)
     51
     52void COMMAND(
     53#if defined paramtypes && defined paramreferences
     54#define BOOST_PP_LOCAL_MACRO(n) type_list(~, n, paramtypes, paramreferences)
     55#define BOOST_PP_LOCAL_LIMITS  (0, MAXPARAMTYPES-1)
     56#include BOOST_PP_LOCAL_ITERATE()
     57#endif
     58    );
     59
     60class GraphSubgraphDissectionAction;
     61
     62template <>
     63class ActionTraits<ACTION> : public ActionTrait {
     64public:
     65  ActionTraits() :
     66#ifndef SHORTFORM
     67    ActionTrait(OptionTrait(TOKEN, &typeid(void), DESCRIPTION, std::string()))
     68#else
     69    ActionTrait(OptionTrait(TOKEN, &typeid(void), DESCRIPTION, std::string(), SHORTFORM))
     70#endif /* SHORTFORM */
     71  {
     72  // initialize remainder of action info
     73#ifdef MENUNAME
     74    MenuTitle = MENUNAME;
     75#endif
     76#ifdef MENUPOSITION
     77    MenuPosition = MENUPOSITION;
     78#endif
     79
     80    // we got no options to initialize
     81  }
     82
     83  virtual ~ActionTraits() {
     84    //std::cout << "ActionTraits<" << BOOST_PP_STRINGIZE(ACTION) << ">::~ActionTraits() on instance " << this << " with name " << getName() << " called." << std::endl;
     85  }
     86};
     87
     88class GraphSubgraphDissectionAction : public MakroAction
     89{
     90public:
     91  GraphSubgraphDissectionAction();
     92  virtual ~GraphSubgraphDissectionAction();
     93
     94  // must be called after all primitive actions are present
     95  void prepare(ActionRegistry &AR);
     96  // must be called before alle primitive actions are removed
     97  void unprepare(ActionRegistry &AR);
     98
     99  virtual Action::state_ptr performCall();
     100  virtual Action::state_ptr performUndo(Action::state_ptr);
     101  virtual Action::state_ptr performRedo(Action::state_ptr);
     102
     103private:
     104  //!> flag to check whether actions have been prepared
     105  static bool isPrepared;
     106  //!> sequence of actions for this macro action
     107  static ActionSequence actions;
     108};
     109
     110}
     111
     112#undef ACTION
     113#undef COMMAND
     114#undef COMMANDFULL
     115#undef PARAMS
     116
     117#undef ACTIONNAME
     118#undef CATEGORY
     119#undef MENUNAME
     120#undef MENUPOSITION
     121#undef TOKEN
     122
     123#undef DESCRIPTION
     124#undef SHORTFORM
    21125
    22126#endif /* SUBGRAPHDISSECTIONACTION_HPP_ */
  • src/Actions/Makefile.am

    r560cbf r22b786  
    233233  Actions/GraphAction/DepthFirstSearchAction.cpp \
    234234  Actions/GraphAction/DestroyAdjacencyAction.cpp \
    235   Actions/GraphAction/SubgraphDissectionAction.cpp
     235  Actions/GraphAction/SubgraphDissectionAction.cpp \
     236  Actions/GraphAction/UpdateMoleculesAction.cpp
    236237GRAPHACTIONHEADER = \
    237238  Actions/GraphAction/CreateAdjacencyAction.hpp \
    238239  Actions/GraphAction/DepthFirstSearchAction.hpp \
    239240  Actions/GraphAction/DestroyAdjacencyAction.hpp \
    240   Actions/GraphAction/SubgraphDissectionAction.hpp
     241  Actions/GraphAction/SubgraphDissectionAction.hpp \
     242  Actions/GraphAction/UpdateMoleculesAction.hpp
    241243GRAPHACTIONDEFS = \
    242244  Actions/GraphAction/CreateAdjacencyAction.def \
    243245  Actions/GraphAction/DepthFirstSearchAction.def \
    244246  Actions/GraphAction/DestroyAdjacencyAction.def \
    245   Actions/GraphAction/SubgraphDissectionAction.def
     247  Actions/GraphAction/SubgraphDissectionAction.def \
     248  Actions/GraphAction/UpdateMoleculesAction.def
    246249
    247250MOLECULEACTIONSOURCE = \
  • src/Actions/MakroAction.cpp

    r560cbf r22b786  
    5656};
    5757
    58 MakroAction::MakroAction(const ActionTrait &_trait,ActionSequence* _actions,bool _doRegister) :
     58MakroAction::MakroAction(const ActionTrait &_trait,ActionSequence& _actions,bool _doRegister) :
    5959Action(_trait,_doRegister),
    6060actions(_actions)
     
    6464MakroAction::~MakroAction()
    6565{
    66   Action* action;
    67   while((action=actions->removeLastAction())){
    68     delete action;
    69   }
    70   delete actions;
     66  // emptying the sequence is someone else responsibility
     67//  Action* action;
     68//  while((action=actions.removeLastAction())){
     69//    delete action;
     70//  }
    7171}
    7272
     73void MakroAction::prepare(ActionRegistry &AR)
     74{}
     75
     76void MakroAction::unprepare(ActionRegistry &AR)
     77{}
     78
    7379Dialog* MakroAction::fillDialog(Dialog *dialog) {
    74   return actions->fillAllDialogs(dialog);
     80  return actions.fillAllDialogs(dialog);
    7581}
    7682
    7783Action::state_ptr MakroAction::performCall(){
    78   ActionSequence::stateSet states = actions->callAll(true);
     84  ActionSequence::stateSet states = actions.callAll(true);
    7985  return Action::state_ptr(new MakroActionState(states));
    8086}
     
    8389  MakroActionState *state = dynamic_cast<MakroActionState*>(_state.get());
    8490  ASSERT(state,"Type mismatch for the state of the MakroAction");
    85   ActionSequence::stateSet states = actions->undoAll(state->states);
     91  ActionSequence::stateSet states = actions.undoAll(state->states);
    8692  return Action::state_ptr(new MakroActionState(states));
    8793}
     
    9096  MakroActionState *state = dynamic_cast<MakroActionState*>(_state.get());
    9197  ASSERT(state,"Type mismatch for the state of the MakroAction");
    92   ActionSequence::stateSet states = actions->redoAll(state->states);
     98  ActionSequence::stateSet states = actions.redoAll(state->states);
    9399  return Action::state_ptr(new MakroActionState(states));
    94100}
    95101
    96102bool MakroAction::canUndo() {
    97   return actions->canUndo();
     103  return actions.canUndo();
    98104}
    99105
    100106bool MakroAction::shouldUndo() {
    101   return actions->shouldUndo();
     107  return actions.shouldUndo();
    102108}
  • src/Actions/MakroAction.hpp

    r560cbf r22b786  
    2020
    2121namespace MoleCuilder {
     22  class ActionRegistry;
    2223  class ActionSequence;
    2324
     
    3031{
    3132public:
    32   MakroAction(const ActionTrait &_trait,ActionSequence* _actions,bool _doRegister=true);
     33  MakroAction(const ActionTrait &_trait,ActionSequence& _actions,bool _doRegister=true);
    3334  virtual ~MakroAction();
    3435
     
    3637  bool shouldUndo();
    3738
     39  // must be called after all primitive actions are present
     40  virtual void prepare(ActionRegistry &AR);
     41  // must be called before alle primitive actions are removed
     42  virtual void unprepare(ActionRegistry &AR);
     43
    3844protected:
    3945  virtual Dialog *fillDialog(Dialog *dialog);
    40 private:
     46
    4147  virtual Action::state_ptr performCall();
    4248  virtual Action::state_ptr performUndo(Action::state_ptr);
    4349  virtual Action::state_ptr performRedo(Action::state_ptr);
    4450
    45   ActionSequence *actions;
     51private:
     52  ActionSequence &actions;
    4653};
    4754
  • src/Actions/unittests/ActionSequenceUnitTest.cpp

    r560cbf r22b786  
    277277
    278278  ActionTrait MakroTrait("Test MakroAction");
    279   MakroAction act(MakroTrait,sequence,false);
     279  MakroAction act(MakroTrait,*sequence,false);
    280280
    281281  act.call();
     
    289289  CPPUNIT_ASSERT_EQUAL(false,wasCalled2->wasCalled());
    290290
    291 }
    292 
    293 
     291  delete sequence;
     292}
     293
     294
Note: See TracChangeset for help on using the changeset viewer.