Index: src/IdPool.hpp
===================================================================
--- src/IdPool.hpp	(revision 3867a77b0b871f3d876032f6535a5d1768b84cd3)
+++ src/IdPool.hpp	(revision b97a60ab241f2ecfff0d2258ecdd13f84f8a4f98)
@@ -26,7 +26,11 @@
  * that stores the id).
  *
+ * Note that the external class \a idpolicy decides upon how the next id is
+ * produced, \sa IdPool_policy.hpp.
  */
-template <class T>
-class IdPool {
+template <class T, class idpolicy>
+class IdPool : public idpolicy {
+  // when trait is not of correct type this will produce an error
+  typedef typename idpolicy::is_IdPool_policy check_for_IdPool_trait;
 public:
   /** Constructor for class IdPool.
@@ -43,10 +47,4 @@
   ~IdPool();
 
-  /** Returns the next available id.
-   *
-   * @return free id that is reserved
-   */
-  T getNextId();
-
   /** Reserves a specific \a id.
    *
@@ -61,4 +59,10 @@
    */
   void releaseId(T id);
+
+  /** Returns the next available id.
+   *
+   * @return free id that is reserved
+   */
+  T getNextId();
 
 private:
Index: src/IdPool_impl.hpp
===================================================================
--- src/IdPool_impl.hpp	(revision 3867a77b0b871f3d876032f6535a5d1768b84cd3)
+++ src/IdPool_impl.hpp	(revision b97a60ab241f2ecfff0d2258ecdd13f84f8a4f98)
@@ -18,6 +18,6 @@
 #include "CodePatterns/Log.hpp"
 
-template <class T>
-IdPool<T>::IdPool(const T _currId, const unsigned int _max_skips, const unsigned int _max_size) :
+template <class T, class idpolicy>
+IdPool<T,idpolicy>::IdPool(const T _currId, const unsigned int _max_skips, const unsigned int _max_size) :
   lastAction(NoAction),
   currId(_currId),
@@ -28,29 +28,17 @@
 {}
 
-template <class T>
-IdPool<T>::~IdPool()
+template <class T, class idpolicy>
+IdPool<T,idpolicy>::~IdPool()
 {}
 
-template <class T>
-T IdPool<T>::getNextId()
+template <class T, class idpolicy>
+T IdPool<T,idpolicy>::getNextId()
 {
   setLastAction(reserve);
-  // try to find an Id in the pool;
-  if(!pool.empty()) {
-    typename IdPool_t::iterator iter=pool.begin();
-    T id = iter->first;
-    range<T> newRange = makeRange(id+1,iter->last);
-    // we wont use this iterator anymore, so we don't care about invalidating
-    pool.erase(iter);
-    if(newRange.first<newRange.last)
-      pool.insert(newRange);
-    return id;
-  }
-  // Nothing in the pool... we are out of luck
-  return currId++;
+  return idpolicy::getNextId_impl(pool, currId);
 }
 
-template <class T>
-void IdPool<T>::releaseId(T id)
+template <class T, class idpolicy>
+void IdPool<T,idpolicy>::releaseId(T id)
 {
   setLastAction(release);
@@ -59,6 +47,6 @@
 }
 
-template <class T>
-bool IdPool<T>::reserveId(T id)
+template <class T, class idpolicy>
+bool IdPool<T,idpolicy>::reserveId(T id)
 {
   setLastAction(reserve);
@@ -100,6 +88,6 @@
 }
 
-template <class T>
-void IdPool<T>::defragIdPool()
+template <class T, class idpolicy>
+void IdPool<T,idpolicy>::defragIdPool()
 {
   // check if the situation is bad enough to make defragging neccessary
@@ -142,10 +130,10 @@
  * at a chosen place.
  */
-#define CONSTRUCT_IDPOOL(name) \
-    template name IdPool< name >::getNextId(); \
-    template bool IdPool< name >::reserveId( name ); \
-    template void IdPool< name >::releaseId( name ); \
-    template void IdPool< name >::setLastAction(const enum Actions _action); \
-    template void IdPool< name >::defragIdPool() ;
+#define CONSTRUCT_IDPOOL(name, idpolicy) \
+    template name IdPool< name, idpolicy >::getNextId(); \
+    template bool IdPool< name, idpolicy >::reserveId( name ); \
+    template void IdPool< name, idpolicy >::releaseId( name ); \
+    template void IdPool< name, idpolicy >::setLastAction(const enum Actions _action); \
+    template void IdPool< name, idpolicy >::defragIdPool() ;
 
 #endif /* IDPOOL_IMPL_HPP_ */
Index: src/IdPool_policy.hpp
===================================================================
--- src/IdPool_policy.hpp	(revision b97a60ab241f2ecfff0d2258ecdd13f84f8a4f98)
+++ src/IdPool_policy.hpp	(revision b97a60ab241f2ecfff0d2258ecdd13f84f8a4f98)
@@ -0,0 +1,50 @@
+/*
+ * IdPool_policy.hpp
+ *
+ *  Created on: Feb 7, 2012
+ *      Author: heber
+ */
+
+#ifndef IDPOOL_POLICY_HPP_
+#define IDPOOL_POLICY_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/Range.hpp"
+
+class uniqueId{
+public:
+  typedef void is_IdPool_policy;
+  template <class T> T getNextId_impl(std::set<range<T> > &pool, T&currId)
+  {
+    return currId++;
+  }
+};
+
+class continuousId{
+public:
+  typedef void is_IdPool_policy;
+
+  template <class T> T getNextId_impl(std::set<range<T> > &pool, T&currId)
+  {
+    // try to find an Id in the pool;
+    if(!pool.empty()) {
+      typename std::set<range<T> >::iterator iter=pool.begin();
+      T id = iter->first;
+      range<T> newRange = makeRange(id+1,iter->last);
+      // we wont use this iterator anymore, so we don't care about invalidating
+      pool.erase(iter);
+      if(newRange.first<newRange.last)
+        pool.insert(newRange);
+      return id;
+    }
+    // Nothing in the pool... we are out of luck
+    return currId++;
+  }
+};
+
+
+#endif /* IDPOOL_POLICY_HPP_ */
Index: src/World.cpp
===================================================================
--- src/World.cpp	(revision 3867a77b0b871f3d876032f6535a5d1768b84cd3)
+++ src/World.cpp	(revision b97a60ab241f2ecfff0d2258ecdd13f84f8a4f98)
@@ -693,5 +693,6 @@
 
 // moleculeId_t und atomId_t sind gleicher Basistyp, deswegen nur einen von beiden konstruieren
-CONSTRUCT_IDPOOL(moleculeId_t)
+CONSTRUCT_IDPOOL(atomId_t, uniqueId)
+CONSTRUCT_IDPOOL(moleculeId_t, continuousId)
 
 CONSTRUCT_SINGLETON(World)
Index: src/World.hpp
===================================================================
--- src/World.hpp	(revision 3867a77b0b871f3d876032f6535a5d1768b84cd3)
+++ src/World.hpp	(revision b97a60ab241f2ecfff0d2258ecdd13f84f8a4f98)
@@ -32,4 +32,5 @@
 #include "CodePatterns/Observer/ObservedContainer.hpp"
 #include "CodePatterns/Range.hpp"
+#include "IdPool_policy.hpp"
 #include "IdPool.hpp"
 #include "LinkedCell/LinkedCell_View.hpp"
@@ -465,5 +466,5 @@
    * The pool contains ranges of free ids in the form [bottom,top).
    */
-  IdPool<atomId_t> atomIdPool;
+  IdPool<atomId_t, uniqueId> atomIdPool;
 
   MoleculeSet molecules;
@@ -474,5 +475,5 @@
    * The pool contains ranges of free ids in the form [bottom,top).
    */
-  IdPool<moleculeId_t> moleculeIdPool;
+  IdPool<moleculeId_t, continuousId> moleculeIdPool;
 
 private:
Index: src/documentation/constructs/world.dox
===================================================================
--- src/documentation/constructs/world.dox	(revision 3867a77b0b871f3d876032f6535a5d1768b84cd3)
+++ src/documentation/constructs/world.dox	(revision b97a60ab241f2ecfff0d2258ecdd13f84f8a4f98)
@@ -112,13 +112,25 @@
  * \paragraph world-internals-notes-idpool
  *
- * The World has an idpool to manage the ids of atoms and molecules, i.e. such
- * that they are:
- * -# unique
- * -# not loosely spread over the whole range of possible, but tightly packed
+ * The World has an idpool to manage the ids of atoms and molecules. The IdPool
+ * inherits policies, such that ids are given in a unique (uniqueId) or
+ * continuous (continousId) fashion.
+ * The id of an atom is the sole identifier for which we can guarantee
+ * uniqueness. Due to undo and redo actions the memory address is not a good
+ * identifier. This is however required for FormatParser's that need
+ * to store their additionalAtomData at program exit and have to safely identify
+ * the data with its atoms. This can only be accomplished via the id. Hence,
+ * we use the unique policy there.
+ * The id of a molecule however is more of a convenience, to distinguish it from
+ * the currently present others. A molecule may change very often and it is also
+ * a compound structure that may change slightly (when a new bond to another atom
+ * occurs). Thus, the concept of the id as a unique identifier does not make
+ * sense. Hence, we use the continuous policy here.
  *
- * For the latter to work we have a class IdPool that manages the ids and
+ * Note that IdPool::reserveId() has to ascertain that we may sweep through ids
+ * available to (undone) AtomRemoveAction or (redone) AtomAddAction in sublinear
+ * time. For this to work we have a class IdPool that manages the ids and
  * defragments the pool from time to time by combining ranges of released ids.
  *
- * \date 2011-10-31
+ * \date 2012-01-06
  *
  */
