Index: src/LinkedCell/LinkedCell_Controller.cpp
===================================================================
--- src/LinkedCell/LinkedCell_Controller.cpp	(revision fea945d620239c90af4f79b6ad78cde77e453de4)
+++ src/LinkedCell/LinkedCell_Controller.cpp	(revision fea945d620239c90af4f79b6ad78cde77e453de4)
@@ -0,0 +1,104 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2011 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * LinkedCell_Controller.cpp
+ *
+ *  Created on: Nov 15, 2011
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "Box.hpp"
+#include "LinkedCell_Controller.hpp"
+#include "LinkedCell_Model.hpp"
+#include "LinkedCell_View.hpp"
+
+#include "CodePatterns/Assert.hpp"
+
+using namespace LinkedCell;
+
+/** Constructor of class LinkedCell_Controller.
+ *
+ */
+LinkedCell_Controller::LinkedCell_Controller(const Box &_domain) :
+    domain(_domain)
+{}
+
+/** Destructor of class LinkedCell_Controller.
+ *
+ * Here, we free all LinkedCell_Model instances again.
+ *
+ */
+LinkedCell_Controller::~LinkedCell_Controller()
+{
+  // remove all linked cell models
+  for(MapEdgelengthModel::iterator iter = ModelsMap.begin();
+      !ModelsMap.empty(); iter = ModelsMap.begin()) {
+    delete iter->second;
+    ModelsMap.erase(iter);
+  }
+}
+
+/** Internal function to decide whether a suitable model is present or not.
+ *
+ * Here, the heuristic for deciding whether a new linked cell structure has to
+ * be constructed or not is implemented.
+ *
+ * \note Dealing out a pointer is here (hopefully) safe because the function is
+ * internal and we - inside this class - know what we are doing.
+ *
+ * @param distance edge length of the requested linked cell structure
+ * @return NULL - there is no fitting LinkedCell_Model, else - pointer to instance
+ */
+const LinkedCell_Model *LinkedCell_Controller::getBestModel(const double distance) const
+{
+  for(MapEdgelengthModel::const_iterator iter = ModelsMap.begin();
+      iter != ModelsMap.end(); ++iter) {
+    // here, we use the heuristic
+    if (true) {
+      return iter->second;
+    }
+  }
+  return NULL;
+}
+
+/** Returns the a suitable LinkedCell_Model contained in a LinkedCell_View
+ *  for the requested \a distance.
+ *
+ * \sa getBestModel()
+ *
+ * @param distance edge length of the requested linked cell structure
+ * @return LinkedCell_View wrapping the best LinkedCell_Model
+ */
+LinkedCell_View LinkedCell_Controller::getView(const double distance)
+{
+  // look for best instance
+  const LinkedCell_Model *LCModel_best = getBestModel(distance);
+
+  // construct new instance if none found
+  if (LCModel_best == NULL) {
+    LinkedCell_Model *LCModel_new = new LinkedCell_Model(distance, domain);
+    std::pair< MapEdgelengthModel::iterator, bool> inserter =
+        ModelsMap.insert( std::make_pair(distance, LCModel_new) );
+    ASSERT(inserter.second,
+        "LinkedCell_Controller::getView() - LinkedCell_Model instance with distance "
+        +toString(distance)+" already present.");
+    LinkedCell_View interface(const_cast<const LinkedCell_Model &>(*LCModel_new));
+    return interface;
+  } else {
+    // construct interface and return
+    LinkedCell_View interface(*LCModel_best);
+    return interface;
+  }
+}
Index: src/LinkedCell/LinkedCell_Controller.hpp
===================================================================
--- src/LinkedCell/LinkedCell_Controller.hpp	(revision fea945d620239c90af4f79b6ad78cde77e453de4)
+++ src/LinkedCell/LinkedCell_Controller.hpp	(revision fea945d620239c90af4f79b6ad78cde77e453de4)
@@ -0,0 +1,62 @@
+/*
+ * LinkedCell_Controller.hpp
+ *
+ *  Created on: Nov 15, 2011
+ *      Author: heber
+ */
+
+#ifndef LINKEDCELL_CONTROLLER_HPP_
+#define LINKEDCELL_CONTROLLER_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <map>
+
+#include "LinkedCell/LinkedCell_View.hpp"
+
+namespace LinkedCell {
+
+  class LinkedCell_Model;
+
+  /** This is the controller in the MVC ansatz for the LinkedCell structure.
+   *
+   * \sa linkedcell
+   *
+   * The Controller contains multiple models (i.e. LinkedCell instances) and he
+   * takes care that the view (the interface) can give its functionality with
+   * low computational complexity.
+   *
+   * Here, it contains multiple LinkedCell_Model instances, each with different
+   * edge lengths of the inherent mesh. You request a LinkedCell instance from
+   * the controller, but you basically just receive a const interface reference
+   * to a present LinkedCell instance.
+   *
+   */
+  class LinkedCell_Controller
+  {
+  public:
+    LinkedCell_Controller(const Box &_domain);
+    ~LinkedCell_Controller();
+
+    LinkedCell_View getView(const double distance);
+
+  private:
+    const LinkedCell_Model * getBestModel(const double distance) const;
+
+  private:
+    //!> typedef for the (edge length, model) map
+    typedef std::map<double, LinkedCell_Model* > MapEdgelengthModel;
+
+    //!> internal map of present LinkedCell_Model instances by their egde length
+    MapEdgelengthModel ModelsMap;
+
+    //!> internal reference to domain required for constructing LinkedCell_Model instances.
+    const Box &domain;
+  };
+
+}
+
+#endif /* LINKEDCELL_CONTROLLER_HPP_ */
Index: src/LinkedCell/Makefile.am
===================================================================
--- src/LinkedCell/Makefile.am	(revision 6b91e6417f39a42bdd14fb1186aea6a23e51aa9a)
+++ src/LinkedCell/Makefile.am	(revision fea945d620239c90af4f79b6ad78cde77e453de4)
@@ -54,4 +54,5 @@
 LINKEDCELL_REFACTOREDSOURCE = \
   LinkedCell/LinkedCell.cpp \
