Index: src/Descriptors/AtomDescriptor.cpp
===================================================================
--- src/Descriptors/AtomDescriptor.cpp	(revision d1c5e2c1e093b9756002d8db06bda62bdb2c9057)
+++ src/Descriptors/AtomDescriptor.cpp	(revision 7a1ce5357081767198c4e7f7e867143f5d19dda0)
@@ -6,10 +6,14 @@
  */
 
-#include "AtomDescriptor.hpp"
+#include "Descriptors/AtomDescriptor.hpp"
+#include "Descriptors/AtomDescriptor_impl.hpp"
 
 #include "World.hpp"
 
+#include "atom.hpp"
+
 #include <boost/bind.hpp>
 #include <cassert>
+#include <iostream>
 
 using namespace std;
@@ -18,140 +22,154 @@
 typedef atoms_t::iterator atoms_iter_t;
 
-AtomDescriptor::AtomDescriptor()
+/************************ Forwarding object **************************************/
+
+
+AtomDescriptor::AtomDescriptor(impl_ptr _impl) :
+    impl(_impl)
+{}
+
+AtomDescriptor::AtomDescriptor(const AtomDescriptor& src) :
+    impl(src.get_impl())
+{}
+
+AtomDescriptor::~AtomDescriptor()
+{}
+
+AtomDescriptor& AtomDescriptor::operator=(AtomDescriptor &src){
+  if(&src!=this) {
+    impl=src.get_impl();
+  }
+  return *this;
+}
+
+atom* AtomDescriptor::find(){
+  return impl->find();
+}
+
+std::vector<atom*> AtomDescriptor::findAll(){
+  return impl->findAll();
+}
+
+AtomDescriptor::impl_ptr AtomDescriptor::get_impl() const{
+  return impl;
+}
+
+
+
+
+/**************************** implementation ********************/
+
+AtomDescriptor_impl::AtomDescriptor_impl()
 {
 }
 
-AtomDescriptor::AtomDescriptor(const AtomDescriptor &desc) {
-}
-
-AtomDescriptor::~AtomDescriptor()
+AtomDescriptor_impl::~AtomDescriptor_impl()
 {
 }
 
