Ignore:
Timestamp:
Mar 25, 2010, 12:01:27 PM (16 years ago)
Author:
Tillmann Crueger <crueger@…>
Children:
c3294f, fe3540
Parents:
521e29
git-author:
Tillmann Crueger <crueger@…> (03/25/10 11:59:56)
git-committer:
Tillmann Crueger <crueger@…> (03/25/10 12:01:27)
Message:

Added full undo functioniality

Location:
molecuilder/src/Actions
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/Actions/Action.cpp

    r521e29 r8d9984  
    1010#include "Actions/Action.hpp"
    1111#include "Actions/ActionRegistry.hpp"
     12#include "Actions/ActionHistory.hpp"
    1213
    1314using namespace std;
     
    3435void Action::call(){
    3536  // forward to private virtual
    36   performCall();
     37  state_ptr state = performCall();
     38  if(shouldUndo() && state != failure){
     39    if(canUndo()){
     40      ActionHistory::getInstance().addElement(this,state);
     41    }
     42    else{
     43      ActionHistory::getInstance().clear();
     44    }
     45  }
    3746}
    3847Action::state_ptr Action::undo(state_ptr _state) {
  • molecuilder/src/Actions/ActionRegistry.cpp

    r521e29 r8d9984  
    1212
    1313#include <string>
    14 #include <cassert>
     14#include "Helpers/Assert.hpp"
    1515#include <iostream>
    1616
     
    3333  map<const string,Action*>::iterator iter;
    3434  iter = actionMap.find(name);
    35   assert(iter!=actionMap.end() && "Query for an action not stored in registry");
     35  ASSERT(iter!=actionMap.end(),"Query for an action not stored in registry");
    3636  return iter->second;
    3737}
     
    4040  pair<map<const string,Action*>::iterator,bool> ret;
    4141  ret = actionMap.insert(pair<const string,Action*>(action->getName(),action));
    42   assert(ret.second && "Two actions with the same name added to registry");
     42  ASSERT(ret.second,"Two actions with the same name added to registry");
    4343}
    4444
  • molecuilder/src/Actions/small_actions.cpp

    r521e29 r8d9984  
    2626};
    2727
    28 char ChangeMoleculeNameAction::NAME[] = "Change filename of Molecule";
     28const char ChangeMoleculeNameAction::NAME[] = "Change filename of Molecule";
    2929
    3030ChangeMoleculeNameAction::ChangeMoleculeNameAction(MoleculeListClass *_molecules) :
  • molecuilder/src/Actions/small_actions.hpp

    r521e29 r8d9984  
    2424
    2525  MoleculeListClass *molecules;
    26   static char NAME[];
     26  static const char NAME[];
    2727};
    2828
Note: See TracChangeset for help on using the changeset viewer.