Index: src/Actions/Action.cpp
===================================================================
--- src/Actions/Action.cpp	(revision 5b0b98b2ea8b24976731e525dc2aa2811d18dc20)
+++ src/Actions/Action.cpp	(revision d56640502d4cc2a4450b681ccb0bc442573add28)
@@ -10,4 +10,5 @@
 #include "Actions/Action.hpp"
 #include "Actions/ActionRegistry.hpp"
+#include "Actions/ActionHistory.hpp"
 
 using namespace std;
@@ -34,5 +35,13 @@
 void Action::call(){
   // forward to private virtual
-  performCall();
+  state_ptr state = performCall();
+  if(shouldUndo() && state != failure){
+    if(canUndo()){
+      ActionHistory::getInstance().addElement(this,state);
+    }
+    else{
+      ActionHistory::getInstance().clear();
+    }
+  }
 }
 Action::state_ptr Action::undo(state_ptr _state) {
Index: src/Actions/ActionHistory.cpp
===================================================================
--- src/Actions/ActionHistory.cpp	(revision d56640502d4cc2a4450b681ccb0bc442573add28)
+++ src/Actions/ActionHistory.cpp	(revision d56640502d4cc2a4450b681ccb0bc442573add28)
@@ -0,0 +1,118 @@
+/*
+ * ActionHistory.cpp
+ *
+ *  Created on: Mar 25, 2010
+ *      Author: crueger
+ */
+
+#include "ActionHistory.hpp"
+
+#include <iostream>
+
+#include "Patterns/Singleton_impl.hpp"
+#include "Helpers/Assert.hpp"
+
+using namespace std;
+
+ActionHistory::ActionHistory()
+{}
+
+ActionHistory::~ActionHistory()
+{}
+
+void ActionHistory::undoLast(){
+  ASSERT(history.size(),"Undo performed when the undo-queue was empty");
+  HistoryElement elem = history.back();
+  history.pop_back();
+  Action::state_ptr newState = elem.action->undo(elem.state);
+  yrotsih.push_back(HistoryElement(elem.action,newState));
+}
+void ActionHistory::redoLast(){
+  ASSERT(yrotsih.size(),"Redo performed when the redo-queue was empty");
+  HistoryElement elem = yrotsih.back();
+  yrotsih.pop_back();
+  Action::state_ptr oldState = elem.action->redo(elem.state);
+  history.push_back(HistoryElement(elem.action,oldState));
+}
+
+void ActionHistory::addElement(Action* action,Action::state_ptr state){
+  cout << "Adding action to end of history" << endl;
+  yrotsih.clear();
+  history.push_back(HistoryElement(action,state));
+}
+
+void ActionHistory::clear(){
+  cout << "History cleared" << endl;
+  history.clear();
+  yrotsih.clear();
+}
+
+void ActionHistory::init(){
+  ActionHistory *hist = new ActionHistory();
+  setInstance(hist);
+  new UndoAction(hist);
+  new RedoAction(hist);
+}
+
+CONSTRUCT_SINGLETON(ActionHistory)
+
+/****************** Contained actions *******************/
+ActionHistory::UndoAction::UndoAction(ActionHistory *_hist) :
+  Action("Undo"),
+  hist(_hist)
+{}
+
+ActionHistory::UndoAction::~UndoAction(){}
+
+bool ActionHistory::UndoAction::canUndo(){
+  return false;
+}
+
+bool ActionHistory::UndoAction::shouldUndo(){
+  return false;
+}
+
+Action::state_ptr ActionHistory::UndoAction::performCall(){
+  hist->undoLast();
+  return Action::success;
+}
+
+Action::state_ptr ActionHistory::UndoAction::performUndo(Action::state_ptr){
+  ASSERT(0,"Cannot undo an undo (should use redo for this");
+  return Action::success;
+}
+
+Action::state_ptr ActionHistory::UndoAction::performRedo(Action::state_ptr){
+  ASSERT(0,"Cannot redo an undo");
+  return Action::success;
+}
+
+ActionHistory::RedoAction::RedoAction(ActionHistory *_hist) :
+    Action("Redo"),
+    hist(_hist)
+{}
+
+ActionHistory::RedoAction::~RedoAction(){}
+
+bool ActionHistory::RedoAction::canUndo(){
+  return false;
+}
+
+bool ActionHistory::RedoAction::shouldUndo(){
+  return false;
+}
+
+Action::state_ptr ActionHistory::RedoAction::performCall(){
+  hist->redoLast();
+  return Action::success;
+}
+
+Action::state_ptr ActionHistory::RedoAction::performUndo(Action::state_ptr){
+  ASSERT(0,"Cannot undo a redo (should use undo for this");
+  return Action::success;
+}
+
+Action::state_ptr ActionHistory::RedoAction::performRedo(Action::state_ptr){
+  ASSERT(0,"Cannot redo a redo");
+  return Action::success;
+}
Index: src/Actions/ActionHistory.hpp
===================================================================
--- src/Actions/ActionHistory.hpp	(revision d56640502d4cc2a4450b681ccb0bc442573add28)
+++ src/Actions/ActionHistory.hpp	(revision d56640502d4cc2a4450b681ccb0bc442573add28)
@@ -0,0 +1,85 @@
+/*
+ * ActionHistory.hpp
+ *
+ *  Created on: Mar 25, 2010
+ *      Author: crueger
+ */
+
+#ifndef ACTIONHISTORY_HPP_
+#define ACTIONHISTORY_HPP_
+
+#include "Patterns/Singleton.hpp"
+
+#include <deque>
+
+#include "Actions/Action.hpp"
+
+
+class ActionHistory : public Singleton<ActionHistory,false>
+{
+  friend class Singleton<ActionHistory,false>;
+
+  struct HistoryElement {
+    HistoryElement(Action *_action, Action::state_ptr _state) :
+      action(_action),
+      state(_state)
+    {}
+    Action *action;
+    Action::state_ptr state;
+  };
+
+  class UndoAction : public Action {
+  public:
+    UndoAction(ActionHistory*);
+    virtual ~UndoAction();
+
+    virtual bool canUndo();
+    virtual bool shouldUndo();
+
+  private:
+    virtual Action::state_ptr performCall();
+    virtual Action::state_ptr performUndo(Action::state_ptr);
+    virtual Action::state_ptr performRedo(Action::state_ptr);
+
+    ActionHistory *hist;
+  };
+
+  class RedoAction : public Action {
+  public:
+    RedoAction(ActionHistory*);
+    virtual ~RedoAction();
+
+    virtual bool canUndo();
+    virtual bool shouldUndo();
+
+  private:
+    virtual Action::state_ptr performCall();
+    virtual Action::state_ptr performUndo(Action::state_ptr);
+    virtual Action::state_ptr performRedo(Action::state_ptr);
+
+    ActionHistory *hist;
+  };
+
+public:
+
+  void undoLast();
+  void redoLast();
+
+  void addElement(Action*,Action::state_ptr);
+  void clear();
+protected:
+  ActionHistory();
+  virtual ~ActionHistory();
+private:
+  std::deque<HistoryElement> history;
+  std::deque<HistoryElement> yrotsih;
+
+public:
+  // when constructing the actions we need the Actionregistry Singleton
+  // Singletons need static variables to work, but we cannot access statics
+  // inside a static initialization, so we have this init function that
+  // needs to be called at a non-static point at the start of the program
+  static void init();
+};
+
+#endif /* ACTIONHISTORY_HPP_ */
Index: src/Actions/ActionRegistry.cpp
===================================================================
--- src/Actions/ActionRegistry.cpp	(revision 5b0b98b2ea8b24976731e525dc2aa2811d18dc20)
+++ src/Actions/ActionRegistry.cpp	(revision d56640502d4cc2a4450b681ccb0bc442573add28)
@@ -12,5 +12,5 @@
 
 #include <string>
-#include <cassert>
+#include "Helpers/Assert.hpp"
 #include <iostream>
 
@@ -33,5 +33,5 @@
   map<const string,Action*>::iterator iter;
   iter = actionMap.find(name);
-  assert(iter!=actionMap.end() && "Query for an action not stored in registry");
+  ASSERT(iter!=actionMap.end(),"Query for an action not stored in registry");
   return iter->second;
 }
