Index: ThirdParty/CodePatterns/src/Patterns/Makefile.am
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/Makefile.am	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/Makefile.am	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,74 @@
+ # PLEASE adhere to the alphabetical ordering in this Makefile!
+# Also indentation by a single tab
+
+
+AM_LDFLAGS = -ldl
+AM_CPPFLAGS = -I$(top_srcdir)/src/ ${BOOST_CPPFLAGS}
+
+PATTERNSOURCE =
+
+PATTERNDEBUGSOURCE =
+
+PATTERNHEADER = \
+	$(top_srcdir)/src/CodePatterns/AtomicInstance.hpp \
+	$(top_srcdir)/src/CodePatterns/AtomicInstance_impl.hpp \
+	$(top_srcdir)/src/CodePatterns/Cacheable.hpp \
+	$(top_srcdir)/src/CodePatterns/Clone.hpp \
+	$(top_srcdir)/src/CodePatterns/Creator.hpp \
+	$(top_srcdir)/src/CodePatterns/Factory.hpp \
+	$(top_srcdir)/src/CodePatterns/Factory_impl.hpp \
+	$(top_srcdir)/src/CodePatterns/FactoryTypeList.hpp \
+	$(top_srcdir)/src/CodePatterns/ManipulableClone.hpp \
+	$(top_srcdir)/src/CodePatterns/ManipulablePrototypeFactory.hpp \
+	$(top_srcdir)/src/CodePatterns/ManipulablePrototypeFactory_impl.hpp \
+	$(top_srcdir)/src/CodePatterns/ObservedValue.hpp \
+	$(top_srcdir)/src/CodePatterns/PrototypeFactory.hpp \
+	$(top_srcdir)/src/CodePatterns/PrototypeFactory_impl.hpp \
+	$(top_srcdir)/src/CodePatterns/Registry.hpp \
+	$(top_srcdir)/src/CodePatterns/Registry_impl.hpp \
+	$(top_srcdir)/src/CodePatterns/Singleton.hpp \
+	$(top_srcdir)/src/CodePatterns/Singleton_impl.hpp
+
+PATTERNDEBUGHEADER =
+
+noinst_LTLIBRARIES = libcodepatterns-Patterns.la libcodepatterns-Patterns-debug.la
+libcodepatterns_Patterns_la_includedir = $(includedir)/CodePatterns/
+libcodepatterns_Patterns_debug_la_includedir = $(includedir)/CodePatterns/
+libcodepatterns_Patterns_la_LDFLAGS = \
+	$(AM_LDFLAGS) \
+	$(BOOST_THREAD_LDFLAGS) \
+	$(BOOST_THREAD_LIBS)
+libcodepatterns_Patterns_la_LIBADD =
+libcodepatterns_Patterns_debug_la_LDFLAGS = \
+	$(AM_LDFLAGS) \
+	$(BOOST_THREAD_LDFLAGS) \
+	$(BOOST_THREAD_LIBS)
+libcodepatterns_Patterns_debug_la_LIBADD =
+
+libcodepatterns_Patterns_la_CPPFLAGS = -DNDEBUG -DNO_MEMDEBUG $(AM_CPPFLAGS)
+libcodepatterns_Patterns_debug_la_CPPFLAGS = -DMEMDEBUG -DLOG_OBSERVER $(AM_CPPFLAGS)
+
+libcodepatterns_Patterns_la_include_HEADERS = $(PATTERNHEADER)
+libcodepatterns_Patterns_debug_la_include_HEADERS = $(PATTERNDEBUGHEADER)
+
+## Define the source file list for the "libexample-@MOLECUILDER_API_VERSION@.la"
+## target.  Note that @MOLECUILDER_API_VERSION@ is not interpreted by Automake and
+## will therefore be treated as if it were literally part of the target name,
+## and the variable name derived from that.
+## The file extension .cc is recognized by Automake, and makes it produce
+## rules which invoke the C++ compiler to produce a libtool object file (.lo)
+## from each source file.  Note that it is not necessary to list header files
+## which are already listed elsewhere in a _HEADERS variable assignment.
+libcodepatterns_Patterns_la_SOURCES = $(PATTERNSOURCE)
+libcodepatterns_Patterns_debug_la_SOURCES = $(PATTERNDEBUGSOURCE)
+
+#Observer/all.hpp: FORCE
+#	@if (test -d $(top_srcdir)/Patterns/Observer); then \
+#	  cd $(top_srcdir)/Patterns; \
+#	  cat >$@ < $(top_srcdir)/Patterns/Observer/all.hpp; \
+#	  for includefile in Observer/*.hpp; do \
+#	  	echo "#include \"${includefile}\"" >>$@; \
+#	  done; \
+#	  echo "#endif /* OBSERVER_ALL_HPP_ */" >>$@; \
+#	fi
+
Index: ThirdParty/CodePatterns/src/Patterns/unittests/AtomicInstanceUnitTest.cpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/AtomicInstanceUnitTest.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/AtomicInstanceUnitTest.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,156 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * AtomicInstanceUnitTest.cpp
+ *
+ *  Created on: Apr 26, 2016
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "AtomicInstanceUnitTest.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include <iostream>
+
+#include "CodePatterns/AtomicInstance.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+CPPUNIT_TEST_SUITE_REGISTRATION( AtomicInstanceTest );
+
+// some necessary stubs
+class AtomicInstanceStub1 {
+public:
+  AtomicInstanceStub1(){
+    count1++;
+  }
+  // explicit copy constructor to catch if this is ever called
+  AtomicInstanceStub1(const AtomicInstanceStub1&){
+    CPPUNIT_FAIL    ( "Copy constructor of AtomicInstance called" );
+  }
+  virtual ~AtomicInstanceStub1(){
+    count2++;
+  }
+public:
+  static int count1;
+  static int count2;
+};
+
+int AtomicInstanceStub1::count1 = 0;
+int AtomicInstanceStub1::count2 = 0;
+
+//CONSTRUCT_ATOMIC(AtomicInstanceStub1)
+
+// some necessary stubs
+class AtomicInstanceStub2 {
+public:
+  AtomicInstanceStub2(){
+    count1++;
+  }
+  // explicit copy constructor to catch if this is ever called
+  AtomicInstanceStub2(const AtomicInstanceStub2&){
+    CPPUNIT_FAIL    ( "Copy constructor of AtomicInstance called" );
+  }
+  virtual ~AtomicInstanceStub2(){
+    count2++;
+  }
+public:
+  static int count1;
+  static int count2;
+};
+
+int AtomicInstanceStub2::count1 = 0;
+int AtomicInstanceStub2::count2 = 0;
+
+//CONSTRUCT_ATOMIC(AtomicInstanceStub2)
+
+void AtomicInstanceTest::setUp()
+{
+  ASSERT_DO(Assert::Throw);
+}
+
+void AtomicInstanceTest::tearDown(){}
+
+static bool checkLock(boost::mutex &_mutex)
+{
+  boost::mutex::scoped_lock lock(_mutex, boost::try_to_lock);
+  return lock;
+}
+
+void AtomicInstanceTest::ConstructionTest()
+{
+  AtomicInstanceStub1 *ptr1_1 = new AtomicInstanceStub1();
+  AtomicInstanceStub2 *ptr2_1 = new AtomicInstanceStub2();
+  {
+    CPPUNIT_ASSERT( checkLock(AtomicInstance<AtomicInstanceStub1>::atomicLock) );
+    AtomicInstance<AtomicInstanceStub1> atomic_ptr1_1(ptr1_1);
+    CPPUNIT_ASSERT_EQUAL( ptr1_1, &(*atomic_ptr1_1) );
+    CPPUNIT_ASSERT( !checkLock(AtomicInstance<AtomicInstanceStub1>::atomicLock) );
+
+    // will NULL no deadlock occurs
+    {
+      CPPUNIT_ASSERT( !checkLock(AtomicInstance<AtomicInstanceStub1>::atomicLock) );
+      AtomicInstance<AtomicInstanceStub1> atomic_ptr1_NULL(NULL);
+      CPPUNIT_ASSERT( !checkLock(AtomicInstance<AtomicInstanceStub1>::atomicLock) );
+    }
+
+    CPPUNIT_ASSERT( checkLock(AtomicInstance<AtomicInstanceStub2>::atomicLock) );
+    const AtomicInstance<AtomicInstanceStub2> atomic_ptr2_1(ptr2_1);
+    CPPUNIT_ASSERT_EQUAL( const_cast<const AtomicInstanceStub2 *>(ptr2_1), &(*atomic_ptr2_1) );
+    CPPUNIT_ASSERT( !checkLock(AtomicInstance<AtomicInstanceStub2>::atomicLock) );
+
+    // move is ok
+    CPPUNIT_ASSERT( !checkLock(AtomicInstance<AtomicInstanceStub1>::atomicLock) );
+    AtomicInstance<AtomicInstanceStub1> atomic_ptr1_2(atomic_ptr1_1);
+    CPPUNIT_ASSERT( atomic_ptr1_1.content == (AtomicInstanceStub1 *)NULL);
+    CPPUNIT_ASSERT( atomic_ptr1_2.content != (AtomicInstanceStub1 *)NULL);
+    CPPUNIT_ASSERT( !checkLock(AtomicInstance<AtomicInstanceStub1>::atomicLock) );
+
+    // this would cause deadlock
+//    AtomicInstance<AtomicInstanceStub1> atomic_ptr1_3(ptr1_1);
+  }
+  CPPUNIT_ASSERT( checkLock(AtomicInstance<AtomicInstanceStub1>::atomicLock) );
+  CPPUNIT_ASSERT( checkLock(AtomicInstance<AtomicInstanceStub2>::atomicLock) );
+  delete ptr1_1;
+  delete ptr2_1;
+ }
+
+void AtomicInstanceTest::AssignmentTest()
+{
+  AtomicInstanceStub1 *ptr1_1 = new AtomicInstanceStub1();
+  {
+    // this does not lock
+    CPPUNIT_ASSERT( checkLock(AtomicInstance<AtomicInstanceStub1>::atomicLock) );
+    AtomicInstance<AtomicInstanceStub1> atomic_ptr1_NULL(NULL);
+    CPPUNIT_ASSERT( atomic_ptr1_NULL.content == (AtomicInstanceStub1 *)NULL );
+    CPPUNIT_ASSERT( checkLock(AtomicInstance<AtomicInstanceStub1>::atomicLock) );
+
+    // this will lock
+    AtomicInstance<AtomicInstanceStub1> atomic_ptr1_1(ptr1_1);
+    CPPUNIT_ASSERT( atomic_ptr1_1.content != (AtomicInstanceStub1 *)NULL );
+    CPPUNIT_ASSERT( !checkLock(AtomicInstance<AtomicInstanceStub1>::atomicLock) );
+
+    // now assign. Content has moved and should still be locked
+    atomic_ptr1_NULL = atomic_ptr1_1;
+    CPPUNIT_ASSERT( !checkLock(AtomicInstance<AtomicInstanceStub1>::atomicLock) );
+    CPPUNIT_ASSERT( atomic_ptr1_NULL.content != (AtomicInstanceStub1 *)NULL );
+    CPPUNIT_ASSERT( atomic_ptr1_1.content == (AtomicInstanceStub1 *)NULL );
+  }
+  CPPUNIT_ASSERT( checkLock(AtomicInstance<AtomicInstanceStub1>::atomicLock) );
+
+  delete ptr1_1;
+}
Index: ThirdParty/CodePatterns/src/Patterns/unittests/AtomicInstanceUnitTest.hpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/AtomicInstanceUnitTest.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/AtomicInstanceUnitTest.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,33 @@
+/*
+ * AtomicInstanceUnitTest.hpp
+ *
+ *  Created on: Apr 26, 2016
+ *      Author: heber
+ */
+
+#ifndef ATOMICINSTANCEUNITTEST_HPP_
+#define ATOMICINSTANCEUNITTEST_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class AtomicInstanceTest : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( AtomicInstanceTest );
+  CPPUNIT_TEST ( ConstructionTest );
+  CPPUNIT_TEST ( AssignmentTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void ConstructionTest();
+  void AssignmentTest();
+};
+
+#endif /* ATOMICINSTANCEUNITTEST_HPP_ */
Index: ThirdParty/CodePatterns/src/Patterns/unittests/CacheableUnitTest.cpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/CacheableUnitTest.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/CacheableUnitTest.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,87 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * CacheableUnitTest.cpp
+ *
+ *  Created on: Feb 2, 2010
+ *      Author: crueger
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CacheableUnitTest.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <boost/bind.hpp>
+
+#include "CodePatterns/Cacheable.hpp"
+
+#include "stubs/Cacheable_threeNumbers.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( CacheableTest );
+
+void CacheableTest::setUp(){
+  numbers = new Cacheable_threeNumbers(1,2,3);
+  Observable::channels_t ychannel(1, Cacheable_threeNumbers::YChanged);
+  YChange_numbers = new Cacheable_threeNumbers(1,2,3, ychannel);
+}
+
+void CacheableTest::tearDown(){
+  delete numbers;
+}
+
+void CacheableTest::doesRecalcTest()
+{
+  CPPUNIT_ASSERT_EQUAL( 6, *(numbers->sum));
+  CPPUNIT_ASSERT_EQUAL( true, numbers->hasRecalced);
+  numbers->hasRecalced=false;
+  numbers->setX(4);
+  CPPUNIT_ASSERT_EQUAL( false, numbers->hasRecalced);
+  CPPUNIT_ASSERT_EQUAL( 9, *(numbers->sum));
+  CPPUNIT_ASSERT_EQUAL( true, numbers->hasRecalced);
+  numbers->hasRecalced=false;
+  CPPUNIT_ASSERT_EQUAL( 9, *(numbers->sum));
+#ifndef NO_CACHING
+  CPPUNIT_ASSERT_EQUAL( false, numbers->hasRecalced);
+#else
+  CPPUNIT_ASSERT_EQUAL( true, numbers->hasRecalced);
+#endif
+
+  CPPUNIT_ASSERT_EQUAL( 6, *(YChange_numbers->sum));
+  CPPUNIT_ASSERT_EQUAL( true, YChange_numbers->hasRecalced);
+  YChange_numbers->hasRecalced=false;
+  YChange_numbers->setX(4);
+  CPPUNIT_ASSERT_EQUAL( false, YChange_numbers->hasRecalced);
+  CPPUNIT_ASSERT_EQUAL( 6, *(YChange_numbers->sum));
+  CPPUNIT_ASSERT_EQUAL( false, YChange_numbers->hasRecalced);
+  YChange_numbers->hasRecalced=false;
+  YChange_numbers->setY(4);
+  CPPUNIT_ASSERT_EQUAL( false, YChange_numbers->hasRecalced);
+  CPPUNIT_ASSERT_EQUAL( 11, *(YChange_numbers->sum));
+  CPPUNIT_ASSERT_EQUAL( true, YChange_numbers->hasRecalced);
+  YChange_numbers->hasRecalced=false;
+  CPPUNIT_ASSERT_EQUAL( 11, *(YChange_numbers->sum));
+#ifndef NO_CACHING
+  CPPUNIT_ASSERT_EQUAL( false, YChange_numbers->hasRecalced);
+#else
+  CPPUNIT_ASSERT_EQUAL( true, YChange_numbers->hasRecalced);
+#endif
+}
Index: ThirdParty/CodePatterns/src/Patterns/unittests/CacheableUnitTest.hpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/CacheableUnitTest.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/CacheableUnitTest.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,37 @@
+/*
+ * CacheableUnitTest.hpp
+ *
+ *  Created on: Feb 2, 2010
+ *      Author: crueger
+ */
+
+#ifndef CACHEABLEUNITTEST_HPP_
+#define CACHEABLEUNITTEST_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <cppunit/extensions/HelperMacros.h>
+
+
+// stub classes
+class Cacheable_threeNumbers;
+
+class CacheableTest :  public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( CacheableTest );
+  CPPUNIT_TEST ( doesRecalcTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void doesRecalcTest();
+  Cacheable_threeNumbers *numbers;
+  Cacheable_threeNumbers *YChange_numbers;
+};
+
+#endif /* CACHEABLEUNITTEST_HPP_ */
Index: ThirdParty/CodePatterns/src/Patterns/unittests/CloneUnitTest.cpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/CloneUnitTest.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/CloneUnitTest.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,115 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+/*
+ * CloneUnitTest.cpp
+ *
+ *  Created on: Jan 03, 2011
+ *      Author: heber
+ */
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CloneUnitTest.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "CodePatterns/Assert.hpp"
+
+#include "CodePatterns/Clone.hpp"
+#include "stubs/CloneStub.hpp"
+
+#include <typeinfo>
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( CloneTest );
+
+
+void CloneTest::setUp()
+{
+  ip1 = &p1;
+  CPPUNIT_ASSERT( ip1 == &p1 );
+  ip2 = &p2;
+  CPPUNIT_ASSERT( ip2 == &p2 );
+
+  ip1_1 = NULL;
+  ip1_2 = NULL;
+  ip2_1 = NULL;
+  ip2_2 = NULL;
+}
+
+void CloneTest::tearDown()
+{
+  // NULL pointer may be deleted.
+  delete ip1_1;
+  delete ip1_2;
+  delete ip2_1;
+  delete ip2_2;
+}
+
+void CloneTest::CreationTest()
+{
+  // test that new instances have been created.
+  ip1_1 = p1.clone();
+  ip1_2 = p1.clone();
+  CPPUNIT_ASSERT( ip1 != ip1_1 );
+  CPPUNIT_ASSERT( ip1 != ip1_2 );
+
+  ip2_1 = p2.clone();
+  ip2_2 = p2.clone();
+  CPPUNIT_ASSERT( ip2 != ip2_1 );
+  CPPUNIT_ASSERT( ip2 != ip2_2 );
+}
+
+void CloneTest::IndividualityTest()
+{
+  CPPUNIT_ASSERT( typeid(p1).name() != typeid(p2).name() );
+  p1.count();
+  p2.count();
+  p2.count();
+
+  // make refs to interface
+  ip1 = &p1;
+  CPPUNIT_ASSERT( ip1 == &p1 );
+  ip2 = &p2;
+  CPPUNIT_ASSERT( ip2 == &p2 );
+
+  // clone (i.e. counter = p?.counter ), ...
+  ip1_1 = p1.clone();
+  ip1_2 = p1.clone();
+  ip2_1 = p2.clone();
+  ip2_2 = p2.clone();
+
+  // check that each is individual
+  CPPUNIT_ASSERT_EQUAL( ip1->getcount(), ip1_1->getcount() );
+  CPPUNIT_ASSERT_EQUAL( ip1->getcount(), ip1_2->getcount() );
+  CPPUNIT_ASSERT_EQUAL( ip2->getcount(), ip2_1->getcount() );
+  CPPUNIT_ASSERT_EQUAL( ip2->getcount(), ip2_2->getcount() );
+
+  // increase individual counters and check against others
+  ip1_1->count();
+  CPPUNIT_ASSERT( ip1->getcount() != ip1_1->getcount() );
+  CPPUNIT_ASSERT( ip1_1->getcount() != ip1_2->getcount() );
+  CPPUNIT_ASSERT( ip1->getcount() == ip1_2->getcount() );
+
+  ip1_2->count();
+  CPPUNIT_ASSERT( ip1_1->getcount() == ip1_2->getcount() );
+  CPPUNIT_ASSERT( ip1->getcount() != ip1_2->getcount() );
+
+  ip1_2->count();
+  CPPUNIT_ASSERT( ip1_1->getcount() != ip1_2->getcount() );
+  CPPUNIT_ASSERT( ip1->getcount()   != ip1_2->getcount() );
+}
Index: ThirdParty/CodePatterns/src/Patterns/unittests/CloneUnitTest.hpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/CloneUnitTest.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/CloneUnitTest.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,47 @@
+/*
+ * CloneUnitTest.hpp
+ *
+ *  Created on: Jan 03, 2011
+ *      Author: heber
+ */
+
+#ifndef CLONEUNITTEST_HPP_
+#define CLONEUNITTEST_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "stubs/CommonStub.hpp"
+#include "stubs/CloneStub.hpp"
+
+
+class CloneTest : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( CloneTest );
+  CPPUNIT_TEST ( CreationTest );
+  CPPUNIT_TEST ( IndividualityTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void CreationTest();
+  void IndividualityTest();
+
+private:
+  Prototype<teststubs::Aclass> p1;
+  Prototype<teststubs::Bclass> p2;
+  IPrototype *ip1;
+  IPrototype *ip1_1;
+  IPrototype *ip1_2;
+  IPrototype *ip2;
+  IPrototype *ip2_1;
+  IPrototype *ip2_2;
+};
+
+#endif /* CLONEUNITTEST_HPP_ */
Index: ThirdParty/CodePatterns/src/Patterns/unittests/CreatorUnitTest.cpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/CreatorUnitTest.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/CreatorUnitTest.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,107 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+/*
+ * CreatorUnitTest.cpp
+ *
+ *  Created on: Jan 03, 2011
+ *      Author: heber
+ */
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CreatorUnitTest.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "CodePatterns/Assert.hpp"
+
+#include <typeinfo>
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( CreatorTest );
+
+
+void CreatorTest::setUp()
+{
+  testingA1 = NULL;
+  testingA2 = NULL;
+  testingB1 = NULL;
+  testingB2 = NULL;
+}
+
+void CreatorTest::tearDown()
+{
+  delete testingA1;
+  delete testingA2;
+  delete testingB1;
+  delete testingB2;
+}
+
+void CreatorTest::CreationTest()
+{
+  testingA1 = teststubA.create();
+  testingA2 = teststubA.create();
+  testingB1 = teststubB.create();
+
+  // instance is different
+  CPPUNIT_ASSERT( &teststubA != testingA1 );
+  CPPUNIT_ASSERT( &teststubA != testingA2 );
+  CPPUNIT_ASSERT( testingA1 != testingA2 );
+  CPPUNIT_ASSERT( &teststubB != testingB1 );
+
+  // type is the same ...
+  CPPUNIT_ASSERT_EQUAL( typeid(teststubA).name(), typeid(*testingA1).name() );
+  CPPUNIT_ASSERT_EQUAL( typeid(*testingA1).name(), typeid(*testingA2).name() );
+  CPPUNIT_ASSERT_EQUAL( typeid(teststubB).name(), typeid(*testingB1).name() );
+
+  // ... for the same particular type only!
+  // (RTTI knows about the true complex type!)
+  CPPUNIT_ASSERT( typeid(*testingB1).name() != typeid(*testingA1).name() );
+  CPPUNIT_ASSERT( typeid(*testingB1).name() != typeid(*testingA2).name() );
+
+  // but not for different encapsulated types
+  CPPUNIT_ASSERT( typeid(teststubA).name() != typeid(*testingB1).name() );
+  CPPUNIT_ASSERT( typeid(teststubB).name() != typeid(*testingA1).name() );
+  CPPUNIT_ASSERT( typeid(teststubB).name() != typeid(*testingA2).name() );
+
+}
+
+void CreatorTest::IndividualityTest()
+{
+  teststubA.count();
+  teststubB.count();
+  teststubB.count();
+
+  testingA1 = teststubA.create();
+  testingA2 = teststubA.create();
+  testingB1 = teststubB.create();
+  testingB2 = teststubB.create();
+
+  // content is the same (prototype has been copied)
+  CPPUNIT_ASSERT( teststubA.getcount() != testingA1->getcount());
+  CPPUNIT_ASSERT( teststubA.getcount() != testingA2->getcount());
+  CPPUNIT_ASSERT( teststubB.getcount() != testingB1->getcount());
+  CPPUNIT_ASSERT( teststubB.getcount() != testingB2->getcount());
+
+  // but each copy is independent
+  testingA1->count();
+  CPPUNIT_ASSERT( testingA1->getcount() != testingA2->getcount());
+  testingB1->count();
+  testingB2->count();
+  testingB2->count();
+  CPPUNIT_ASSERT( testingB1->getcount() != testingB2->getcount());
+}
Index: ThirdParty/CodePatterns/src/Patterns/unittests/CreatorUnitTest.hpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/CreatorUnitTest.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/CreatorUnitTest.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,44 @@
+/*
+ * CreatorUnitTest.hpp
+ *
+ *  Created on: Jan 03, 2011
+ *      Author: heber
+ */
+
+#ifndef CREATORUNITTEST_HPP_
+#define CREATORUNITTEST_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "stubs/CreatorStub.hpp"
+#include "stubs/CommonStub.hpp"
+
+class CreatorTest : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( CreatorTest );
+  CPPUNIT_TEST ( CreationTest );
+  CPPUNIT_TEST ( IndividualityTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void CreationTest();
+  void IndividualityTest();
+
+private:
+  class CreatorStub<teststubs::Aclass> teststubA;
+  class CreatorStub<teststubs::Bclass> teststubB;
+  ICreatorStub* testingA1;
+  ICreatorStub* testingA2;
+  ICreatorStub* testingB1;
+  ICreatorStub* testingB2;
+};
+
+#endif /* CREATORUNITTEST_HPP_ */
Index: ThirdParty/CodePatterns/src/Patterns/unittests/FactoryUnitTest.cpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/FactoryUnitTest.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/FactoryUnitTest.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,102 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+/*
+ * FactoryUnitTest.cpp
+ *
+ *  Created on: Jan 03, 2011
+ *      Author: heber
+ */
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include "CodePatterns/Assert.hpp"
+
+#include "FactoryUnitTest.hpp"
+
+#include "stubs/CommonStub.hpp"
+#include "stubs/FactoryStub.hpp"
+
+#include <typeinfo>
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( FactoryTest );
+
+void FactoryTest::setUp()
+{
+  rndA =
+      FactoryStub::getInstance().
+      PrototypeTable[FactoryStub::Aclass]->create();
+  rndB =
+      FactoryStub::getInstance().
+      PrototypeTable[FactoryStub::Bclass]->create();
+  rndA_1 = NULL;
+}
+
+void FactoryTest::tearDown()
+{
+  delete rndA;
+  delete rndB;
+  delete rndA_1;
+  FactoryStub::purgeInstance();
+}
+
+void FactoryTest::DistributionTest()
+{
+  // check the injectiveness of enum and string map
+  for (FactoryStub::NameMap::const_iterator
+      iter = FactoryStub::getInstance().names.begin();
+      iter != FactoryStub::getInstance().names.end();
+      ++iter) {
+    CPPUNIT_ASSERT_EQUAL(
+        iter->second,
+        FactoryStub::getInstance().getName(
+            FactoryStub::getInstance().getEnum(
+                iter->second
+            )
+        )
+    );
+  }
+
+  // check distributions in the table
+  CPPUNIT_ASSERT_EQUAL(
+      std::string(typeid(teststubs::Aclass).name()),
+      rndA->name()
+  );
+  CPPUNIT_ASSERT_EQUAL(
+      std::string(typeid(teststubs::Bclass).name()),
+      rndB->name()
+  );
+}
+
+
+void FactoryTest::getProductEnumTest()
+{
+  rndA_1 = FactoryStub::getInstance().getProduct(FactoryStub::Aclass);
+  CPPUNIT_ASSERT( typeid(*rndA) == typeid(*rndA_1) );
+}
+
+void FactoryTest::getProductNameTest()
+{
+  rndA_1 = FactoryStub::getInstance().getProduct(std::string("Aclass"));
+  CPPUNIT_ASSERT( typeid(*rndA) == typeid(*rndA_1) );
+}
+
+void FactoryTest::getProductTypeTest()
+{
+  rndA_1 = FactoryStub::getInstance().getProduct( typeid(teststubs::Aclass) );
+  CPPUNIT_ASSERT( typeid(*rndA) == typeid(*rndA_1) );
+}
Index: ThirdParty/CodePatterns/src/Patterns/unittests/FactoryUnitTest.hpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/FactoryUnitTest.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/FactoryUnitTest.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,44 @@
+/*
+ * FactoryUnitTest.hpp
+ *
+ *  Created on: Jan 03, 2011
+ *      Author: heber
+ */
+
+#ifndef FACTORYUNITTEST_HPP_
+#define FACTORYUNITTEST_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+class ICreatorStub;
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class FactoryTest : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( FactoryTest );
+  CPPUNIT_TEST ( DistributionTest );
+  CPPUNIT_TEST ( getProductEnumTest );
+  CPPUNIT_TEST ( getProductNameTest );
+  CPPUNIT_TEST ( getProductTypeTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void DistributionTest();
+  void getProductEnumTest();
+  void getProductNameTest();
+  void getProductTypeTest();
+
+private:
+  ICreatorStub * rndA;
+  ICreatorStub * rndB;
+  ICreatorStub * rndA_1;
+};
+
+#endif /* FACTORYUNITTEST_HPP_ */
Index: ThirdParty/CodePatterns/src/Patterns/unittests/Makefile.am
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/Makefile.am	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/Makefile.am	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,210 @@
+# PLEASE adhere to the alphabetical ordering in this Makefile!
+# Also indentation by a single tab
+
+# NOTE that all paths are relative to ./src (because we get included there!)
+
+TESTS += \
+	AtomicInstanceUnitTest \
+	CacheableUnitTest \
+	CloneUnitTest \
+	CreatorUnitTest \
+	FactoryUnitTest \
+	ManipulableCloneUnitTest \
+	ManipulablePrototypeFactoryUnitTest \
+	ObservedValueUnitTest \
+	PrototypeFactoryUnitTest \
+	RegistryUnitTest \
+	SingletonUnitTest
+
+TESTSOURCES += \
+	../Patterns/unittests/AtomicInstanceUnitTest.cpp \
+	../Patterns/unittests/CacheableUnitTest.cpp \
+	../Patterns/unittests/CloneUnitTest.cpp \
+	../Patterns/unittests/CreatorUnitTest.cpp \
+	../Patterns/unittests/FactoryUnitTest.cpp \
+	../Patterns/unittests/ManipulableCloneUnitTest.cpp \
+	../Patterns/unittests/ManipulablePrototypeFactoryUnitTest.cpp \
+	../Patterns/unittests/ObservedValueUnitTest.cpp \
+	../Patterns/unittests/PrototypeFactoryUnitTest.cpp \
+	../Patterns/unittests/RegistryUnitTest.cpp \
+	../Patterns/unittests/SingletonUnitTest.cpp \
+	../Patterns/unittests/stubs/Cacheable_threeNumbers.cpp \
+	../Patterns/unittests/stubs/CloneStub.cpp \
+	../Patterns/unittests/stubs/CommonStub.cpp \
+	../Patterns/unittests/stubs/CommonNamedStub.cpp \
+	../Patterns/unittests/stubs/FactoryStub.cpp \
+	../Patterns/unittests/stubs/ManipulableCloneStub.cpp \
+	../Patterns/unittests/stubs/ManipulablePrototypeFactoryStub.cpp \
+	../Patterns/unittests/stubs/ObservedValue_threeNumbers.cpp \
+	../Patterns/unittests/stubs/PrototypeFactoryStub.cpp \
+	../Patterns/unittests/stubs/RegistryStub.cpp
+
+TESTHEADERS += \
+	../Patterns/unittests/CacheableUnitTest.hpp \
+	../Patterns/unittests/CloneUnitTest.hpp \
+	../Patterns/unittests/CreatorUnitTest.hpp \
+	../Patterns/unittests/FactoryUnitTest.hpp \
+	../Patterns/unittests/ManipulableCloneUnitTest.hpp \
+	../Patterns/unittests/ManipulablePrototypeFactoryUnitTest.hpp \
+	../Patterns/unittests/ObservedValueUnitTest.hpp \
+	../Patterns/unittests/PrototypeFactoryUnitTest.hpp \
+	../Patterns/unittests/RegistryUnitTest.hpp \
+	../Patterns/unittests/SingletonUnitTest.hpp \
+	../Patterns/unittests/stubs/Cacheable_threeNumbers.hpp \
+	../Patterns/unittests/stubs/CloneStub.hpp \
+	../Patterns/unittests/stubs/CommonStub.hpp \
+	../Patterns/unittests/stubs/CommonNamedStub.hpp \
+	../Patterns/unittests/stubs/CommonParametersStub.hpp \
+	../Patterns/unittests/stubs/CreatorStub.hpp \
+	../Patterns/unittests/stubs/FactoryStub.hpp \
+	../Patterns/unittests/stubs/ManipulableCloneStub.hpp \
+	../Patterns/unittests/stubs/ManipulablePrototypeFactoryStub.hpp \
+	../Patterns/unittests/stubs/PrototypeFactoryStub.hpp \
+	../Patterns/unittests/stubs/FactoryStub.def \
+	../Patterns/unittests/stubs/FactoryStub.undef \
+	../Patterns/unittests/stubs/ManipulablePrototypeFactoryStub.def \
+	../Patterns/unittests/stubs/ManipulablePrototypeFactoryStub.undef \
+	../Patterns/unittests/stubs/ObservedValue_threeNumbers.hpp \
+	../Patterns/unittests/stubs/PrototypeFactoryStub.def \
+	../Patterns/unittests/stubs/PrototypeFactoryStub.undef \
+	../Patterns/unittests/stubs/RegistryStub.hpp
+
+check_PROGRAMS += $(TESTS) 
+noinst_PROGRAMS += $(TESTS)
+
+AtomicInstanceUnitTest_SOURCES = UnitTestMain.cpp \
+	../Patterns/unittests/AtomicInstanceUnitTest.cpp \
+	../Patterns/unittests/AtomicInstanceUnitTest.hpp
+AtomicInstanceUnitTest_LDADD = \
+	../Helpers/libcodepatterns-Helpers-debug.la
+
+CacheableUnitTest_SOURCES = UnitTestMain.cpp \
+	../Patterns/unittests/CacheableUnitTest.cpp \
+	../Patterns/unittests/CacheableUnitTest.hpp \
+	../Patterns/unittests/stubs/Cacheable_threeNumbers.cpp \
+	../Patterns/unittests/stubs/Cacheable_threeNumbers.hpp
+nodist_CacheableUnitTest_SOURCES = \
+	$(top_srcdir)/src/CodePatterns/Cachable.hpp \
+	$(top_srcdir)/src/CodePatterns/Observer/Observer.hpp \
+	$(top_srcdir)/src/CodePatterns/Observer/ObserverIterator.hpp
+CacheableUnitTest_LDADD = \
+	../Observer/libcodepatterns-Observer-debug.la \
+	../Patterns/libcodepatterns-Patterns-debug.la \
+	../Helpers/libcodepatterns-Helpers-debug.la
+
+CloneUnitTest_SOURCES = UnitTestMain.cpp \
+	../Patterns/unittests/CloneUnitTest.cpp \
+	../Patterns/unittests/CloneUnitTest.hpp \
+	../Patterns/unittests/stubs/CommonStub.cpp \
+	../Patterns/unittests/stubs/CommonStub.hpp \
+	../Patterns/unittests/stubs/CloneStub.cpp \
+	../Patterns/unittests/stubs/CloneStub.hpp
+nodist_CloneUnitTest_SOURCES = \
+	$(top_srcdir)/src/CodePatterns/Clone.hpp
+CloneUnitTest_LDADD = \
+	../Helpers/libcodepatterns-Helpers-debug.la
+
+CreatorUnitTest_SOURCES = UnitTestMain.cpp \
+	../Patterns/unittests/CreatorUnitTest.cpp \
+	../Patterns/unittests/CreatorUnitTest.hpp \
+	../Patterns/unittests/stubs/CommonStub.cpp \
+	../Patterns/unittests/stubs/CommonStub.hpp \
+	../Patterns/unittests/stubs/CreatorStub.hpp
+nodist_CreatorUnitTest_SOURCES = \
+	$(top_srcdir)/src/CodePatterns/Creator.hpp
+CreatorUnitTest_LDADD = \
+	../Helpers/libcodepatterns-Helpers-debug.la
+
+FactoryUnitTest_SOURCES = UnitTestMain.cpp \
+	../Patterns/unittests/FactoryUnitTest.cpp \
+	../Patterns/unittests/FactoryUnitTest.hpp \
+	../Patterns/unittests/stubs/CommonStub.cpp \
+	../Patterns/unittests/stubs/CommonStub.hpp \
+	../Patterns/unittests/stubs/CreatorStub.hpp \
+	../Patterns/unittests/stubs/FactoryStub.hpp \
+	../Patterns/unittests/stubs/FactoryStub.cpp
+nodist_FactoryUnitTest_SOURCES = \
+	$(top_srcdir)/src/CodePatterns/Factory.hpp \
+	$(top_srcdir)/src/CodePatterns/FactoryTypeList.hpp \
+	$(top_srcdir)/src/CodePatterns/Factory_impl.hpp
+FactoryUnitTest_LDADD = \
+	../Helpers/libcodepatterns-Helpers-debug.la
+
+ManipulableCloneUnitTest_SOURCES = UnitTestMain.cpp \
+	../Patterns/unittests/ManipulableCloneUnitTest.cpp \
+	../Patterns/unittests/ManipulableCloneUnitTest.hpp \
+	../Patterns/unittests/stubs/CommonStub.cpp \
+	../Patterns/unittests/stubs/CommonStub.hpp \
+	../Patterns/unittests/stubs/ManipulableCloneStub.cpp \
+	../Patterns/unittests/stubs/ManipulableCloneStub.hpp
+nodist_ManipulableCloneUnitTest_SOURCES = \
+	$(top_srcdir)/src/CodePatterns/ManipulableClone.hpp
+ManipulableCloneUnitTest_LDADD = \
+	../Helpers/libcodepatterns-Helpers-debug.la
+
+ManipulablePrototypeFactoryUnitTest_SOURCES = UnitTestMain.cpp \
+	../Patterns/unittests/ManipulablePrototypeFactoryUnitTest.cpp \
+	../Patterns/unittests/ManipulablePrototypeFactoryUnitTest.hpp \
+	../Patterns/unittests/stubs/ManipulableCloneStub.cpp \
+	../Patterns/unittests/stubs/ManipulableCloneStub.hpp \
+	../Patterns/unittests/stubs/CommonStub.cpp \
+	../Patterns/unittests/stubs/CommonStub.hpp \
+	../Patterns/unittests/stubs/ManipulablePrototypeFactoryStub.hpp \
+	../Patterns/unittests/stubs/ManipulablePrototypeFactoryStub.cpp
+nodist_ManipulablePrototypeFactoryUnitTest_SOURCES = \
+	$(top_srcdir)/src/CodePatterns/ManipulablePrototypeFactory.hpp \
+	$(top_srcdir)/src/CodePatterns/FactoryTypeList.hpp \
+	$(top_srcdir)/src/CodePatterns/ManipulablePrototypeFactory_impl.hpp
+ManipulablePrototypeFactoryUnitTest_LDADD = \
+	../Helpers/libcodepatterns-Helpers-debug.la
+
+ObservedValueUnitTest_SOURCES = UnitTestMain.cpp \
+	../Patterns/unittests/ObservedValueUnitTest.cpp \
+	../Patterns/unittests/ObservedValueUnitTest.hpp \
+	../Patterns/unittests/stubs/ObservedValue_threeNumbers.cpp \
+	../Patterns/unittests/stubs/ObservedValue_threeNumbers.hpp
+nodist_ObservedValueUnitTest_SOURCES = \
+	$(top_srcdir)/src/CodePatterns/ObservedValue.hpp \
+	$(top_srcdir)/src/CodePatterns/Observer/Observer.hpp
+ObservedValueUnitTest_LDADD = \
+	../Observer/libcodepatterns-Observer-debug.la \
+	../Patterns/libcodepatterns-Patterns-debug.la \
+	../Helpers/libcodepatterns-Helpers-debug.la
+
+PrototypeFactoryUnitTest_SOURCES = UnitTestMain.cpp \
+	../Patterns/unittests/PrototypeFactoryUnitTest.cpp \
+	../Patterns/unittests/PrototypeFactoryUnitTest.hpp \
+	../Patterns/unittests/stubs/CloneStub.cpp \
+	../Patterns/unittests/stubs/CloneStub.hpp \
+	../Patterns/unittests/stubs/CommonStub.cpp \
+	../Patterns/unittests/stubs/CommonStub.hpp \
+	../Patterns/unittests/stubs/PrototypeFactoryStub.hpp \
+	../Patterns/unittests/stubs/PrototypeFactoryStub.cpp
+nodist_PrototypeFactoryUnitTest_SOURCES = \
+	$(top_srcdir)/src/CodePatterns/PrototypeFactory.hpp \
+	$(top_srcdir)/src/CodePatterns/FactoryTypeList.hpp \
+	$(top_srcdir)/src/CodePatterns/PrototypeFactory_impl.hpp
+PrototypeFactoryUnitTest_LDADD = \
+	../Helpers/libcodepatterns-Helpers-debug.la
+
+RegistryUnitTest_SOURCES = UnitTestMain.cpp \
+	../Patterns/unittests/RegistryUnitTest.cpp \
+	../Patterns/unittests/RegistryUnitTest.hpp \
+	../Patterns/unittests/stubs/CommonNamedStub.cpp \
+	../Patterns/unittests/stubs/CommonNamedStub.hpp \
+	../Patterns/unittests/stubs/RegistryStub.cpp \
+	../Patterns/unittests/stubs/RegistryStub.hpp
+nodist_RegistryUnitTest_SOURCES = \
+	$(top_srcdir)/src/CodePatterns/Registry.hpp \
+	$(top_srcdir)/src/CodePatterns/Registry_impl.hpp
+RegistryUnitTest_LDADD = \
+	../Helpers/libcodepatterns-Helpers-debug.la
+
+SingletonUnitTest_SOURCES = UnitTestMain.cpp \
+	../Patterns/unittests/SingletonUnitTest.cpp \
+	../Patterns/unittests/SingletonUnitTest.hpp
+#nodist_SingletonUnitTest_SOURCES =
+SingletonUnitTest_LDADD = \
+	../Helpers/libcodepatterns-Helpers-debug.la
+
+#AUTOMAKE_OPTIONS = parallel-tests
Index: ThirdParty/CodePatterns/src/Patterns/unittests/ManipulableCloneUnitTest.cpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/ManipulableCloneUnitTest.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/ManipulableCloneUnitTest.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,131 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+/*
+ * ManipulableCloneUnitTest.cpp
+ *
+ *  Created on: Jan 06, 2011
+ *      Author: heber
+ */
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "ManipulableCloneUnitTest.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "CodePatterns/Assert.hpp"
+
+#include "CodePatterns/ManipulableClone.hpp"
+#include "stubs/ManipulableCloneStub.hpp"
+#include "stubs/CommonParametersStub.hpp"
+
+#include <typeinfo>
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( ManipulableCloneTest );
+
+
+void ManipulableCloneTest::setUp()
+{
+  ip1 = &p1;
+  CPPUNIT_ASSERT( ip1 == &p1 );
+  ip2 = &p2;
+  CPPUNIT_ASSERT( ip2 == &p2 );
+
+  ip1_1 = NULL;
+  ip1_2 = NULL;
+  ip2_1 = NULL;
+  ip2_2 = NULL;
+}
+
+void ManipulableCloneTest::tearDown()
+{
+  // NULL pointer may be deleted.
+  delete ip1_1;
+  delete ip1_2;
+  delete ip2_1;
+  delete ip2_2;
+}
+
+void ManipulableCloneTest::CreationTest()
+{
+  // test that new instances have been created.
+  ip1_1 = p1.clone();
+  ip1_2 = p1.clone();
+  CPPUNIT_ASSERT( ip1 != ip1_1 );
+  CPPUNIT_ASSERT( ip1 != ip1_2 );
+
+  ip2_1 = p2.clone();
+  ip2_2 = p2.clone();
+  CPPUNIT_ASSERT( ip2 != ip2_1 );
+  CPPUNIT_ASSERT( ip2 != ip2_2 );
+}
+
+void ManipulableCloneTest::IndividualityTest()
+{
+  CPPUNIT_ASSERT( typeid(p1).name() != typeid(p2).name() );
+  p1.count();
+  p2.count();
+  p2.count();
+
+  // make refs to interface
+  ip1 = &p1;
+  CPPUNIT_ASSERT( ip1 == &p1 );
+  ip2 = &p2;
+  CPPUNIT_ASSERT( ip2 == &p2 );
+
+  // clone (i.e. counter = p?.counter ), ...
+  ip1_1 = p1.clone();
+  ip1_2 = p1.clone();
+  ip2_1 = p2.clone();
+  ip2_2 = p2.clone();
+
+  // check that each is individual
+  CPPUNIT_ASSERT_EQUAL( ip1->getcount(), ip1_1->getcount() );
+  CPPUNIT_ASSERT_EQUAL( ip1->getcount(), ip1_2->getcount() );
+  CPPUNIT_ASSERT_EQUAL( ip2->getcount(), ip2_1->getcount() );
+  CPPUNIT_ASSERT_EQUAL( ip2->getcount(), ip2_2->getcount() );
+
+  // increase individual counters and check against others
+  ip1_1->count();
+  CPPUNIT_ASSERT( ip1->getcount() != ip1_1->getcount() );
+  CPPUNIT_ASSERT( ip1_1->getcount() != ip1_2->getcount() );
+  CPPUNIT_ASSERT( ip1->getcount() == ip1_2->getcount() );
+
+  ip1_2->count();
+  CPPUNIT_ASSERT( ip1_1->getcount() == ip1_2->getcount() );
+  CPPUNIT_ASSERT( ip1->getcount() != ip1_2->getcount() );
+
+  ip1_2->count();
+  CPPUNIT_ASSERT( ip1_1->getcount() != ip1_2->getcount() );
+  CPPUNIT_ASSERT( ip1->getcount()   != ip1_2->getcount() );
+}
+
+void ManipulableCloneTest::ManipulationTest()
+{
+  ip1_1 = p1.clone();
+  CPPUNIT_ASSERT_EQUAL( 0, ip1_1->getcount() );
+  teststubs::classParameters params;
+  params.counter= 100;
+  ip1_2 = p1.manipulatedclone(params);
+  CPPUNIT_ASSERT_EQUAL( 100, ip1_2->getcount() );
+
+  ip2_1 = p2.clone();
+  CPPUNIT_ASSERT_EQUAL( 0, ip2_1->getcount() );
+
+  CPPUNIT_ASSERT( ip1_1->getcount() != ip1_2->getcount() );
+}
Index: ThirdParty/CodePatterns/src/Patterns/unittests/ManipulableCloneUnitTest.hpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/ManipulableCloneUnitTest.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/ManipulableCloneUnitTest.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,50 @@
+/*
+ * ManipulableCloneUnitTest.hpp
+ *
+ *  Created on: Jan 06, 2011
+ *      Author: heber
+ */
+
+#ifndef MANIPULABLECLONEUNITTEST_HPP_
+#define MANIPULABLECLONEUNITTEST_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "stubs/CommonStub.hpp"
+#include "stubs/ManipulableCloneStub.hpp"
+#include "stubs/CommonParametersStub.hpp"
+
+
+class ManipulableCloneTest : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( ManipulableCloneTest );
+  CPPUNIT_TEST ( CreationTest );
+  CPPUNIT_TEST ( IndividualityTest );
+  CPPUNIT_TEST ( ManipulationTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void CreationTest();
+  void IndividualityTest();
+  void ManipulationTest();
+
+private:
+  ManipulablePrototype<teststubs::Aclass> p1;
+  ManipulablePrototype<teststubs::Bclass> p2;
+  IManipulablePrototype *ip1;
+  IManipulablePrototype *ip1_1;
+  IManipulablePrototype *ip1_2;
+  IManipulablePrototype *ip2;
+  IManipulablePrototype *ip2_1;
+  IManipulablePrototype *ip2_2;
+};
+
+#endif /* MANIPULABLECLONEUNITTEST_HPP_ */
Index: ThirdParty/CodePatterns/src/Patterns/unittests/ManipulablePrototypeFactoryUnitTest.cpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/ManipulablePrototypeFactoryUnitTest.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/ManipulablePrototypeFactoryUnitTest.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,175 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+/*
+ * ManipulablePrototypeFactoryUnitTest.cpp
+ *
+ *  Created on: Jan 03, 2011
+ *      Author: heber
+ */
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include "CodePatterns/Assert.hpp"
+
+#include "ManipulablePrototypeFactoryUnitTest.hpp"
+
+#include "stubs/CommonStub.hpp"
+#include "stubs/ManipulableCloneStub.hpp"
+#include "stubs/ManipulablePrototypeFactoryStub.hpp"
+
+#include <typeinfo>
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( ManipulablePrototypeFactoryTest );
+
+void ManipulablePrototypeFactoryTest::setUp()
+{
+  rndA =
+      ManipulablePrototypeFactoryStub::getInstance().
+      ManipulablePrototypeTable[ManipulablePrototypeFactoryStub::Aclass]->clone();
+  CPPUNIT_ASSERT_EQUAL( 0,  rndA->getcount() );
+  rndB =
+      ManipulablePrototypeFactoryStub::getInstance().
+      ManipulablePrototypeTable[ManipulablePrototypeFactoryStub::Bclass]->clone();
+  CPPUNIT_ASSERT_EQUAL( 0,  rndB->getcount() );
+
+  rndA_1 = NULL;
+  rndA_2 = NULL;
+  rndA_3 = NULL;
+}
+
+void ManipulablePrototypeFactoryTest::tearDown()
+{
+  delete rndA;
+  delete rndA_1;
+  delete rndA_2;
+  delete rndA_3;
+  delete rndB;
+  ManipulablePrototypeFactoryStub::purgeInstance();
+}
+
+void ManipulablePrototypeFactoryTest::DistributionTest()
+{
+  // check the injectiveness of enum and string map
+  for (ManipulablePrototypeFactoryStub::NameMap::const_iterator
+      iter = ManipulablePrototypeFactoryStub::getInstance().names.begin();
+      iter != ManipulablePrototypeFactoryStub::getInstance().names.end();
+      ++iter) {
+    CPPUNIT_ASSERT_EQUAL(
+        iter->second,
+        ManipulablePrototypeFactoryStub::getInstance().getName(
+            ManipulablePrototypeFactoryStub::getInstance().getEnum(
+                iter->second
+            )
+        )
+    );
+  }
+
+  // check distributions in the table
+  CPPUNIT_ASSERT_EQUAL(
+      std::string(typeid(ManipulablePrototype<teststubs::Aclass>).name()),
+      std::string(typeid(*rndA).name())
+  );
+  CPPUNIT_ASSERT_EQUAL(
+      std::string(typeid(ManipulablePrototype<teststubs::Bclass>).name()),
+      std::string(typeid(*rndB).name())
+  );
+}
+
+void ManipulablePrototypeFactoryTest::getProductEnumTest()
+{
+  rndA_1 =
+      ManipulablePrototypeFactoryStub::getInstance().getProduct(ManipulablePrototypeFactoryStub::Aclass);
+  CPPUNIT_ASSERT( typeid(*rndA) == typeid(*rndA_1) );
+}
+
+void ManipulablePrototypeFactoryTest::getProductNameTest()
+{
+  rndA_1 =
+      ManipulablePrototypeFactoryStub::getInstance().getProduct(std::string("Aclass"));
+  CPPUNIT_ASSERT( typeid(*rndA) == typeid(*rndA_1) );
+}
+
+void ManipulablePrototypeFactoryTest::getProductTypeTest()
+{
+  rndA_1 =
+      ManipulablePrototypeFactoryStub::getInstance().getProduct( typeid(teststubs::Aclass) );
+  CPPUNIT_ASSERT( typeid(*rndA) == typeid(*rndA_1) );
+}
+
+void ManipulablePrototypeFactoryTest::Individualitytest()
+{
+  // increasing this does not change the prototype
+  rndA->count();
+
+  rndA_1 = ManipulablePrototypeFactoryStub::getInstance().getProduct(ManipulablePrototypeFactoryStub::Aclass);
+  CPPUNIT_ASSERT_EQUAL( 0,  rndA_1->getcount() );
+  CPPUNIT_ASSERT( rndA->getcount() != rndA_1->getcount() );
+  rndA_1->count();
+  CPPUNIT_ASSERT( rndA->getcount() == rndA_1->getcount() );
+
+  rndA_2 = ManipulablePrototypeFactoryStub::getInstance().getProduct(ManipulablePrototypeFactoryStub::Aclass);
+  CPPUNIT_ASSERT_EQUAL( 0,  rndA_2->getcount() );
+  CPPUNIT_ASSERT( rndA->getcount() != rndA_2->getcount() );
+  rndA_2->count();
+  CPPUNIT_ASSERT( rndA->getcount() == rndA_2->getcount() );
+  CPPUNIT_ASSERT( rndA_1->getcount() == rndA_2->getcount() );
+}
+
+void ManipulablePrototypeFactoryTest::getPrototypetest()
+{
+  // this method is protected and only friends may access it.
+  IManipulablePrototype &rndA_1c = ManipulablePrototypeFactoryStub::getInstance().getPrototype(std::string("Aclass"));
+  CPPUNIT_ASSERT_EQUAL( 0, rndA_1c.getcount() );
+
+  // clone the type and check whether new default values holds
+  rndA_2 = ManipulablePrototypeFactoryStub::getInstance().getProduct(ManipulablePrototypeFactoryStub::Aclass);
+  CPPUNIT_ASSERT_EQUAL( rndA_1c.getcount(), rndA_2->getcount() );
+  rndA_2->count();
+  CPPUNIT_ASSERT( rndA_1c.getcount() != rndA_2->getcount() );
+
+  // the following is possible (with PrototypeFactory not!)
+  rndA_1c.count();
+  CPPUNIT_ASSERT_EQUAL( 1, rndA_1c.getcount() );
+
+  // rndA has been cloned before we have manipulated the prototype
+  CPPUNIT_ASSERT( rndA->getcount() != rndA_2->getcount() );
+
+  // prototype is at 1, has been manipulated!
+  rndA_3 = ManipulablePrototypeFactoryStub::getInstance().getProduct(ManipulablePrototypeFactoryStub::Aclass);
+  CPPUNIT_ASSERT_EQUAL( 1, rndA_3->getcount() );
+
+  // rndA is older, before manipulation, hence still at 0
+  CPPUNIT_ASSERT( rndA->getcount() != rndA_3->getcount() );
+}
+
+void ManipulablePrototypeFactoryTest::manipulatePrototypetest()
+{
+  teststubs::classParameters params;
+  params.counter = 100;
+  ManipulablePrototypeFactoryStub::getInstance().manipulatePrototype(std::string("Aclass"), params);
+
+  rndA_1 = ManipulablePrototypeFactoryStub::getInstance().getProduct(std::string("Aclass"));
+  CPPUNIT_ASSERT( 100 == rndA_1->getcount() );
+
+  rndA_1->count();
+  CPPUNIT_ASSERT( 101 == rndA_1->getcount() );
+
+  rndA_2 = ManipulablePrototypeFactoryStub::getInstance().getProduct(std::string("Aclass"));
+  CPPUNIT_ASSERT( 100 == rndA_2->getcount() );
+  CPPUNIT_ASSERT( rndA_1->getcount() != rndA_2->getcount() );
+}
Index: ThirdParty/CodePatterns/src/Patterns/unittests/ManipulablePrototypeFactoryUnitTest.hpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/ManipulablePrototypeFactoryUnitTest.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/ManipulablePrototypeFactoryUnitTest.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,52 @@
+/*
+ * ManipulablePrototypeFactoryUnitTest.hpp
+ *
+ *  Created on: Jan 03, 2011
+ *      Author: heber
+ */
+
+#ifndef MANIPULABLEPROTOTYPEFACTORYUNITTEST_HPP_
+#define MANIPULABLEPROTOTYPEFACTORYUNITTEST_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class IManipulablePrototype;
+
+class ManipulablePrototypeFactoryTest : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( ManipulablePrototypeFactoryTest );
+  CPPUNIT_TEST ( DistributionTest );
+  CPPUNIT_TEST ( getProductEnumTest );
+  CPPUNIT_TEST ( getProductNameTest );
+  CPPUNIT_TEST ( getProductTypeTest );
+  CPPUNIT_TEST ( Individualitytest );
+  CPPUNIT_TEST ( getPrototypetest );
+  CPPUNIT_TEST ( manipulatePrototypetest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void DistributionTest();
+  void getProductEnumTest();
+  void getProductNameTest();
+  void getProductTypeTest();
+  void Individualitytest();
+  void getPrototypetest();
+  void manipulatePrototypetest();
+
+private:
+  IManipulablePrototype* rndA;
+  IManipulablePrototype* rndA_1;
+  IManipulablePrototype* rndA_2;
+  IManipulablePrototype* rndA_3;
+  IManipulablePrototype* rndB;
+};
+
+#endif /* MANIPULABLEPROTOTYPEFACTORYUNITTEST_HPP_ */
Index: ThirdParty/CodePatterns/src/Patterns/unittests/ObservedValueUnitTest.cpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/ObservedValueUnitTest.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/ObservedValueUnitTest.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,72 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2015 Frederik Heber. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * ObservedValueUnitTest.cpp
+ *
+ *  Created on: Jun 19, 2015
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "ObservedValueUnitTest.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <boost/bind.hpp>
+
+#include "CodePatterns/ObservedValue.hpp"
+
+#include "stubs/ObservedValue_threeNumbers.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( ObservedValueTest );
+
+void ObservedValueTest::setUp(){
+  numbers = new ObservedValue_threeNumbers(1,2,3);
+  Observable::channels_t ychannel(1, ObservedValue_threeNumbers::YChanged);
+  YChange_numbers = new ObservedValue_threeNumbers(1,2,3, ychannel);
+}
+
+void ObservedValueTest::tearDown(){
+  delete numbers;
+  delete YChange_numbers;
+}
+
+void ObservedValueTest::doesRecalcTest()
+{
+  CPPUNIT_ASSERT_EQUAL( 6, (numbers->sum).get());
+  CPPUNIT_ASSERT_EQUAL( false, numbers->hasRecalced);
+  numbers->hasRecalced=false;
+  numbers->setX(4);
+  CPPUNIT_ASSERT_EQUAL( true, numbers->hasRecalced);
+  CPPUNIT_ASSERT_EQUAL( 9, (numbers->sum).get());
+  CPPUNIT_ASSERT_EQUAL( true, numbers->hasRecalced);
+
+  CPPUNIT_ASSERT_EQUAL( 6, (YChange_numbers->sum).get());
+  CPPUNIT_ASSERT_EQUAL( false, YChange_numbers->hasRecalced);
+  YChange_numbers->hasRecalced=false;
+  YChange_numbers->setX(4);
+  CPPUNIT_ASSERT_EQUAL( false, YChange_numbers->hasRecalced);
+  CPPUNIT_ASSERT_EQUAL( 6, (YChange_numbers->sum).get());
+  YChange_numbers->hasRecalced=false;
+  YChange_numbers->setY(4);
+  CPPUNIT_ASSERT_EQUAL( true, YChange_numbers->hasRecalced);
+  CPPUNIT_ASSERT_EQUAL( 11, (YChange_numbers->sum).get());
+}
Index: ThirdParty/CodePatterns/src/Patterns/unittests/ObservedValueUnitTest.hpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/ObservedValueUnitTest.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/ObservedValueUnitTest.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,36 @@
+/*
+ * ObservedValueUnitTest.hpp
+ *
+ *  Created on: Jun 19, 2015
+ *      Author: heber
+ */
+
+#ifndef OBSERVEDVALUEUNITTEST_HPP_
+#define OBSERVEDVALUEUNITTEST_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <cppunit/extensions/HelperMacros.h>
+
+// stub classes
+class ObservedValue_threeNumbers;
+
+class ObservedValueTest :  public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( ObservedValueTest );
+  CPPUNIT_TEST ( doesRecalcTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void doesRecalcTest();
+  ObservedValue_threeNumbers *numbers;
+  ObservedValue_threeNumbers *YChange_numbers;
+};
+
+#endif /* OBSERVEDVALUEUNITTEST_HPP_ */
Index: ThirdParty/CodePatterns/src/Patterns/unittests/PrototypeFactoryUnitTest.cpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/PrototypeFactoryUnitTest.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/PrototypeFactoryUnitTest.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,149 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+/*
+ * PrototypeFactoryUnitTest.cpp
+ *
+ *  Created on: Jan 03, 2011
+ *      Author: heber
+ */
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include "CodePatterns/Assert.hpp"
+
+#include "PrototypeFactoryUnitTest.hpp"
+
+#include "stubs/CommonStub.hpp"
+#include "stubs/PrototypeFactoryStub.hpp"
+
+#include <typeinfo>
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( PrototypeFactoryTest );
+
+void PrototypeFactoryTest::setUp()
+{
+  rndA =
+      PrototypeFactoryStub::getInstance().
+      PrototypeTable[PrototypeFactoryStub::Aclass]->clone();
+  CPPUNIT_ASSERT_EQUAL( 0,  rndA->getcount() );
+  rndB =
+      PrototypeFactoryStub::getInstance().
+      PrototypeTable[PrototypeFactoryStub::Bclass]->clone();
+  CPPUNIT_ASSERT_EQUAL( 0,  rndB->getcount() );
+
+  rndA_1 = NULL;
+  rndA_2 = NULL;
+  rndA_3 = NULL;
+}
+
+void PrototypeFactoryTest::tearDown()
+{
+  delete rndA;
+  delete rndA_1;
+  delete rndA_2;
+  delete rndA_3;
+  delete rndB;
+  PrototypeFactoryStub::purgeInstance();
+}
+
+void PrototypeFactoryTest::DistributionTest()
+{
+  // check the injectiveness of enum and string map
+  for (PrototypeFactoryStub::NameMap::const_iterator
+      iter = PrototypeFactoryStub::getInstance().names.begin();
+      iter != PrototypeFactoryStub::getInstance().names.end();
+      ++iter) {
+    CPPUNIT_ASSERT_EQUAL(
+        iter->second,
+        PrototypeFactoryStub::getInstance().getName(
+            PrototypeFactoryStub::getInstance().getEnum(
+                iter->second
+            )
+        )
+    );
+  }
+
+  // check distributions in the table
+  CPPUNIT_ASSERT_EQUAL(
+      std::string(typeid(Prototype<teststubs::Aclass>).name()),
+      std::string(typeid(*rndA).name())
+  );
+  CPPUNIT_ASSERT_EQUAL(
+      std::string(typeid(Prototype<teststubs::Bclass>).name()),
+      std::string(typeid(*rndB).name())
+  );
+}
+
+void PrototypeFactoryTest::getProductEnumTest()
+{
+  rndA_1 =
+      PrototypeFactoryStub::getInstance().getProduct(PrototypeFactoryStub::Aclass);
+  CPPUNIT_ASSERT( typeid(*rndA) == typeid(*rndA_1) );
+}
+
+void PrototypeFactoryTest::getProductNameTest()
+{
+  rndA_1 =
+      PrototypeFactoryStub::getInstance().getProduct(std::string("Aclass"));
+  CPPUNIT_ASSERT( typeid(*rndA) == typeid(*rndA_1) );
+}
+
+void PrototypeFactoryTest::getProductTypeTest()
+{
+  rndA_1 =
+      PrototypeFactoryStub::getInstance().getProduct( typeid(teststubs::Aclass) );
+  CPPUNIT_ASSERT( typeid(*rndA) == typeid(*rndA_1) );
+}
+
+void PrototypeFactoryTest::Individualitytest()
+{
+  // increasing this does not change the prototype
+  rndA->count();
+
+  rndA_1 = PrototypeFactoryStub::getInstance().getProduct(PrototypeFactoryStub::Aclass);
+  CPPUNIT_ASSERT_EQUAL( 0,  rndA_1->getcount() );
+  CPPUNIT_ASSERT( rndA->getcount() != rndA_1->getcount() );
+  rndA_1->count();
+  CPPUNIT_ASSERT( rndA->getcount() == rndA_1->getcount() );
+
+  rndA_2 = PrototypeFactoryStub::getInstance().getProduct(PrototypeFactoryStub::Aclass);
+  CPPUNIT_ASSERT_EQUAL( 0,  rndA_2->getcount() );
+  CPPUNIT_ASSERT( rndA->getcount() != rndA_2->getcount() );
+  rndA_2->count();
+  CPPUNIT_ASSERT( rndA->getcount() == rndA_2->getcount() );
+  CPPUNIT_ASSERT( rndA_1->getcount() == rndA_2->getcount() );
+}
+
+void PrototypeFactoryTest::getPrototypetest()
+{
+  // this method is protected and only friends may access it.
+  const IPrototype& rndA_1c = PrototypeFactoryStub::getInstance().getPrototype(std::string("Aclass"));
+
+  // clone the type and check whether new default values holds
+  rndA_2 = PrototypeFactoryStub::getInstance().getProduct(PrototypeFactoryStub::Aclass);
+  CPPUNIT_ASSERT_EQUAL( rndA_1c.getcount(), rndA_2->getcount() );
+  rndA_2->count();
+  CPPUNIT_ASSERT( rndA_1c.getcount() != rndA_2->getcount() );
+
+  // the following is not possible
+  //rndA_1c.count();
+
+  rndA_3 = PrototypeFactoryStub::getInstance().getProduct(PrototypeFactoryStub::Aclass);
+  CPPUNIT_ASSERT_EQUAL( 0, rndA_3->getcount() );
+  CPPUNIT_ASSERT( rndA->getcount() == rndA_3->getcount() );
+}
Index: ThirdParty/CodePatterns/src/Patterns/unittests/PrototypeFactoryUnitTest.hpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/PrototypeFactoryUnitTest.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/PrototypeFactoryUnitTest.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,50 @@
+/*
+ * PrototypeFactoryUnitTest.hpp
+ *
+ *  Created on: Jan 03, 2011
+ *      Author: heber
+ */
+
+#ifndef PROTOTYPEFACTORYUNITTEST_HPP_
+#define PROTOTYPEFACTORYUNITTEST_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "stubs/CloneStub.hpp"
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class PrototypeFactoryTest : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( PrototypeFactoryTest );
+  CPPUNIT_TEST ( DistributionTest );
+  CPPUNIT_TEST ( getProductEnumTest );
+  CPPUNIT_TEST ( getProductNameTest );
+  CPPUNIT_TEST ( getProductTypeTest );
+  CPPUNIT_TEST ( Individualitytest );
+  CPPUNIT_TEST ( getPrototypetest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void DistributionTest();
+  void getProductEnumTest();
+  void getProductNameTest();
+  void getProductTypeTest();
+  void Individualitytest();
+  void getPrototypetest();
+
+private:
+  IPrototype* rndA;
+  IPrototype* rndA_1;
+  IPrototype* rndA_2;
+  IPrototype* rndA_3;
+  IPrototype* rndB;
+};
+
+#endif /* PROTOTYPEFACTORYUNITTEST_HPP_ */
Index: ThirdParty/CodePatterns/src/Patterns/unittests/RegistryUnitTest.cpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/RegistryUnitTest.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/RegistryUnitTest.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,117 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * RegistryUnitTest.cpp
+ *
+ *  Created on: Oct 27, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include <typeinfo>
+
+#include "stubs/CommonNamedStub.hpp"
+#include "stubs/RegistryStub.hpp"
+
+#include "CodePatterns/Assert.hpp"
+
+#include "RegistryUnitTest.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( RegistryTest );
+
+
+void RegistryTest::setUp()
+{
+  ASSERT_DO(Assert::Throw);
+  registry = new RegistryStub;
+};
+
+
+void RegistryTest::tearDown()
+{
+  delete registry;
+};
+
+void RegistryTest::InOutCheck()
+{
+  // create two test instances to put into the registry
+  teststubs::ANamedclass *instanceA = new teststubs::ANamedclass;
+  teststubs::BNamedclass *instanceB = new teststubs::BNamedclass;
+  teststubs::INamedclass *testinstance = NULL;
+
+  // register both instances
+  registry->registerInstance(instanceA);
+  registry->registerInstance(instanceB);
+
+  // obtain Aclass and see if it matches
+  testinstance = registry->getByName("ANamedclass");
+  CPPUNIT_ASSERT( testinstance == instanceA );
+
+  // re-register instanceA and check if this is admonished
+#ifndef NDEBUG
+  CPPUNIT_ASSERT_THROW(registry->registerInstance(instanceA),Assert::AssertionFailure);
+#endif
+
+  // unregister Aclass and see if there's no more match
+  registry->unregisterInstance(instanceA);
+  testinstance = NULL;
+#ifndef NDEBUG
+  CPPUNIT_ASSERT_THROW((testinstance = registry->getByName("ANamedclass")),Assert::AssertionFailure);
+#else
+  testinstance = registry->getByName("ANamedclass");
+#endif
+  CPPUNIT_ASSERT( testinstance == NULL );
+
+  // obtain Bclass and see if it matches
+  testinstance = registry->getByName("BNamedclass");
+  CPPUNIT_ASSERT( testinstance == instanceB );
+
+  // unregister Aclass and see if there's no more match
+  registry->unregisterInstance(instanceB);
+  testinstance = NULL;
+#ifndef NDEBUG
+  CPPUNIT_ASSERT_THROW((testinstance = registry->getByName("BNamedclass")),Assert::AssertionFailure);
+#else
+  testinstance = registry->getByName("BNamedclass");
+#endif
+  CPPUNIT_ASSERT( testinstance == NULL );
+  CPPUNIT_ASSERT( testinstance == NULL );
+
+  // check that registry is empty
+  CPPUNIT_ASSERT( registry->getBeginIter() == registry->getEndIter() );
+
+  delete instanceA;
+  delete instanceB;
+}
+
+void RegistryTest::cleanupCheck()
+{
+  // register two test instances
+  registry->registerInstance(new teststubs::ANamedclass);
+  registry->registerInstance(new teststubs::BNamedclass);
+  CPPUNIT_ASSERT( registry->getBeginIter() != registry->getEndIter() );
+
+  // cleanup and check
+  registry->cleanup();
+  CPPUNIT_ASSERT( registry->getBeginIter() == registry->getEndIter() );
+}
Index: ThirdParty/CodePatterns/src/Patterns/unittests/RegistryUnitTest.hpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/RegistryUnitTest.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/RegistryUnitTest.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,39 @@
+/*
+ * RegistryUnitTest.hpp
+ *
+ *  Created on: Oct 27, 2010
+ *      Author: heber
+ */
+
+#ifndef REGISTRYUNITTEST_HPP_
+#define REGISTRYUNITTEST_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class RegistryStub;
+
+/********************************************** Test classes **************************************/
+
+class RegistryTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( RegistryTest) ;
+    CPPUNIT_TEST ( InOutCheck );
+    CPPUNIT_TEST ( cleanupCheck );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+      void InOutCheck();
+      void cleanupCheck();
+
+private:
+      RegistryStub* registry;
+};
+
+#endif /* REGISTRYUNITTEST_HPP_ */
Index: ThirdParty/CodePatterns/src/Patterns/unittests/SingletonUnitTest.cpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/SingletonUnitTest.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/SingletonUnitTest.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,172 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * SingletonUnitTest.cpp
+ *
+ *  Created on: Mar 11, 2010
+ *      Author: crueger
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "SingletonUnitTest.hpp"
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+#include <iostream>
+
+#include "CodePatterns/Singleton.hpp"
+#include "CodePatterns/Singleton_impl.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+CPPUNIT_TEST_SUITE_REGISTRATION( SingletonTest );
+
+// some necessary stubs
+class SingletonStub1 : public Singleton <SingletonStub1>{
+  friend class Singleton<SingletonStub1>;
+private:
+  SingletonStub1(){
+    count1++;
+  }
+  // explicit copy constructor to catch if this is ever called
+  SingletonStub1(const SingletonStub1&){
+    CPPUNIT_FAIL    ( "Copy constructor of Singleton called" );
+  }
+  virtual ~SingletonStub1(){
+    count2++;
+  }
+public:
+  static int count1;
+  static int count2;
+};
+
+int SingletonStub1::count1 = 0;
+int SingletonStub1::count2 = 0;
+
+CONSTRUCT_SINGLETON(SingletonStub1);
+
+class SingletonStub2 : public Singleton<SingletonStub2>{
+  friend class Singleton<SingletonStub2>;
+private:
+  SingletonStub2(){
+    count1++;
+  }
+  // explicit copy constructor to catch if this is ever called
+  SingletonStub2(const SingletonStub2&){
+    CPPUNIT_FAIL    ( "Copy constructor of Singleton called" );
+  }
+  virtual ~SingletonStub2(){
+    count2++;
+  }
+public:
+  static int count1;
+  static int count2;
+};
+
+int SingletonStub2::count1 = 0;
+int SingletonStub2::count2 = 0;
+
+CONSTRUCT_SINGLETON(SingletonStub2);
+
+void SingletonTest::setUp()
+{
+  ASSERT_DO(Assert::Throw);
+}
+
+void SingletonTest::tearDown(){}
+
+void SingletonTest::ConstructionTest(){
+  void *ptr_1_1 = reinterpret_cast<void*>(SingletonStub1::getPointer());
+  void *ptr_1_2 = reinterpret_cast<void*>(SingletonStub1::getPointer());
+  void *ptr_1_3 = reinterpret_cast<void*>(&(SingletonStub1::getInstance()));
+
+  // test if we always get the same instance of our singleton
+  CPPUNIT_ASSERT_EQUAL(ptr_1_1,ptr_1_2);
+  CPPUNIT_ASSERT_EQUAL(ptr_1_1,ptr_1_3);
+
+  void *ptr_2_1 = reinterpret_cast<void*>(SingletonStub2::getPointer());
+  void *ptr_2_2 = reinterpret_cast<void*>(SingletonStub2::getPointer());
+  void *ptr_2_3 = reinterpret_cast<void*>(&(SingletonStub2::getInstance()));
+
+  // same as above but for a different singleton
+  CPPUNIT_ASSERT_EQUAL(ptr_2_1,ptr_2_2);
+  CPPUNIT_ASSERT_EQUAL(ptr_2_1,ptr_2_3);
+
+  // see if the two singletons actually differ
+  CPPUNIT_ASSERT(ptr_1_1!=ptr_2_1);
+
+  // see if each constructor was called exactly once
+  CPPUNIT_ASSERT_EQUAL(1,SingletonStub1::count1);
+  CPPUNIT_ASSERT_EQUAL(1,SingletonStub2::count1);
+  // no calls to the destructor should have occured so far
+  CPPUNIT_ASSERT_EQUAL(0,SingletonStub1::count2);
+  CPPUNIT_ASSERT_EQUAL(0,SingletonStub2::count2);
+
+  SingletonStub1::purgeInstance();
+
+  void *ptr_3_1 = reinterpret_cast<void*>(SingletonStub1::getPointer());
+  void *ptr_3_2 = reinterpret_cast<void*>(SingletonStub1::getPointer());
+
+  // now the constructor should have been called twice
+  CPPUNIT_ASSERT_EQUAL(2,SingletonStub1::count1);
+  // the destructor should have been called once
+  CPPUNIT_ASSERT_EQUAL(1,SingletonStub1::count2);
+  // see if the singleton Assumption holds
+  CPPUNIT_ASSERT_EQUAL(ptr_3_1,ptr_3_2);
+  // Some esoteric thing might cause our pointer to lay at the position of Singleton2 now
+  // See that those two objects still differ
+  CPPUNIT_ASSERT(ptr_3_1!=ptr_2_1);
+  // don't test for pointer difference between first and second singleton here,
+  // because they might be constructed in the same place
+
+
+  SingletonStub2::resetInstance();
+  // now the constructor should have been called twice
+  CPPUNIT_ASSERT_EQUAL(2,SingletonStub2::count1);
+  // the destructor should have been called once
+  CPPUNIT_ASSERT_EQUAL(1,SingletonStub2::count2);
+
+  void *ptr_4_1 = reinterpret_cast<void*>(SingletonStub2::getPointer());
+  void *ptr_4_2 = reinterpret_cast<void*>(SingletonStub2::getPointer());
+
+  // Still only two calls to the constructor, one call to destructor
+  CPPUNIT_ASSERT_EQUAL(2,SingletonStub2::count1);
+  CPPUNIT_ASSERT_EQUAL(1,SingletonStub2::count2);
+
+  // test if Singleton assumption can be broken by reset
+  CPPUNIT_ASSERT_EQUAL(ptr_4_1,ptr_4_2);
+
+  // and again test if we actually have a object seperate from anything else
+  CPPUNIT_ASSERT(ptr_4_1!=ptr_3_1);
+
+
+  // we don't purge our singletons here. Purging should be done automatically by the Singleton
+  // mechanism. Check with Valgrind to see if memory-leak occurs
+  std::cout << "Not purging Singleton!\n Check with Valgrind to see if automatic purgins is working!" << std::endl;
+}
+
+void SingletonTest::LockedTest(){
+  const AtomicInstance<SingletonStub1> ptr_1_1(SingletonStub1::getLockedInstance());
+  const SingletonStub1 &test_1 = *ptr_1_1;
+
+  // this deadlocks
+//  AtomicInstance<SingletonStub1> ptr_1_2(SingletonStub1::getLockedInstance());
+
+  AtomicInstance<SingletonStub2> ptr_2_1(SingletonStub2::getLockedInstance());
+  SingletonStub2 &test_2 = *ptr_2_1;
+
+  // this deadlocks
+//  AtomicInstance<SingletonStub2> ptr_2_2(SingletonStub2::getLockedInstance());
+}
Index: ThirdParty/CodePatterns/src/Patterns/unittests/SingletonUnitTest.hpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/SingletonUnitTest.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/SingletonUnitTest.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,33 @@
+/*
+ * SingletonUnitTest.hpp
+ *
+ *  Created on: Mar 11, 2010
+ *      Author: crueger
+ */
+
+#ifndef SINGLETONUNITTEST_HPP_
+#define SINGLETONUNITTEST_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class SingletonTest : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( SingletonTest );
+  CPPUNIT_TEST ( ConstructionTest );
+  CPPUNIT_TEST ( LockedTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void ConstructionTest();
+  void LockedTest();
+};
+
+#endif /* SINGLETONUNITTEST_HPP_ */
Index: ThirdParty/CodePatterns/src/Patterns/unittests/stubs/Cacheable_threeNumbers.cpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/stubs/Cacheable_threeNumbers.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/stubs/Cacheable_threeNumbers.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,81 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2015 Frederik Heber. 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/>.
+ */
+
+/*
+ * Cacheable_threeNumbers.cpp
+ *
+ *  Created on: Jun 19, 2015
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "Cacheable_threeNumbers.hpp"
+
+#include <algorithm>
+
+#include "CodePatterns/Observer/Channels.hpp"
+
+void Cacheable_threeNumbers::setX(int _x)
+{
+  OBSERVE;
+  NOTIFY(XChanged);
+  x = _x;
+}
+
+void Cacheable_threeNumbers::setY(int _y)
+{
+  OBSERVE;
+  NOTIFY(YChanged);
+  y = _y;
+}
+
+void Cacheable_threeNumbers::setZ(int _z)
+{
+  OBSERVE;
+  NOTIFY(ZChanged);
+  z = _z;
+}
+
+int Cacheable_threeNumbers::calcSum() const
+{
+  hasRecalced = true;
+  return x+y+z;
+}
+
+Cacheable_threeNumbers::Cacheable_threeNumbers(
+    int _x,
+    int _y,
+    int _z,
+    Observable::channels_t channels) :
+  Observable(
+      "Cacheable_threeNumbers",
+      Observable::getChannelList(Cacheable_threeNumbers::NotificationType_MAX)),
+  x(_x),y(_y),z(_z),
+  sum(this,boost::bind(&Cacheable_threeNumbers::calcSum,this),"sum", channels),
+  hasRecalced(false)
+{}
Index: ThirdParty/CodePatterns/src/Patterns/unittests/stubs/Cacheable_threeNumbers.hpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/stubs/Cacheable_threeNumbers.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/stubs/Cacheable_threeNumbers.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,48 @@
+/*
+ * Cacheable_threeNumbers.hpp
+ *
+ *  Created on: Jun 19, 2015
+ *      Author: heber
+ */
+
+#ifndef CACHEABLETHREENUMBERS_HPP_
+#define CACHEABLETHREENUMBERS_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/Cacheable.hpp"
+#include "CodePatterns/Observer/Observable.hpp"
+#include "CodePatterns/Observer/Notification.hpp"
+
+class Cacheable_threeNumbers : public Observable {
+public:
+  int x;
+  int y;
+  int z;
+  Cacheable<int> sum;
+  mutable bool hasRecalced;
+
+  enum NotificationType {
+    XChanged,
+    YChanged,
+    ZChanged,
+    NotificationType_MAX
+  };
+
+  void setX(int _x);
+  void setY(int _y);
+  void setZ(int _z);
+
+  int calcSum() const;
+
+  Cacheable_threeNumbers(
+      int _x,
+      int _y,
+      int _z,
+      Observable::channels_t channels = Observable::channels_t());
+};
+
+#endif /* CACHEABLETHREENUMBERS_HPP_ */
Index: ThirdParty/CodePatterns/src/Patterns/unittests/stubs/CloneStub.cpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/stubs/CloneStub.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/stubs/CloneStub.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,42 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * CloneStub.cpp
+ *
+ *  Created on: Jan 4, 2011
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CloneStub.hpp"
+
+#include "CommonStub.hpp"
+
+/************ Prototype 1 *******************/
+
+template <>
+IPrototype* Prototype<teststubs::Aclass>::clone() const
+{
+  IPrototype *MyClone = new Prototype<teststubs::Aclass>();
+  MyClone->setcount(getcount());
+  return MyClone;
+}
+
+/************ Prototype 2 *******************/
+
+template <>
+IPrototype* Prototype<teststubs::Bclass>::clone() const
+{
+  IPrototype *MyClone = new Prototype<teststubs::Bclass>();
+  MyClone->setcount(getcount());
+  return MyClone;
+}
Index: ThirdParty/CodePatterns/src/Patterns/unittests/stubs/CloneStub.hpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/stubs/CloneStub.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/stubs/CloneStub.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,69 @@
+/*
+ * CloneStub.hpp
+ *
+ *  Created on: Jan 4, 2011
+ *      Author: heber
+ */
+
+#ifndef CLONESTUB_HPP_
+#define CLONESTUB_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/Clone.hpp"
+
+struct IPrototype
+{
+  virtual ~IPrototype() {};
+  virtual void count()=0;
+  virtual int getcount() const =0;
+  virtual void setcount(int const _counter)=0;
+};
+
+class CloneTest;
+class PrototypeFactoryStub;
+
+template <class T>
+class Prototype :
+  public IPrototype,
+  public Clone<IPrototype>
+{
+    /**
+     * Prototype Factory is friend because it needs to access protected cstor
+     * to instantiate prototypes.
+     */
+    friend class PrototypeFactoryStub;
+
+    /**
+     * Tests are friend such that it can access protected cstor.
+     */
+    friend class CloneTest;
+    friend class PrototypeFactoryTest;
+
+protected:
+    Prototype() {
+      member.setcount(0);
+    }
+    ~Prototype() {};
+
+public:
+    void count() {
+      member.count();
+    }
+    int getcount() const {
+      return member.getcount();
+    }
+    void setcount(int const _counter) {
+      member.setcount(_counter);
+    }
+
+    IPrototype* clone() const;
+private:
+    T member;
+};
+
+
+#endif /* CLONESTUB_HPP_ */
Index: ThirdParty/CodePatterns/src/Patterns/unittests/stubs/CommonNamedStub.cpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/stubs/CommonNamedStub.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/stubs/CommonNamedStub.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,39 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * CommonNamedStub.cpp
+ *
+ *  Created on: Jan 16, 2011
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CommonNamedStub.hpp"
+
+namespace teststubs {
+  INamedclass::~INamedclass() {};
+  INamedclass::INamedclass(const std::string &_name) :
+    name(_name)
+  {};
+
+  ANamedclass::ANamedclass() :
+    INamedclass("ANamedclass")
+  {};
+
+  ANamedclass::~ANamedclass() {};
+
+  BNamedclass::BNamedclass() :
+    INamedclass("BNamedclass")
+  {};
+
+  BNamedclass::~BNamedclass() {};
+};
Index: ThirdParty/CodePatterns/src/Patterns/unittests/stubs/CommonNamedStub.hpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/stubs/CommonNamedStub.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/stubs/CommonNamedStub.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,50 @@
+/*
+ * CommonNamedStub.hpp
+ *
+ *  Created on: Jan 16, 2011
+ *      Author: heber
+ */
+
+#ifndef COMMONNAMEDSTUB_HPP_
+#define COMMONNAMEDSTUB_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string>
+
+namespace teststubs {
+  class INamedclass
+  {
+  public:
+    INamedclass(const std::string &_name);
+    virtual ~INamedclass();
+
+    std::string getName() const {
+      return name;
+    }
+
+  private:
+    std::string name;
+  };
+
+  class ANamedclass :
+    public INamedclass
+  {
+  public:
+    ANamedclass();
+    ~ANamedclass();
+  };
+
+  class BNamedclass :
+    public INamedclass
+  {
+  public:
+    BNamedclass();
+    ~BNamedclass();
+  };
+};
+
+#endif /* COMMONNAMEDSTUB_HPP_ */
Index: ThirdParty/CodePatterns/src/Patterns/unittests/stubs/CommonParametersStub.hpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/stubs/CommonParametersStub.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/stubs/CommonParametersStub.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,18 @@
+/*
+ * CommonParametersStub.hpp
+ *
+ *  Created on: Jan 6, 2011
+ *      Author: heber
+ */
+
+#ifndef COMMONPARAMETERSSTUB_HPP_
+#define COMMONPARAMETERSSTUB_HPP_
+
+namespace teststubs {
+  struct classParameters
+  {
+    int counter;
+  };
+}
+
+#endif /* COMMONPARAMETERSSTUB_HPP_ */
Index: ThirdParty/CodePatterns/src/Patterns/unittests/stubs/CommonStub.cpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/stubs/CommonStub.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/stubs/CommonStub.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,61 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * CommonStub.cpp
+ *
+ *  Created on: Jan 4, 2011
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CommonStub.hpp"
+
+namespace teststubs {
+  Iclass::~Iclass() {};
+
+  Aclass::Aclass() :
+    counter(0)
+  {};
+
+  Aclass::~Aclass() {};
+
+  void Aclass::count() {
+    ++counter;
+  }
+
+  int Aclass::getcount() const {
+    return counter;
+  };
+
+  void Aclass::setcount(int const _counter) {
+    counter = _counter;
+  };
+
+
+  Bclass::Bclass() :
+    counter(0.)
+  {};
+
+  Bclass::~Bclass() {};
+
+  void Bclass::count() {
+    counter+=1.;
+  }
+
+  int Bclass::getcount() const {
+    return (int)counter;
+  };
+
+  void Bclass::setcount(int const _counter) {
+    counter = (double)_counter;
+  };
+};
Index: ThirdParty/CodePatterns/src/Patterns/unittests/stubs/CommonStub.hpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/stubs/CommonStub.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/stubs/CommonStub.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,56 @@
+/*
+ * CommonStub.hpp
+ *
+ *  Created on: Jan 4, 2011
+ *      Author: heber
+ */
+
+#ifndef COMMONSTUB_HPP_
+#define COMMONSTUB_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+namespace teststubs {
+  class Iclass
+  {
+  public:
+    virtual ~Iclass();
+
+    virtual void count() = 0;
+    virtual int getcount() const = 0;
+    virtual void setcount(int const _counter) = 0;
+  };
+
+  class Aclass :
+    public Iclass
+  {
+  public:
+    Aclass();
+    ~Aclass();
+
+    void count();
+    int getcount() const;
+    void setcount(int const _counter);
+
+    int counter;
+  };
+
+  class Bclass :
+    public Iclass
+  {
+  public:
+    Bclass();
+    ~Bclass();
+
+    void count();
+    int getcount() const;
+    void setcount(int const _counter);
+
+    double counter;
+  };
+};
+
+#endif /* COMMONSTUB_HPP_ */
Index: ThirdParty/CodePatterns/src/Patterns/unittests/stubs/CreatorStub.hpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/stubs/CreatorStub.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/stubs/CreatorStub.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,50 @@
+/*
+ * CreatorStub.hpp
+ *
+ *  Created on: Jan 4, 2011
+ *      Author: heber
+ */
+
+#ifndef CREATORSTUB_HPP_
+#define CREATORSTUB_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <typeinfo>
+
+#include "CodePatterns/Creator.hpp"
+
+class ICreatorStub {
+public:
+  virtual ~ICreatorStub() {};
+  virtual void count() = 0;
+  virtual int getcount() = 0;
+  virtual std::string name() = 0;
+};
+
+
+template <class T>
+class CreatorStub : public ICreatorStub, public Creator<ICreatorStub, CreatorStub<T> >
+{
+public:
+  CreatorStub() {};
+  virtual ~CreatorStub() {};
+
+  virtual void count() {
+    member.counter++;
+  }
+  virtual int getcount() {
+    return member.counter;
+  }
+  virtual std::string name() {
+    return std::string(typeid(T).name());
+  }
+private:
+  T member;
+};
+
+
+#endif /* CREATORSTUB_HPP_ */
Index: ThirdParty/CodePatterns/src/Patterns/unittests/stubs/FactoryStub.cpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/stubs/FactoryStub.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/stubs/FactoryStub.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,36 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * FactoryStub.cpp
+ *
+ *  Created on: Jan 4, 2011
+   Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/Singleton_impl.hpp"
+
+#include "CommonStub.hpp"
+#include "FactoryStub.hpp"
+
+// has to be included BEFORE Factory_impl.hpp!
+#include "FactoryStub.def"
+#include "CodePatterns/Factory_impl.hpp"
+
+
+FactoryStub::FactoryStub() {}
+FactoryStub::~FactoryStub() {}
+
+CONSTRUCT_SINGLETON(FactoryStub)
+CONSTRUCT_FACTORY(ICreatorStub)
+
+#include "FactoryStub.undef"
Index: ThirdParty/CodePatterns/src/Patterns/unittests/stubs/FactoryStub.def
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/stubs/FactoryStub.def	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/stubs/FactoryStub.def	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,9 @@
+#ifndef FACTORYSTUB_DEF_
+#define FACTORYSTUB_DEF_
+
+#define type_seq (Aclass)(Bclass)
+#define Abstract_Interface_Class ICreatorStub
+#define Abstract_Encapsulation_Class CreatorStub
+#define type_name_space teststubs::
+
+#endif //FACTORYSTUB_DEF_
Index: ThirdParty/CodePatterns/src/Patterns/unittests/stubs/FactoryStub.hpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/stubs/FactoryStub.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/stubs/FactoryStub.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,39 @@
+/*
+ * FactoryStub.hpp
+ *
+ *  Created on: Jan 4, 2011
+   Author: heber
+ */
+
+#ifndef FACTORYSTUB_HPP_
+#define FACTORYSTUB_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CreatorStub.hpp"
+
+// triple has to be appear BEFORE Factory.hpp is included!
+#include "FactoryStub.def"
+#include "CodePatterns/FactoryTypeList.hpp"
+#include "FactoryStub.undef"
+
+#include "CodePatterns/Factory.hpp"
+
+#include "CodePatterns/Singleton.hpp"
+
+class FactoryStub :
+  public Singleton<FactoryStub>,
+  public Factory<ICreatorStub>
+{
+  friend class Singleton<FactoryStub>;
+  friend class FactoryTest;
+
+protected:
+  FactoryStub();
+  virtual ~FactoryStub();
+};
+
+#endif /* FACTORYSTUB_HPP_ */
Index: ThirdParty/CodePatterns/src/Patterns/unittests/stubs/FactoryStub.undef
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/stubs/FactoryStub.undef	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/stubs/FactoryStub.undef	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,10 @@
+#ifdef FACTORYSTUB_DEF_
+
+#undef type_seq
+#undef type_seq_size
+#undef Abstract_Interface_Class
+#undef Abstract_Encapsulation_Class
+#undef type_name_space
+
+#undef FACTORYSTUB_DEF_
+#endif
Index: ThirdParty/CodePatterns/src/Patterns/unittests/stubs/ManipulableCloneStub.cpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/stubs/ManipulableCloneStub.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/stubs/ManipulableCloneStub.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,58 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * ManipulableCloneStub.cpp
+ *
+ *  Created on: Jan 6, 2011
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CommonStub.hpp"
+#include "CommonParametersStub.hpp"
+#include "ManipulableCloneStub.hpp"
+
+/************ Prototype 1 *******************/
+
+template <>
+IManipulablePrototype* ManipulablePrototype<teststubs::Aclass>::clone() const
+{
+  IManipulablePrototype *MyManipulableClone = new ManipulablePrototype<teststubs::Aclass>();
+  MyManipulableClone->setcount(getcount());
+  return MyManipulableClone;
+}
+
+template <>
+ManipulablePrototype<teststubs::Aclass>* ManipulablePrototype<teststubs::Aclass>::manipulatedclone(const teststubs::classParameters &_params) const
+{
+  ManipulablePrototype<teststubs::Aclass> *MyManipulableClone = new ManipulablePrototype<teststubs::Aclass>();
+  MyManipulableClone->setcount(_params.counter);
+  return MyManipulableClone;
+}
+
+/************ Prototype 2 *******************/
+
+template <>
+IManipulablePrototype* ManipulablePrototype<teststubs::Bclass>::clone() const
+{
+  IManipulablePrototype *MyManipulableClone = new ManipulablePrototype<teststubs::Bclass>();
+  MyManipulableClone->setcount(getcount());
+  return MyManipulableClone;
+}
+
+template <>
+ManipulablePrototype<teststubs::Bclass>* ManipulablePrototype<teststubs::Bclass>::manipulatedclone(const teststubs::classParameters &_params) const
+{
+  ManipulablePrototype<teststubs::Bclass> *MyManipulableClone = new ManipulablePrototype<teststubs::Bclass>();
+  MyManipulableClone->setcount(_params.counter);
+  return MyManipulableClone;
+}
Index: ThirdParty/CodePatterns/src/Patterns/unittests/stubs/ManipulableCloneStub.hpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/stubs/ManipulableCloneStub.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/stubs/ManipulableCloneStub.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,74 @@
+/*
+ * ManipulableCloneStub.hpp
+ *
+ *  Created on: Jan 6, 2011
+ *      Author: heber
+ */
+
+#ifndef MANIPULABLECLONESTUB_HPP_
+#define MANIPULABLECLONESTUB_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/ManipulableClone.hpp"
+
+struct IManipulablePrototype
+{
+  virtual ~IManipulablePrototype() {};
+  virtual void count()=0;
+  virtual int getcount() const =0;
+  virtual void setcount(int const _counter)=0;
+};
+
+class ManipulableCloneTest;
+class ManipulablePrototypeFactoryStub;
+namespace teststubs {
+class classParameters;
+}
+
+template <class T>
+class ManipulablePrototype :
+  public IManipulablePrototype,
+  public ManipulableClone<IManipulablePrototype,teststubs::classParameters>
+{
+    /**
+     * Prototype Factory is friend because it needs to access protected cstor
+     * to instantiate prototypes.
+     */
+    friend class ManipulablePrototypeFactoryStub;
+
+    /**
+     * Tests are friend such that it can access protected cstor.
+     */
+    friend class ManipulableCloneTest;
+    friend class ManipulablePrototypeFactoryTest;
+
+protected:
+    ManipulablePrototype() {
+      member.setcount(0);
+    }
+    ~ManipulablePrototype() {};
+
+public:
+    void count() {
+      member.count();
+    }
+    int getcount() const {
+      return member.getcount();
+    }
+    void setcount(int const _counter) {
+      member.setcount(_counter);
+    }
+
+    IManipulablePrototype* clone() const;
+
+    ManipulablePrototype<T> * manipulatedclone(const teststubs::classParameters& _params) const;
+private:
+    T member;
+};
+
+
+#endif /* MANIPULABLECLONESTUB_HPP_ */
Index: ThirdParty/CodePatterns/src/Patterns/unittests/stubs/ManipulablePrototypeFactoryStub.cpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/stubs/ManipulablePrototypeFactoryStub.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/stubs/ManipulablePrototypeFactoryStub.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,42 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * ManipulablePrototypeFactoryStub.cpp
+ *
+ *  Created on: Jan 6, 2011
+   Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/Singleton_impl.hpp"
+
+#include "CommonStub.hpp"
+#include "CommonParametersStub.hpp"
+#include "ManipulablePrototypeFactoryStub.hpp"
+
+// has to be included BEFORE ManipulablePrototypeFactory_impl.hpp!
+#include "ManipulablePrototypeFactoryStub.def"
+#include "CodePatterns/ManipulablePrototypeFactory_impl.hpp"
+
+
+ManipulablePrototypeFactoryStub::ManipulablePrototypeFactoryStub() {
+  FillPrototypeTable();
+}
+
+ManipulablePrototypeFactoryStub::~ManipulablePrototypeFactoryStub() {
+  EmptyPrototypeTable();
+}
+
+CONSTRUCT_SINGLETON(ManipulablePrototypeFactoryStub)
+CONSTRUCT_MANIPULABLEPROTOTYPEFACTORY(IManipulablePrototype, teststubs::classParameters)
+
+#include "ManipulablePrototypeFactoryStub.undef"
Index: ThirdParty/CodePatterns/src/Patterns/unittests/stubs/ManipulablePrototypeFactoryStub.def
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/stubs/ManipulablePrototypeFactoryStub.def	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/stubs/ManipulablePrototypeFactoryStub.def	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,12 @@
+#ifndef MANIPULABLEPROTOTYPEFACTORYSTUB_DEF_
+#define MANIPULABLEPROTOTYPEFACTORYSTUB_DEF_
+
+#define type_seq (Aclass)(Bclass)
+#define FactoryNAME ManipulablePrototypeFactoryStub
+#define Abstract_Interface_Class IManipulablePrototype
+#define Abstract_Parameter_Class teststubs::classParameters
+#define Abstract_Encapsulation_Class ManipulablePrototype
+#define type_name_space teststubs::
+#undef type_suffix
+
+#endif //MANIPULABLEPROTOTYPEFACTORYSTUB_DEF_
Index: ThirdParty/CodePatterns/src/Patterns/unittests/stubs/ManipulablePrototypeFactoryStub.hpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/stubs/ManipulablePrototypeFactoryStub.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/stubs/ManipulablePrototypeFactoryStub.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,44 @@
+/*
+ * ManipulablePrototypeFactoryStub.hpp
+ *
+ *  Created on: Jan 4, 2011
+   Author: heber
+ */
+
+#ifndef MANIPULABLEPROTOTYPEFACTORYSTUB_HPP_
+#define MANIPULABLEPROTOTYPEFACTORYSTUB_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CommonStub.hpp"
+#include "CommonParametersStub.hpp"
+#include "ManipulableCloneStub.hpp"
+
+// triple has to be appear BEFORE ManipulablePrototypeFactory.hpp is included!
+#include "ManipulablePrototypeFactoryStub.def"
+#include "CodePatterns/FactoryTypeList.hpp"
+#include "ManipulablePrototypeFactoryStub.undef"
+
+#include "CodePatterns/ManipulablePrototypeFactory.hpp"
+
+#include "CodePatterns/Singleton.hpp"
+
+class ManipulablePrototypeFactoryStub :
+  public Singleton<ManipulablePrototypeFactoryStub>,
+  public ManipulablePrototypeFactory<IManipulablePrototype, teststubs::classParameters>
+{
+  friend class Singleton<ManipulablePrototypeFactoryStub>;
+  friend class ManipulablePrototypeFactoryTest;
+
+protected:
+  void FillPrototypeTable();
+  void EmptyPrototypeTable();
+
+  ManipulablePrototypeFactoryStub();
+  virtual ~ManipulablePrototypeFactoryStub();
+};
+
+#endif /* MANIPULABLEPROTOTYPEFACTORYSTUB_HPP_ */
Index: ThirdParty/CodePatterns/src/Patterns/unittests/stubs/ManipulablePrototypeFactoryStub.undef
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/stubs/ManipulablePrototypeFactoryStub.undef	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/stubs/ManipulablePrototypeFactoryStub.undef	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,12 @@
+#ifdef MANIPULABLEPROTOTYPEFACTORYSTUB_DEF_
+
+#undef type_seq
+#undef type_seq_size
+#undef FactoryNAME
+#undef Abstract_Interface_Class
+#undef Abstract_Parameter_Class
+#undef Abstract_Encapsulation_Class
+#undef type_name_space
+
+#undef MANIPULABLEPROTOTYPEFACTORYSTUB_DEF_
+#endif
Index: ThirdParty/CodePatterns/src/Patterns/unittests/stubs/ObservedValue_threeNumbers.cpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/stubs/ObservedValue_threeNumbers.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/stubs/ObservedValue_threeNumbers.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,79 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2015 Frederik Heber. 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/>.
+ */
+
+/*
+ * ObservedValue_threeNumbers.cpp
+ *
+ *  Created on: Jun 19, 2015
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "ObservedValue_threeNumbers.hpp"
+
+#include "CodePatterns/Observer/Channels.hpp"
+
+void ObservedValue_threeNumbers::setX(int _x)
+{
+  OBSERVE;
+  NOTIFY(XChanged);
+  x = _x;
+}
+
+void ObservedValue_threeNumbers::setY(int _y)
+{
+  OBSERVE;
+  NOTIFY(YChanged);
+  y = _y;
+}
+
+void ObservedValue_threeNumbers::setZ(int _z)
+{
+  OBSERVE;
+  NOTIFY(ZChanged);
+  z = _z;
+}
+
+int ObservedValue_threeNumbers::calcSum() const
+{
+  hasRecalced = true;
+  return x+y+z;
+}
+
+ObservedValue_threeNumbers::ObservedValue_threeNumbers(
+    int _x,
+    int _y,
+    int _z,
+    Observable::channels_t channels) :
+  Observable(
+      "ObservedValue_threeNumbers",
+      Observable::getChannelList(ObservedValue_threeNumbers::NotificationType_MAX)),
+  x(_x),y(_y),z(_z),
+  sum(this,boost::bind(&ObservedValue_threeNumbers::calcSum,this),"sum", calcSum(), channels),
+  hasRecalced(false)
+{}
Index: ThirdParty/CodePatterns/src/Patterns/unittests/stubs/ObservedValue_threeNumbers.hpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/stubs/ObservedValue_threeNumbers.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/stubs/ObservedValue_threeNumbers.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,48 @@
+/*
+ * ObservedValue_threeNumbers.hpp
+ *
+ *  Created on: Jun 19, 2015
+ *      Author: heber
+ */
+
+#ifndef OBSERVEDVALUETHREENUMBERS_HPP_
+#define OBSERVEDVALUETHREENUMBERS_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/ObservedValue.hpp"
+#include "CodePatterns/Observer/Observable.hpp"
+#include "CodePatterns/Observer/Notification.hpp"
+
+class ObservedValue_threeNumbers : public Observable {
+public:
+  int x;
+  int y;
+  int z;
+  ObservedValue<int> sum;
+  mutable bool hasRecalced;
+
+  enum NotificationType {
+    XChanged,
+    YChanged,
+    ZChanged,
+    NotificationType_MAX
+  };
+
+  void setX(int _x);
+  void setY(int _y);
+  void setZ(int _z);
+
+  int calcSum() const;
+
+  ObservedValue_threeNumbers(
+      int _x,
+      int _y,
+      int _z,
+      Observable::channels_t channels = Observable::channels_t());
+};
+
+#endif /* OBSERVEDVALUETHREENUMBERS_HPP_ */
Index: ThirdParty/CodePatterns/src/Patterns/unittests/stubs/PrototypeFactoryStub.cpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/stubs/PrototypeFactoryStub.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/stubs/PrototypeFactoryStub.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,41 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * PrototypeFactoryStub.cpp
+ *
+ *  Created on: Jan 4, 2011
+   Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/Singleton_impl.hpp"
+
+#include "CommonStub.hpp"
+#include "PrototypeFactoryStub.hpp"
+
+// has to be included BEFORE PrototypeFactory_impl.hpp!
+#include "PrototypeFactoryStub.def"
+#include "CodePatterns/PrototypeFactory_impl.hpp"
+
+
+PrototypeFactoryStub::PrototypeFactoryStub() {
+  FillPrototypeTable();
+}
+
+PrototypeFactoryStub::~PrototypeFactoryStub() {
+  EmptyPrototypeTable();
+}
+
+CONSTRUCT_SINGLETON(PrototypeFactoryStub)
+CONSTRUCT_PROTOTYPEFACTORY(IPrototype)
+
+#include "PrototypeFactoryStub.undef"
Index: ThirdParty/CodePatterns/src/Patterns/unittests/stubs/PrototypeFactoryStub.def
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/stubs/PrototypeFactoryStub.def	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/stubs/PrototypeFactoryStub.def	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,11 @@
+#ifndef PROTOTYPEFACTORYSTUB_DEF_
+#define PROTOTYPEFACTORYSTUB_DEF_
+
+#define type_seq (Aclass)(Bclass)
+#define FactoryNAME PrototypeFactoryStub
+#define Abstract_Interface_Class IPrototype
+#define Abstract_Encapsulation_Class Prototype
+#define type_name_space teststubs::
+#undef type_suffix
+
+#endif //PROTOTYPEFACTORYSTUB_DEF_
Index: ThirdParty/CodePatterns/src/Patterns/unittests/stubs/PrototypeFactoryStub.hpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/stubs/PrototypeFactoryStub.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/stubs/PrototypeFactoryStub.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,42 @@
+/*
+ * PrototypeFactoryStub.hpp
+ *
+ *  Created on: Jan 4, 2011
+   Author: heber
+ */
+
+#ifndef PROTOTYPEFACTORYSTUB_HPP_
+#define PROTOTYPEFACTORYSTUB_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CloneStub.hpp"
+
+// triple has to be appear BEFORE PrototypeFactory.hpp is included!
+#include "PrototypeFactoryStub.def"
+#include "CodePatterns/FactoryTypeList.hpp"
+#include "PrototypeFactoryStub.undef"
+
+#include "CodePatterns/PrototypeFactory.hpp"
+
+#include "CodePatterns/Singleton.hpp"
+
+class PrototypeFactoryStub :
+  public Singleton<PrototypeFactoryStub>,
+  public PrototypeFactory<IPrototype>
+{
+  friend class Singleton<PrototypeFactoryStub>;
+  friend class PrototypeFactoryTest;
+
+protected:
+  void FillPrototypeTable();
+  void EmptyPrototypeTable();
+
+  PrototypeFactoryStub();
+  virtual ~PrototypeFactoryStub();
+};
+
+#endif /* PROTOTYPEFACTORYSTUB_HPP_ */
Index: ThirdParty/CodePatterns/src/Patterns/unittests/stubs/PrototypeFactoryStub.undef
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/stubs/PrototypeFactoryStub.undef	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/stubs/PrototypeFactoryStub.undef	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,11 @@
+#ifdef PROTOTYPEFACTORYSTUB_DEF_
+
+#undef type_seq
+#undef type_seq_size
+#undef FactoryNAME
+#undef Abstract_Interface_Class
+#undef Abstract_Encapsulation_Class
+#undef type_name_space
+
+#undef PROTOTYPEFACTORYSTUB_DEF_
+#endif
Index: ThirdParty/CodePatterns/src/Patterns/unittests/stubs/RegistryStub.cpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/stubs/RegistryStub.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/stubs/RegistryStub.cpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,31 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * RegistryStub.cpp
+ *
+ *  Created on: Jan 16, 2011
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CommonNamedStub.hpp"
+#include "RegistryStub.hpp"
+
+#include "CodePatterns/Registry_impl.hpp"
+
+RegistryStub::RegistryStub()
+{}
+
+RegistryStub::~RegistryStub()
+{}
+
+CONSTRUCT_REGISTRY(teststubs::INamedclass)
Index: ThirdParty/CodePatterns/src/Patterns/unittests/stubs/RegistryStub.hpp
===================================================================
--- ThirdParty/CodePatterns/src/Patterns/unittests/stubs/RegistryStub.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
+++ ThirdParty/CodePatterns/src/Patterns/unittests/stubs/RegistryStub.hpp	(revision 41e8e2a5c8c564e7fcb9688c8fe826715131b8f5)
@@ -0,0 +1,22 @@
+/*
+ * RegistryStub.hpp
+ *
+ *  Created on: Jan 16, 2011
+ *      Author: heber
+ */
+
+#ifndef REGISTRYSTUB_HPP_
+#define REGISTRYSTUB_HPP_
+
+#include "CommonNamedStub.hpp"
+#include "CodePatterns/Registry.hpp"
+
+class RegistryStub : public Registry<teststubs::INamedclass>
+{
+public:
+
+  RegistryStub();
+  ~RegistryStub();
+};
+
+#endif /* REGISTRYSTUB_HPP_ */