-
-atoms_t& AtomDescriptor::getAtoms(){
+atoms_t& AtomDescriptor_impl::getAtoms(){
   return World::get()->atoms;
 }
 
-atom* AtomDescriptor::find() {
+atom* AtomDescriptor_impl::find() {
   atoms_t atoms = getAtoms();
-  atoms_iter_t res = find_if(atoms.begin(),atoms.end(),boost::bind(&AtomDescriptor::predicate,this,_1));
+  atoms_iter_t res = find_if(atoms.begin(),atoms.end(),boost::bind(&AtomDescriptor_impl::predicate,this,_1));
   return (res!=atoms.end())?((*res).second):0;
 }
 
-vector<atom*> AtomDescriptor::findAll() {
+vector<atom*> AtomDescriptor_impl::findAll() {
   vector<atom*> res;
   atoms_t atoms = getAtoms();
   atoms_iter_t iter;
   for(iter=atoms.begin();iter!=atoms.end();++iter) {
-    if(predicate(*iter))
+    if(predicate(*iter)){
       res.push_back((*iter).second);
+    }
   }
+  return res;
 }
 
-// stuff for operators
+/************************** Universe and Emptyset *****************/
+
+AtomAllDescriptor_impl::AtomAllDescriptor_impl()
+{}
+
+AtomAllDescriptor_impl::~AtomAllDescriptor_impl()
+{}
+
+bool AtomAllDescriptor_impl::predicate(std::pair<int,atom*>){
+  return true;
+}
+
+AtomDescriptor AllAtoms(){
+  return AtomDescriptor(AtomDescriptor::impl_ptr(new AtomAllDescriptor_impl));
+}
+
+AtomNoneDescriptor_impl::AtomNoneDescriptor_impl()
+{}
+
+AtomNoneDescriptor_impl::~AtomNoneDescriptor_impl()
+{}
+
+bool AtomNoneDescriptor_impl::predicate(std::pair<int,atom*>){
+  return false;
+}
+
+AtomDescriptor NoAtoms(){
+  return AtomDescriptor(AtomDescriptor::impl_ptr(new AtomNoneDescriptor_impl));
+}
+
+/************************** Operator stuff ************************/
 
 // AND
-AtomAndDescriptor::AtomAndDescriptor(const AtomDescriptor &_lhs,const AtomDescriptor &_rhs){
-  lhs=_lhs.clone();
-  rhs=_rhs.clone();
-}
+AtomAndDescriptor_impl::AtomAndDescriptor_impl(AtomDescriptor::impl_ptr _lhs, AtomDescriptor::impl_ptr _rhs) :
+    lhs(_lhs), rhs(_rhs)
+{}
 
-AtomAndDescriptor::AtomAndDescriptor(const AtomAndDescriptor &_desc)
-{
-  // the copy constructor needs it's parameter as const to work,
-  // however we need to be able to transfer the ownership of the pointers
-  // to the new method to avoid another cloning.
-  //
-  // the only place where the copy constructor is used for these classes,
-  // is when returning a temporary.
-  // this is one of the very rare cases when const_cast makes sense
-  AtomAndDescriptor &desc = const_cast<AtomAndDescriptor&>(_desc);
-  lhs = desc.lhs;
-  rhs = desc.rhs;
-}
+AtomAndDescriptor_impl::~AtomAndDescriptor_impl()
+{}
 
-AtomAndDescriptor::~AtomAndDescriptor(){
-}
-
-bool AtomAndDescriptor::predicate(std::pair<int,atom*> atom){
+bool AtomAndDescriptor_impl::predicate(std::pair<int,atom*> atom){
   return lhs->predicate(atom) && rhs->predicate(atom);
 }
-
-AtomAndDescriptor::desc_ptr AtomAndDescriptor::clone() const{
-  return desc_ptr(new AtomAndDescriptor(*lhs,*rhs));
-}
-
-AtomAndDescriptor operator&&(const AtomDescriptor &lhs, const AtomDescriptor &rhs){
-  return AtomAndDescriptor(lhs,rhs);
+AtomDescriptor operator&&(const AtomDescriptor &lhs, const AtomDescriptor &rhs){
+  AtomDescriptor::impl_ptr newImpl = AtomDescriptor::impl_ptr(new AtomAndDescriptor_impl(lhs.get_impl(),rhs.get_impl()));
+  return AtomDescriptor(newImpl);
 }
 
 // OR
+AtomOrDescriptor_impl::AtomOrDescriptor_impl(AtomDescriptor::impl_ptr _lhs ,AtomDescriptor::impl_ptr _rhs) :
+    lhs(_lhs), rhs(_rhs)
+{}
 
-AtomOrDescriptor::AtomOrDescriptor(const AtomDescriptor &_lhs,const AtomDescriptor &_rhs){
-  lhs=_lhs.clone();
-  rhs=_rhs.clone();
+AtomOrDescriptor_impl::~AtomOrDescriptor_impl(){
 }
 
-AtomOrDescriptor::AtomOrDescriptor(const AtomOrDescriptor &_desc)
-{
-  // the copy constructor needs it's parameter as const to work,
-  // however we need to be able to transfer the ownership of the pointers
-  // to the new method to avoid another cloning.
-  //
-  // the only place where the copy constructor is used for these classes,
-  // is when returning a temporary.
-  // this is one of the very rare cases when const_cast makes sense
-  AtomOrDescriptor &desc = const_cast<AtomOrDescriptor&>(_desc);
-  lhs = desc.lhs;
-  rhs = desc.rhs;
-}
-
-AtomOrDescriptor::~AtomOrDescriptor(){
-}
-
-bool AtomOrDescriptor::predicate(std::pair<int,atom*> atom){
+bool AtomOrDescriptor_impl::predicate(std::pair<int,atom*> atom){
   return lhs->predicate(atom) || rhs->predicate(atom);
 }
 
-AtomAndDescriptor::desc_ptr AtomOrDescriptor::clone() const{
-  return desc_ptr(new AtomOrDescriptor(*lhs,*rhs));
-}
-
-AtomOrDescriptor  operator||(const AtomDescriptor &lhs, const AtomDescriptor &rhs){
-  return AtomOrDescriptor(lhs,rhs);
+AtomDescriptor  operator||(const AtomDescriptor &lhs, const AtomDescriptor &rhs){
+  AtomDescriptor::impl_ptr newImpl = AtomDescriptor::impl_ptr(new AtomOrDescriptor_impl(lhs.get_impl(),rhs.get_impl()));
+  return AtomDescriptor(newImpl);
 }
 
 // NOT
 
-AtomNotDescriptor::AtomNotDescriptor(const AtomDescriptor &_arg){
-  arg = _arg.clone();
-}
+AtomNotDescriptor_impl::AtomNotDescriptor_impl(AtomDescriptor::impl_ptr _arg) :
+    arg(_arg)
+{}
 
-AtomNotDescriptor::AtomNotDescriptor(const AtomNotDescriptor &_desc) {
-  // the copy constructor needs it's parameter as const to work,
-  // however we need to be able to transfer the ownership of the pointers
-  // to the new method to avoid another cloning.
-  //
-  // the only place where the copy constructor is used for these classes,
-  // is when returning a temporary.
-  // this is one of the very rare cases when const_cast makes sense
-  AtomNotDescriptor &desc = const_cast<AtomNotDescriptor&>(_desc);
-  arg = desc.arg;
-}
 
-AtomNotDescriptor::~AtomNotDescriptor()
+AtomNotDescriptor_impl::~AtomNotDescriptor_impl()
 {
 }
 
-bool AtomNotDescriptor::predicate(std::pair<int,atom*> atom){
+bool AtomNotDescriptor_impl::predicate(std::pair<int,atom*> atom){
  return !(arg->predicate(atom));
 }
 
-AtomAndDescriptor::desc_ptr AtomNotDescriptor::clone() const{
-  return desc_ptr(new AtomNotDescriptor(*arg));
+AtomDescriptor operator!(const AtomDescriptor &arg){
+  AtomDescriptor::impl_ptr newImpl = AtomDescriptor::impl_ptr(new AtomNotDescriptor_impl(arg.get_impl()));
+  return AtomDescriptor(newImpl);
 }
-
-AtomNotDescriptor operator!(const AtomDescriptor &arg){
-  return AtomNotDescriptor(arg);
-}
Index: src/Descriptors/AtomDescriptor.hpp
===================================================================
--- src/Descriptors/AtomDescriptor.hpp	(revision d1c5e2c1e093b9756002d8db06bda62bdb2c9057)
+++ src/Descriptors/AtomDescriptor.hpp	(revision 7a1ce5357081767198c4e7f7e867143f5d19dda0)
@@ -17,84 +17,41 @@
 class atom;
 
-class AtomDescriptor
-{
+// internal implementation, allows assignment, copying etc
+class AtomDescripter_impl;
+
+class AtomDescriptor {
+  friend atom* World::getAtom(AtomDescriptor descriptor);
+  friend std::vector<atom*> World::getAllAtoms(AtomDescriptor descriptor);
+
+  friend AtomDescriptor operator&&(const AtomDescriptor &lhs, const AtomDescriptor &rhs);
+  friend AtomDescriptor operator||(const AtomDescriptor &lhs, const AtomDescriptor &rhs);
+  friend AtomDescriptor operator!(const AtomDescriptor &arg);
+
 public:
+  typedef boost::shared_ptr<AtomDescriptor_impl> impl_ptr;
 
-  typedef boost::shared_ptr<AtomDescriptor> desc_ptr;
+  AtomDescriptor(impl_ptr);
+  AtomDescriptor(const AtomDescriptor&);
+  ~AtomDescriptor();
 
-  friend atom* World::getAtom(AtomDescriptor& descriptor);
-  friend std::vector<atom*> World::getAllAtoms(AtomDescriptor& descriptor);
-
-  AtomDescriptor();
-  virtual ~AtomDescriptor();
-  AtomDescriptor(const AtomDescriptor&);
-
-  virtual bool predicate(std::pair<int,atom*>)=0;
-  // clone is only used internally to generate operators
-  virtual desc_ptr clone() const=0;
+  AtomDescriptor &operator=(AtomDescriptor &);
 
 protected:
-  virtual atom* find();
-  virtual std::vector<atom*> findAll();
-  std::map<int,atom*>& getAtoms();
+  atom* find();
+  std::vector<atom*> findAll();
+  impl_ptr get_impl() const;
+
+private:
+  impl_ptr impl;
 };
 
-class AtomAndDescriptor : public AtomDescriptor
-{
-  friend AtomAndDescriptor operator&&(const AtomDescriptor &lhs, const AtomDescriptor &rhs);
-public:
-  AtomAndDescriptor(const AtomAndDescriptor&);
-  ~AtomAndDescriptor();
-
-  virtual desc_ptr clone() const;
-  virtual bool predicate(std::pair<int,atom*>);
-
-private:
-  desc_ptr lhs;
-  desc_ptr rhs;
-
-  // private constructor to enforce construction through operators
-  AtomAndDescriptor(const AtomDescriptor &_lhs, const AtomDescriptor &_rhs);
-};
-
-class AtomOrDescriptor : public AtomDescriptor
-{
-  friend AtomOrDescriptor  operator||(const AtomDescriptor &lhs, const AtomDescriptor &rhs);
-public:
-  AtomOrDescriptor(const AtomOrDescriptor &);
-  ~AtomOrDescriptor();
-
-  virtual desc_ptr clone() const;
-  virtual bool predicate(std::pair<int,atom*>);
-
-private:
-  desc_ptr lhs;
-  desc_ptr rhs;
-
-  // private constructor to enforce construction through operators
-  AtomOrDescriptor(const AtomDescriptor &_lhs, const AtomDescriptor &_rhs);
-};
-
-class AtomNotDescriptor : public AtomDescriptor
-{
-  friend AtomNotDescriptor operator!(const AtomDescriptor &arg);
-public:
-  AtomNotDescriptor(const AtomNotDescriptor &);
-  ~AtomNotDescriptor();
-
-  virtual desc_ptr clone() const;
-  virtual bool predicate(std::pair<int,atom*>);
-
-private:
-  desc_ptr arg;
-
-  // protected constructor to enforce construction through operators
-  AtomNotDescriptor(const AtomDescriptor &_arg);
-};
+// Functions to construct actual descriptors
+AtomDescriptor AllAtoms();
+AtomDescriptor NoAtoms();
 
 // no true short circuit, but the test of the second descriptor wont be done
-AtomAndDescriptor operator&&(const AtomDescriptor &lhs, const AtomDescriptor &rhs);
-AtomOrDescriptor  operator||(const AtomDescriptor &lhs, const AtomDescriptor &rhs);
-AtomNotDescriptor operator!(const AtomDescriptor &arg);
+AtomDescriptor operator&&(const AtomDescriptor &lhs, const AtomDescriptor &rhs);
+AtomDescriptor operator||(const AtomDescriptor &lhs, const AtomDescriptor &rhs);
+AtomDescriptor operator!(const AtomDescriptor &arg);
 
 #endif /* ATOMDESCRIPTOR_HPP_ */
Index: src/Descriptors/AtomDescriptor_impl.hpp
===================================================================
--- src/Descriptors/AtomDescriptor_impl.hpp	(revision 7a1ce5357081767198c4e7f7e867143f5d19dda0)
+++ src/Descriptors/AtomDescriptor_impl.hpp	(revision 7a1ce5357081767198c4e7f7e867143f5d19dda0)
@@ -0,0 +1,73 @@
+#include "Descriptors/AtomDescriptor.hpp"
+
+/************************ Declarations of implementation Objects ************************/
+
+class AtomDescriptor_impl
+{
+  friend class AtomDescriptor;
+public:
+
+  AtomDescriptor_impl();
+  virtual ~AtomDescriptor_impl();
+
+  virtual bool predicate(std::pair<int,atom*>)=0;
+
+protected:
+  virtual atom* find();
+  virtual std::vector<atom*> findAll();
+  std::map<int,atom*>& getAtoms();
+};
+
+/************************** Universe and Emptyset *****************/
+
+class AtomAllDescriptor_impl : public AtomDescriptor_impl {
+public:
+  AtomAllDescriptor_impl();
+  virtual ~AtomAllDescriptor_impl();
+  virtual bool predicate(std::pair<int,atom*>);
+};
+
+class AtomNoneDescriptor_impl : public AtomDescriptor_impl {
+public:
+  AtomNoneDescriptor_impl();
+  virtual ~AtomNoneDescriptor_impl();
+  virtual bool predicate(std::pair<int,atom*>);
+};
+
+/************************** Operator stuff ************************/
+
+class AtomAndDescriptor_impl : public AtomDescriptor_impl
+{
+public:
+  AtomAndDescriptor_impl(AtomDescriptor::impl_ptr _lhs, AtomDescriptor::impl_ptr _rhs);
+  ~AtomAndDescriptor_impl();
+  virtual bool predicate(std::pair<int,atom*>);
+
+private:
+  AtomDescriptor::impl_ptr lhs;
+  AtomDescriptor::impl_ptr rhs;
+};
+
+class AtomOrDescriptor_impl : public AtomDescriptor_impl
+{
+public:
+  AtomOrDescriptor_impl(AtomDescriptor::impl_ptr _lhs, AtomDescriptor::impl_ptr _rhs);
+  virtual ~AtomOrDescriptor_impl();
+  virtual bool predicate(std::pair<int,atom*>);
+
+private:
+  AtomDescriptor::impl_ptr lhs;
+  AtomDescriptor::impl_ptr rhs;
+};
+
+class AtomNotDescriptor_impl : public AtomDescriptor_impl
+{
+public:
+  AtomNotDescriptor_impl(AtomDescriptor::impl_ptr _arg);
+  virtual ~AtomNotDescriptor_impl();
+
+  virtual bool predicate(std::pair<int,atom*>);
+
+private:
+  AtomDescriptor::impl_ptr arg;
+};
Index: src/Descriptors/AtomIdDescriptor.cpp
===================================================================
--- src/Descriptors/AtomIdDescriptor.cpp	(revision d1c5e2c1e093b9756002d8db06bda62bdb2c9057)
+++ src/Descriptors/AtomIdDescriptor.cpp	(revision 7a1ce5357081767198c4e7f7e867143f5d19dda0)
@@ -7,4 +7,5 @@
 
 #include "AtomIdDescriptor.hpp"
+#include "AtomIdDescriptor_impl.hpp"
 
 #include "atom.hpp"
@@ -12,17 +13,18 @@
 using namespace std;
 
-AtomIdDescriptor::AtomIdDescriptor(int _id) :
+
+AtomIdDescriptor_impl::AtomIdDescriptor_impl(int _id) :
   id(_id)
 {}
 
-AtomIdDescriptor::~AtomIdDescriptor()
+AtomIdDescriptor_impl::~AtomIdDescriptor_impl()
 {}
 
-bool AtomIdDescriptor::predicate(std::pair<int,atom*> atom) {
+bool AtomIdDescriptor_impl::predicate(std::pair<int,atom*> atom) {
   return atom.second->getId()==id;
 }
 
-AtomDescriptor::desc_ptr AtomIdDescriptor::clone() const{
-  return desc_ptr(new AtomIdDescriptor(id));
+AtomDescriptor AtomById(int id){
+  return AtomDescriptor(AtomDescriptor::impl_ptr(new AtomIdDescriptor_impl(id)));
 }
 
Index: src/Descriptors/AtomIdDescriptor.hpp
===================================================================
--- src/Descriptors/AtomIdDescriptor.hpp	(revision d1c5e2c1e093b9756002d8db06bda62bdb2c9057)
+++ src/Descriptors/AtomIdDescriptor.hpp	(revision 7a1ce5357081767198c4e7f7e867143f5d19dda0)
@@ -11,22 +11,5 @@
 #include "Descriptors/AtomDescriptor.hpp"
 
-class AtomIdDescriptor : public AtomDescriptor
-{
-public:
-  AtomIdDescriptor(int _id);
-  virtual ~AtomIdDescriptor();
-
-  bool predicate(std::pair<int,atom*> atom);
-
-  virtual desc_ptr clone() const;
-
-protected:
-#if 0
-  atom *find();
-  std::vector<atom*> findAll();
-#endif
-private:
-  int id;
-};
+AtomDescriptor AtomById(int id);
 
 #endif /* ATOMIDDESCRIPTOR_HPP_ */
Index: src/Descriptors/AtomIdDescriptor_impl.hpp
===================================================================
--- src/Descriptors/AtomIdDescriptor_impl.hpp	(revision 7a1ce5357081767198c4e7f7e867143f5d19dda0)
+++ src/Descriptors/AtomIdDescriptor_impl.hpp	(revision 7a1ce5357081767198c4e7f7e867143f5d19dda0)
@@ -0,0 +1,19 @@
+#include "Descriptors/AtomIdDescriptor.hpp"
+#include "Descriptors/AtomDescriptor_impl.hpp"
+
+class AtomIdDescriptor_impl : public AtomDescriptor_impl
+{
+public:
+  AtomIdDescriptor_impl(int _id);
+  virtual ~AtomIdDescriptor_impl();
+
+  bool predicate(std::pair<int,atom*> atom);
+
+protected:
+#if 0
+  atom *find();
+  std::vector<atom*> findAll();
+#endif
+private:
+  int id;
+};
Index: src/World.cpp
===================================================================
--- src/World.cpp	(revision d1c5e2c1e093b9756002d8db06bda62bdb2c9057)
+++ src/World.cpp	(revision 7a1ce5357081767198c4e7f7e867143f5d19dda0)
@@ -18,9 +18,9 @@
 }
 
-atom* World::getAtom(AtomDescriptor &descriptor){
+atom* World::getAtom(AtomDescriptor descriptor){
   return descriptor.find();
 }
 
-vector<atom*> World::getAllAtoms(AtomDescriptor &descriptor){
+vector<atom*> World::getAllAtoms(AtomDescriptor descriptor){
   return descriptor.findAll();
 }
@@ -34,5 +34,6 @@
 
 
-World::World()
+World::World() :
+    dummyId(0)
 {}
 
@@ -87,5 +88,5 @@
 void World::registerAtom(atom *theAtom){
   OBSERVE;
-  atoms[theAtom->getId()] = theAtom;
+  atoms[dummyId++] = theAtom;
 }
 
Index: src/World.hpp
===================================================================
--- src/World.hpp	(revision d1c5e2c1e093b9756002d8db06bda62bdb2c9057)
+++ src/World.hpp	(revision 7a1ce5357081767198c4e7f7e867143f5d19dda0)
@@ -21,14 +21,15 @@
 class atom;
 class AtomDescriptor;
+class AtomDescriptor_impl;
 
 class World : public Observable
 {
-friend class AtomDescriptor;
+friend class AtomDescriptor_impl;
 public:
 
   /***** getter and setter *****/
   periodentafel* getPeriode();
-  atom* getAtom(AtomDescriptor& descriptor);
-  std::vector<atom*> getAllAtoms(AtomDescriptor& descriptor);
+  atom* getAtom(AtomDescriptor descriptor);
+  std::vector<atom*> getAllAtoms(AtomDescriptor descriptor);
 private:
   periodentafel *periode;
@@ -63,4 +64,10 @@
 private:
   MoleculeListClass *molecules;
+
+  // this is needed to assign unique IDs to atoms... so far
+  // IDs are not assigned upon Atom creation, so we cannot query the ID
+  // during construction. By using the dummy ID we can make sure all atoms
+  // are actually stored in the map and don't overwrite each other.
+  int dummyId;
 };
 
Index: src/atom_particleinfo.hpp
===================================================================
--- src/atom_particleinfo.hpp	(revision d1c5e2c1e093b9756002d8db06bda62bdb2c9057)
+++ src/atom_particleinfo.hpp	(revision 7a1ce5357081767198c4e7f7e867143f5d19dda0)
@@ -35,5 +35,5 @@
   ostream & operator << (ostream &ost) const;
 
-  int getId();
+  virtual int getId();
 
 private:
Index: src/unittests/DescriptorUnittest.cpp
===================================================================
--- src/unittests/DescriptorUnittest.cpp	(revision 7a1ce5357081767198c4e7f7e867143f5d19dda0)
+++ src/unittests/DescriptorUnittest.cpp	(revision 7a1ce5357081767198c4e7f7e867143f5d19dda0)
@@ -0,0 +1,179 @@
+/*
+ * DescriptorUnittest.cpp
+ *
+ *  Created on: Feb 9, 2010
+ *      Author: crueger
+ */
+
+#include "DescriptorUnittest.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include <iostream>
+
+#include <Descriptors/AtomDescriptor.hpp>
+#include <Descriptors/AtomIdDescriptor.hpp>
+
+#include "World.hpp"
+#include "atom.hpp"
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( DescriptorUnittest );
+
+// some stubs
+class AtomStub : public atom {
+public:
+  AtomStub(int _id) :
+  atom(),
+  id(_id)
+  {}
+
+  virtual int getId(){
+    return id;
+  }
+
+private:
+  int id;
+};
+
+
+// set up and tear down
+void DescriptorUnittest::setUp(){
+  World::get();
+  for(int i=0;i<ATOM_COUNT;++i){
+    atoms[i]= new AtomStub(i);
+  }
+}
+void DescriptorUnittest::tearDown(){
+  World::destroy();
+  for(int i=0;i<ATOM_COUNT;++i){
+    delete atoms[i];
+  }
+}
+
+// some helper functions
+bool hasAll(std::vector<atom*> atoms,int min, int max, std::set<int> excluded = std::set<int>()){
+  for(int i=min;i<max;++i){
+    if(!excluded.count(i)){
+      std::vector<atom*>::iterator iter;
+      bool res=false;
+      for(iter=atoms.begin();iter!=atoms.end();++iter){
+        res |= (*iter)->getId() == i;
+      }
+      if(!res) {
+        cout << "Atom " << i << " missing in returned list" << endl;
+        return false;
+      }
+    }
+  }
+  return true;
+}
+
+bool hasNoDuplicates(std::vector<atom*> atoms){
+  std::set<int> found;
+  std::vector<atom*>::iterator iter;
+  for(iter=atoms.begin();iter!=atoms.end();++iter){
+    int id = (*iter)->getId();
+    if(found.count(id))
+      return false;
+    found.insert(id);
+  }
+  return true;
+}
+
+
+void DescriptorUnittest::AtomBaseSetsTest(){
+  std::vector<atom*> allAtoms = World::get()->getAllAtoms(AllAtoms());
+  CPPUNIT_ASSERT_EQUAL( true , hasAll(allAtoms,0,ATOM_COUNT));
+  CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicates(allAtoms));
+
+  std::vector<atom*> noAtoms = World::get()->getAllAtoms(NoAtoms());
+  CPPUNIT_ASSERT_EQUAL( true , noAtoms.empty());
+}
+void DescriptorUnittest::AtomIdTest(){
+  // test Atoms from boundaries and middle of the set
+  atom* testAtom;
+  testAtom = World::get()->getAtom(AtomById(0));
+  CPPUNIT_ASSERT_EQUAL( 0, testAtom->getId());
+  testAtom = World::get()->getAtom(AtomById(ATOM_COUNT/2));
+  CPPUNIT_ASSERT_EQUAL( ATOM_COUNT/2, testAtom->getId());
+  testAtom = World::get()->getAtom(AtomById(ATOM_COUNT-1));
+  CPPUNIT_ASSERT_EQUAL( ATOM_COUNT-1, testAtom->getId());
+
+  // test from outside of set
+  testAtom = World::get()->getAtom(AtomById(ATOM_COUNT));
+  CPPUNIT_ASSERT(!testAtom);
+}
+void DescriptorUnittest::AtomCalcTest(){
+  // test some elementary set operations
+  {
+    std::vector<atom*> testAtoms = World::get()->getAllAtoms(AllAtoms()||NoAtoms());
+    CPPUNIT_ASSERT_EQUAL( true , hasAll(testAtoms,0,ATOM_COUNT));
+    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicates(testAtoms));
+  }
+
+  {
+    std::vector<atom*> testAtoms = World::get()->getAllAtoms(NoAtoms()||AllAtoms());
+    CPPUNIT_ASSERT_EQUAL( true , hasAll(testAtoms,0,ATOM_COUNT));
+    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicates(testAtoms));
+  }
+
+  {
+    std::vector<atom*> testAtoms = World::get()->getAllAtoms(NoAtoms()&&AllAtoms());
+    CPPUNIT_ASSERT_EQUAL( true , testAtoms.empty());
+  }
+
+  {
+    std::vector<atom*> testAtoms = World::get()->getAllAtoms(AllAtoms()&&NoAtoms());
+    CPPUNIT_ASSERT_EQUAL( true , testAtoms.empty());
+  }
+
+  {
+    std::vector<atom*> testAtoms = World::get()->getAllAtoms(!AllAtoms());
+    CPPUNIT_ASSERT_EQUAL( true , testAtoms.empty());
+  }
+
+  {
+    std::vector<atom*> testAtoms = World::get()->getAllAtoms(!NoAtoms());
+    CPPUNIT_ASSERT_EQUAL( true , hasAll(testAtoms,0,ATOM_COUNT));
+    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicates(testAtoms));
+  }
+
+  // exclude and include some atoms
+  {
+    std::vector<atom*> testAtoms = World::get()->getAllAtoms(AllAtoms()&&(!AtomById(ATOM_COUNT/2)));
+    std::set<int> excluded;
+    excluded.insert(ATOM_COUNT/2);
+    CPPUNIT_ASSERT_EQUAL( true , hasAll(testAtoms,0,ATOM_COUNT,excluded));
+    CPPUNIT_ASSERT_EQUAL( true , hasNoDuplicates(testAtoms));
+    CPPUNIT_ASSERT_EQUAL( (size_t)(ATOM_COUNT-1), testAtoms.size());
+  }
+
+  {
+    std::vector<atom*> testAtoms = World::get()->getAllAtoms(NoAtoms()||(AtomById(ATOM_COUNT/2)));
+    CPPUNIT_ASSERT_EQUAL( (size_t)1, testAtoms.size());
+    CPPUNIT_ASSERT_EQUAL( ATOM_COUNT/2, testAtoms[0]->getId());
+  }
+}
+
+/********************************************** Main routine **************************************/
+
+int main(int argc, char **argv)
+{
+  // Get the top level suite from the registry
+  CppUnit::Test *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
+
+  // Adds the test to the list of test to run
+  CppUnit::TextUi::TestRunner runner;
+  runner.addTest( suite );
+
+  // Change the default outputter to a compiler error format outputter
+  runner.setOutputter( new CppUnit::CompilerOutputter( &runner.result(),
+                                                       std::cerr ) );
+  // Run the tests.
+  bool wasSucessful = runner.run();
+
+  // Return error code 1 if the one of test failed.
+  return wasSucessful ? 0 : 1;
+};
Index: src/unittests/DescriptorUnittest.hpp
===================================================================
--- src/unittests/DescriptorUnittest.hpp	(revision 7a1ce5357081767198c4e7f7e867143f5d19dda0)
+++ src/unittests/DescriptorUnittest.hpp	(revision 7a1ce5357081767198c4e7f7e867143f5d19dda0)
@@ -0,0 +1,37 @@
+/*
+ * DescriptorUnittest.hpp
+ *
+ *  Created on: Feb 9, 2010
+ *      Author: crueger
+ */
+
+#ifndef DESCRIPTORUNITTEST_HPP_
+#define DESCRIPTORUNITTEST_HPP_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#define ATOM_COUNT (10)
+
+class atom;
+
+class DescriptorUnittest : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( DescriptorUnittest );
+  CPPUNIT_TEST ( AtomBaseSetsTest );
+  CPPUNIT_TEST ( AtomIdTest );
+  CPPUNIT_TEST ( AtomCalcTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void AtomBaseSetsTest();
+  void AtomIdTest();
+  void AtomCalcTest();
+
+private:
+  atom *atoms [ATOM_COUNT];
+};
+
+#endif /* DESCRIPTORUNITTEST_HPP_ */
Index: src/unittests/Makefile.am
===================================================================
--- src/unittests/Makefile.am	(revision d1c5e2c1e093b9756002d8db06bda62bdb2c9057)
+++ src/unittests/Makefile.am	(revision 7a1ce5357081767198c4e7f7e867143f5d19dda0)
@@ -29,4 +29,5 @@
   ObserverTest \
   CacheableTest \
+  DescriptorUnittest \
   ${MENUTESTS}  
     
@@ -107,4 +108,7 @@
 CacheableTest_LDADD = ${ALLLIBS}
 
+DescriptorUnittest_SOURCES = DescriptorUnittest.cpp DescriptorUnittest.hpp
+DescriptorUnittest_LDADD = ${ALLLIBS} 
+
 #AUTOMAKE_OPTIONS = parallel-tests
 