@@ -40,5 +40,5 @@
   pair<map<const string,Action*>::iterator,bool> ret;
   ret = actionMap.insert(pair<const string,Action*>(action->getName(),action));
-  assert(ret.second && "Two actions with the same name added to registry");
+  ASSERT(ret.second,"Two actions with the same name added to registry");
 }
 
Index: src/Actions/small_actions.cpp
===================================================================
--- src/Actions/small_actions.cpp	(revision 5b0b98b2ea8b24976731e525dc2aa2811d18dc20)
+++ src/Actions/small_actions.cpp	(revision d56640502d4cc2a4450b681ccb0bc442573add28)
@@ -26,5 +26,5 @@
 };
 
-char ChangeMoleculeNameAction::NAME[] = "Change filename of Molecule";
+const char ChangeMoleculeNameAction::NAME[] = "Change filename of Molecule";
 
 ChangeMoleculeNameAction::ChangeMoleculeNameAction(MoleculeListClass *_molecules) :
Index: src/Actions/small_actions.hpp
===================================================================
--- src/Actions/small_actions.hpp	(revision 5b0b98b2ea8b24976731e525dc2aa2811d18dc20)
+++ src/Actions/small_actions.hpp	(revision d56640502d4cc2a4450b681ccb0bc442573add28)
@@ -24,5 +24,5 @@
 
   MoleculeListClass *molecules;
-  static char NAME[];
+  static const char NAME[];
 };
 