+  LinkedCell/LinkedCell_Controller.cpp \
   LinkedCell/LinkedCell_Model.cpp \
   LinkedCell/LinkedCell_View.cpp
@@ -59,4 +60,5 @@
 LINKEDCELL_REFACTOREDHEADER = \
   LinkedCell/LinkedCell.hpp \
+  LinkedCell/LinkedCell_Controller.hpp \
   LinkedCell/LinkedCell_Model.hpp \
   LinkedCell/LinkedCell_View.hpp
Index: src/LinkedCell/unittests/LinkedCell_ControllerUnitTest.cpp
===================================================================
--- src/LinkedCell/unittests/LinkedCell_ControllerUnitTest.cpp	(revision fea945d620239c90af4f79b6ad78cde77e453de4)
+++ src/LinkedCell/unittests/LinkedCell_ControllerUnitTest.cpp	(revision fea945d620239c90af4f79b6ad78cde77e453de4)
@@ -0,0 +1,74 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2011 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * LinkedCell_ControllerUnitTest.cpp
+ *
+ *  Created on: Nov 29, 2011
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+using namespace std;
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "Box.hpp"
+#include "CodePatterns/Assert.hpp"
+#include "LinearAlgebra/RealSpaceMatrix.hpp"
+#include "LinkedCell/LinkedCell_Controller.hpp"
+#include "LinkedCell/unittests/defs.hpp"
+
+#include "LinkedCell_ControllerUnitTest.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( LinkedCell_ControllerTest );
+
+
+void LinkedCell_ControllerTest::setUp()
+{
+  // failing asserts should be thrown
+  ASSERT_DO(Assert::Throw);
+
+  // create diag(20.) matrix
+  BoxM = new RealSpaceMatrix;
+  BoxM->setIdentity();
+  (*BoxM) *= DOMAINLENGTH;
+
+  // create Box with this matrix
+  domain = new Box(*BoxM);
+
+  controller = new LinkedCell::LinkedCell_Controller(*domain);
+}
+
+
+void LinkedCell_ControllerTest::tearDown()
+{
+  delete controller;
+  delete domain;
+}
+
+
+/** UnitTest for LinkedCell_Controller::getViewTest().
+ */
+void LinkedCell_ControllerTest::getViewTest()
+{
+  CPPUNIT_ASSERT_EQUAL(true, true);
+
+}
Index: src/LinkedCell/unittests/LinkedCell_ControllerUnitTest.hpp
===================================================================
--- src/LinkedCell/unittests/LinkedCell_ControllerUnitTest.hpp	(revision fea945d620239c90af4f79b6ad78cde77e453de4)
+++ src/LinkedCell/unittests/LinkedCell_ControllerUnitTest.hpp	(revision fea945d620239c90af4f79b6ad78cde77e453de4)
@@ -0,0 +1,46 @@
+/*
+ * LinkedCell_ControllerUnitTest.hpp
+ *
+ *  Created on: Nov 29, 2011
+ *      Author: heber
+ */
+
+#ifndef LINKEDCELL_CONTROLLERUNITTEST_HPP_
+#define LINKEDCELL_CONTROLLERUNITTEST_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class Box;
+class RealSpaceMatrix;
+namespace LinkedCell {
+  class LinkedCellController;
+}
+
+/********************************************** Test classes **************************************/
+
+class LinkedCell_ControllerTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( LinkedCell_ControllerTest) ;
+    CPPUNIT_TEST ( getViewTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+
+      void getViewTest();
+
+private:
+      Box *domain;
+      RealSpaceMatrix *BoxM;
+      LinkedCell::LinkedCell_Controller *controller;
+};
+
+
+#endif /* LINKEDCELL_CONTROLLERUNITTEST_HPP_ */
Index: src/LinkedCell/unittests/Makefile.am
===================================================================
--- src/LinkedCell/unittests/Makefile.am	(revision 6b91e6417f39a42bdd14fb1186aea6a23e51aa9a)
+++ src/LinkedCell/unittests/Makefile.am	(revision fea945d620239c90af4f79b6ad78cde77e453de4)
@@ -4,4 +4,5 @@
 LINKEDCELLTESTSSOURCES = \
 	../LinkedCell/unittests/LinkedCellUnitTest.cpp \
