Index: src/Actions/BondAction/BondAddAction.cpp
===================================================================
--- src/Actions/BondAction/BondAddAction.cpp	(revision f63e41b6a0ddb762209a7c4ba24753bc9ceb33a2)
+++ src/Actions/BondAction/BondAddAction.cpp	(revision f63e41b6a0ddb762209a7c4ba24753bc9ceb33a2)
@@ -0,0 +1,126 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2012 University of Bonn. All rights reserved.
+ * 
+ *
+ *   This file is part of MoleCuilder.
+ *
+ *    MoleCuilder is free software: you can redistribute it and/or modify
+ *    it under the terms of the GNU General Public License as published by
+ *    the Free Software Foundation, either version 2 of the License, or
+ *    (at your option) any later version.
+ *
+ *    MoleCuilder is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *    GNU General Public License for more details.
+ *
+ *    You should have received a copy of the GNU General Public License
+ *    along with MoleCuilder.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * BondAddAction.cpp
+ *
+ *  Created on: Nov 12, 2012
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "Atom/atom.hpp"
+#include "Bond/bond.hpp"
+#include "CodePatterns/Assert.hpp"
+#include "CodePatterns/Log.hpp"
+#include "CodePatterns/Verbose.hpp"
+#include "Descriptors/AtomIdDescriptor.hpp"
+#include "World.hpp"
+#include "WorldTime.hpp"
+
+#include <iostream>
+#include <string>
+
+#include "Actions/BondAction/BondAddAction.hpp"
+
+using namespace MoleCuilder;
+
+// and construct the stuff
+#include "BondAddAction.def"
+#include "Action_impl_pre.hpp"
+/** =========== define the function ====================== */
+Action::state_ptr BondAddAction::performCall() {
+  // check preconditions
+  if (World::getInstance().countSelectedAtoms() != 2) {
+    ELOG(1, "Exactly two atoms must be selected for BondAction Add.");
+    return Action::failure;
+  }
+  const std::vector<atom *> selected_atoms = World::getInstance().getSelectedAtoms();
+  if (selected_atoms[0]->IsBondedTo(WorldTime::getTime(), selected_atoms[1])) {
+    ELOG(2, "There already is a bond in between the two selected atoms.");
+    return Action::failure;
+  }
+
+  // create undo
+  BondAddState *UndoState = new BondAddState(selected_atoms[0]->getId(), selected_atoms[1]->getId(), params);
+
+  // execute action
+  selected_atoms[0]->addBond(WorldTime::getTime(), selected_atoms[1]);
+  ASSERT( selected_atoms[0]->IsBondedTo(WorldTime::getTime(), selected_atoms[1]),
+      "BondAddAction::performCall() - adding bond in between "
+      +toString(*selected_atoms[0])+" and "+toString(*selected_atoms[1])+" failed.");
+
+  return Action::state_ptr(UndoState);
+}
+
+Action::state_ptr BondAddAction::performUndo(Action::state_ptr _state) {
+  BondAddState *state = assert_cast<BondAddState*>(_state.get());
+
+  // check whether bond already existed
+  atom * const first = World::getInstance().getAtom(AtomById(state->firstId));
+  atom * const second = World::getInstance().getAtom(AtomById(state->secondId));
+  ASSERT((first != NULL) && (second != NULL),
+      "BondAddAction::performUndo() - at least one of the ids "
+      +toString(state->firstId)+" or "+toString(state->secondId)+" is not present.");
+  if (first->IsBondedTo(WorldTime::getTime(), second)) {
+    first->removeBond(WorldTime::getTime(), second);
+  } else {
+    ELOG(2, "There is no bond in between "+toString(state->firstId)
+        +" and "+toString(state->secondId)+".");
+  }
+
+  return Action::state_ptr(_state);
+}
+
+Action::state_ptr BondAddAction::performRedo(Action::state_ptr _state){
+  BondAddState *state = assert_cast<BondAddState*>(_state.get());
+
+  // check whether bond already existed
+  atom * const first = World::getInstance().getAtom(AtomById(state->firstId));
+  atom * const second = World::getInstance().getAtom(AtomById(state->secondId));
+  ASSERT((first != NULL) && (second != NULL),
+      "BondAddAction::performRedo() - at least one of the ids "
+      +toString(state->firstId)+" or "+toString(state->secondId)+" is not present.");
+  if (!first->IsBondedTo(WorldTime::getTime(), second)) {
+    first->addBond(WorldTime::getTime(), second);
+  } else {
+    ELOG(2, "There is already a bond in between "+toString(state->firstId)
+        +" and "+toString(state->secondId)+".");
+  }
+
+  return Action::state_ptr(_state);
+}
+
+bool BondAddAction::canUndo() {
+  return true;
+}
+
+bool BondAddAction::shouldUndo() {
+  return true;
+}
+/** =========== end of function ====================== */
Index: src/Actions/BondAction/BondAddAction.def
===================================================================
--- src/Actions/BondAction/BondAddAction.def	(revision f63e41b6a0ddb762209a7c4ba24753bc9ceb33a2)
+++ src/Actions/BondAction/BondAddAction.def	(revision f63e41b6a0ddb762209a7c4ba24753bc9ceb33a2)
@@ -0,0 +1,34 @@
+/*
+ * BondAddAction.def
+ *
+ *  Created on: Nov 14, 2012
+ *      Author: heber
+ */
+
+// all includes and forward declarations necessary for non-integral types below
+#include "types.hpp"
+
+// i.e. there is an integer with variable name Z that can be found in
+// ValueStorage by the token "Z" -> first column: int, Z, "Z"
+// "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value
+//#define paramtypes (const element *)(BoxVector) TODO: use a validator
+#undef paramtypes
+#undef paramtokens
+#undef paramdescriptions
+#undef paramreferences
+#undef paramdefaults
+#undef paramvalids
+
+#define statetypes (atomId_t)(atomId_t)
+#define statereferences (firstId)(secondId)
+
+// some defines for all the names, you may use ACTION, STATE and PARAMS
+#define CATEGORY Bond
+#define MENUNAME "bond"
+#define MENUPOSITION 1
+#define ACTIONNAME Add
+#define TOKEN "add-bond"
+
+// finally the information stored in the ActionTrait specialization
+#define DESCRIPTION "add bond in between two selected atoms"
+#undef SHORTFORM
Index: src/Actions/BondAction/BondAddAction.hpp
===================================================================
--- src/Actions/BondAction/BondAddAction.hpp	(revision f63e41b6a0ddb762209a7c4ba24753bc9ceb33a2)
+++ src/Actions/BondAction/BondAddAction.hpp	(revision f63e41b6a0ddb762209a7c4ba24753bc9ceb33a2)
@@ -0,0 +1,22 @@
+/*
+ * BondAddAction.hpp
+ *
+ *  Created on: Nov 14, 2012
+ *      Author: heber
+ */
+
+#ifndef BONDADDACTION_HPP_
+#define BONDADDACTION_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include "Actions/Action.hpp"
+
+#include "BondAddAction.def"
+#include "Action_impl_header.hpp"
+
+#endif /* BONDADDACTION_HPP_ */
Index: src/Actions/BondAction/BondRemoveAction.cpp
===================================================================
--- src/Actions/BondAction/BondRemoveAction.cpp	(revision f63e41b6a0ddb762209a7c4ba24753bc9ceb33a2)
+++ src/Actions/BondAction/BondRemoveAction.cpp	(revision f63e41b6a0ddb762209a7c4ba24753bc9ceb33a2)
@@ -0,0 +1,126 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2012 University of Bonn. All rights reserved.
+ * 
+ *
+ *   This file is part of MoleCuilder.
+ *
+ *    MoleCuilder is free software: you can redistribute it and/or modify
+ *    it under the terms of the GNU General Public License as published by
+ *    the Free Software Foundation, either version 2 of the License, or
+ *    (at your option) any later version.
+ *
+ *    MoleCuilder is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *    GNU General Public License for more details.
+ *
+ *    You should have received a copy of the GNU General Public License
+ *    along with MoleCuilder.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * BondRemoveAction.cpp
+ *
+ *  Created on: Nov 14, 2012
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "Atom/atom.hpp"
+#include "Bond/bond.hpp"
+#include "CodePatterns/Assert.hpp"
+#include "CodePatterns/Log.hpp"
+#include "CodePatterns/Verbose.hpp"
+#include "Descriptors/AtomIdDescriptor.hpp"
+#include "World.hpp"
+#include "WorldTime.hpp"
+
+#include <iostream>
+#include <string>
+
+#include "Actions/BondAction/BondRemoveAction.hpp"
+
+using namespace MoleCuilder;
+
+// and construct the stuff
+#include "BondRemoveAction.def"
+#include "Action_impl_pre.hpp"
+/** =========== define the function ====================== */
+Action::state_ptr BondRemoveAction::performCall() {
+  // check preconditions
+  if (World::getInstance().countSelectedAtoms() != 2) {
+    ELOG(1, "Exactly two atoms must be selected for BondAction Remove.");
+    return Action::failure;
+  }
+  const std::vector<atom *> selected_atoms = World::getInstance().getSelectedAtoms();
+  if (!selected_atoms[0]->IsBondedTo(WorldTime::getTime(), selected_atoms[1])) {
+    ELOG(2, "There is no bond in between the two selected atoms.");
+    return Action::failure;
+  }
+
+  // create undo
+  BondRemoveState *UndoState = new BondRemoveState(selected_atoms[0]->getId(), selected_atoms[1]->getId(), params);
+
+  // execute action
+  selected_atoms[0]->removeBond(WorldTime::getTime(), selected_atoms[1]);
+  ASSERT( !selected_atoms[0]->IsBondedTo(WorldTime::getTime(), selected_atoms[1]),
+      "BondRemoveAction::performCall() - removing bond in between "
+      +toString(*selected_atoms[0])+" and "+toString(*selected_atoms[1])+" failed.");
+
+  return Action::state_ptr(UndoState);
+}
+
+Action::state_ptr BondRemoveAction::performUndo(Action::state_ptr _state) {
+  BondRemoveState *state = assert_cast<BondRemoveState*>(_state.get());
+
+  // check whether bond already existed
+  atom * const first = World::getInstance().getAtom(AtomById(state->firstId));
+  atom * const second = World::getInstance().getAtom(AtomById(state->secondId));
+  ASSERT((first != NULL) && (second != NULL),
+      "BondRemoveAction::performUndo() - at least one of the ids "
+      +toString(state->firstId)+" or "+toString(state->secondId)+" is not present.");
+  if (!first->IsBondedTo(WorldTime::getTime(), second)) {
+    first->addBond(WorldTime::getTime(), second);
+  } else {
+    ELOG(2, "There is already a bond in between "+toString(state->firstId)
+        +" and "+toString(state->secondId)+".");
+  }
+
+  return Action::state_ptr(_state);
+}
+
+Action::state_ptr BondRemoveAction::performRedo(Action::state_ptr _state){
+  BondRemoveState *state = assert_cast<BondRemoveState*>(_state.get());
+
+  // check whether bond already existed
+  atom * const first = World::getInstance().getAtom(AtomById(state->firstId));
+  atom * const second = World::getInstance().getAtom(AtomById(state->secondId));
+  ASSERT((first != NULL) && (second != NULL),
+      "BondRemoveAction::performRedo() - at least one of the ids "
+      +toString(state->firstId)+" or "+toString(state->secondId)+" is not present.");
+  if (first->IsBondedTo(WorldTime::getTime(), second)) {
+    first->removeBond(WorldTime::getTime(), second);
+  } else {
+    ELOG(2, "There is no bond in between "+toString(state->firstId)
+        +" and "+toString(state->secondId)+".");
+  }
+
+  return Action::state_ptr(_state);
+}
+
+bool BondRemoveAction::canUndo() {
+  return true;
+}
+
+bool BondRemoveAction::shouldUndo() {
+  return true;
+}
+/** =========== end of function ====================== */
Index: src/Actions/BondAction/BondRemoveAction.def
===================================================================
--- src/Actions/BondAction/BondRemoveAction.def	(revision f63e41b6a0ddb762209a7c4ba24753bc9ceb33a2)
+++ src/Actions/BondAction/BondRemoveAction.def	(revision f63e41b6a0ddb762209a7c4ba24753bc9ceb33a2)
@@ -0,0 +1,33 @@
+/*
+ * BondRemoveAction.def
+ *
+ *  Created on: Nov 14, 2012
+ *      Author: heber
+ */
+
+// all includes and forward declarations necessary for non-integral types below
+
+// i.e. there is an integer with variable name Z that can be found in
+// ValueStorage by the token "Z" -> first column: int, Z, "Z"
+// "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value
+//#define paramtypes (const element *)(BoxVector) TODO: use a validator
+#undef paramtypes
+#undef paramtokens
+#undef paramdescriptions
+#undef paramreferences
+#undef paramdefaults
+#undef paramvalids
+
+#define statetypes (atomId_t)(atomId_t)
+#define statereferences (firstId)(secondId)
+
+// some defines for all the names, you may use ACTION, STATE and PARAMS
+#define CATEGORY Bond
+#define MENUNAME "bond"
+#define MENUPOSITION 2
+#define ACTIONNAME Remove
+#define TOKEN "remove-bond"
+
+// finally the information stored in the ActionTrait specialization
+#define DESCRIPTION "remove the bond in between two selected atoms"
+#undef SHORTFORM
Index: src/Actions/BondAction/BondRemoveAction.hpp
===================================================================
--- src/Actions/BondAction/BondRemoveAction.hpp	(revision f63e41b6a0ddb762209a7c4ba24753bc9ceb33a2)
+++ src/Actions/BondAction/BondRemoveAction.hpp	(revision f63e41b6a0ddb762209a7c4ba24753bc9ceb33a2)
@@ -0,0 +1,22 @@
+/*
+ * BondRemoveAction.hpp
+ *
+ *  Created on: Nov 14, 2012
+ *      Author: heber
+ */
+
+#ifndef BONDREMOVEACTION_HPP_
+#define BONDREMOVEACTION_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include "Actions/Action.hpp"
+
+#include "BondRemoveAction.def"
+#include "Action_impl_header.hpp"
+
+#endif /* BONDREMOVEACTION_HPP_ */