+	../LinkedCell/unittests/LinkedCell_ControllerUnitTest.cpp \
 	../LinkedCell/unittests/LinkedCell_ModelUnitTest.cpp \
 	../LinkedCell/unittests/LinkedCell_ViewUnitTest.cpp \
@@ -11,4 +12,5 @@
 	../LinkedCell/PointCloudAdaptor.hpp \
 	../LinkedCell/unittests/LinkedCellUnitTest.hpp \
+	../LinkedCell/unittests/LinkedCell_ControllerUnitTest.hpp \
 	../LinkedCell/unittests/LinkedCell_ModelUnitTest.hpp \
 	../LinkedCell/unittests/LinkedCell_ViewUnitTest.hpp \
@@ -17,8 +19,8 @@
 LINKEDCELLTESTS = \
   LinkedCellUnitTest \
+  LinkedCell_ControllerUnitTest \
   LinkedCell_ModelUnitTest \
   LinkedCell_ViewUnitTest \
   linkedcellUnitTest
-
 
 TESTS += $(LINKEDCELLTESTS)
@@ -45,8 +47,14 @@
 	$(LINKEDCELLLIBS)
 
+LinkedCell_ControllerUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
+	../LinkedCell/unittests/LinkedCell_ControllerUnitTest.cpp \
+	../LinkedCell/unittests/LinkedCell_ControllerUnitTest.hpp
+LinkedCell_ControllerUnitTest_LDADD = \
+	../libMolecuilderLinkedCell_refactored.la \
+	$(LINKEDCELLLIBS)
+
 LinkedCell_ModelUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
 	../LinkedCell/unittests/LinkedCell_ModelUnitTest.cpp \
-	../LinkedCell/unittests/LinkedCell_ModelUnitTest.hpp \
-	../LinkedCell/PointCloudAdaptor.hpp
+	../LinkedCell/unittests/LinkedCell_ModelUnitTest.hpp
 LinkedCell_ModelUnitTest_LDADD = \
 	../libMolecuilderLinkedCell_refactored.la \
@@ -61,3 +69,4 @@
 	$(LINKEDCELLLIBS)
 
+
 #AUTOMAKE_OPTIONS = parallel-tests
