Index: src/Fragmentation/Automation/FragmentQueue.cpp
===================================================================
--- src/Fragmentation/Automation/FragmentQueue.cpp	(revision b5ebb569dab339861535e482277051aeb3f8943a)
+++ src/Fragmentation/Automation/FragmentQueue.cpp	(revision b5ebb569dab339861535e482277051aeb3f8943a)
@@ -0,0 +1,109 @@
+/*
+ * 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.
+ */
+
+/*
+ * FragmentQueue.cpp
+ *
+ *  Created on: Oct 19, 2011
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "FragmentQueue.hpp"
+
+#include "CodePatterns/Assert.hpp"
+
+FragmentResult FragmentQueue::NoResult(-1);
+FragmentResult FragmentQueue::ResultDelivered(-2);
+
+/** Constructor for class FragmentQueue.
+ *
+ */
+FragmentQueue::FragmentQueue()
+{}
+
+/** Destructor for class FragmentQueue.
+ *
+ */
+FragmentQueue::~FragmentQueue()
+{}
+
+/** Pushes a FragmentJob into the internal queue for delivery to server.
+ *
+ * \note we throw assertion when jobid has already been used.
+ *
+ * \param job job to enter into queue
+ */
+void FragmentQueue::pushJob(FragmentJob &job)
+{
+  ASSERT(!results.count(job.getId()),
+      "FragmentQueue::pushJob() - job id "+toString(job.getId())+" has already been used.");
+  jobs.push_back(job);
+  results.insert( std::make_pair(job.getId(), NoResult));
+}
+
+/** Queries whether a job has already been finished and the result is present.
+ *
+ * \param jobid id of job to query
+ * \return true - result is present, false - result is not present
+ */
+bool FragmentQueue::isResultPresent(JobId_t jobid) const
+{
+  ResultMap::const_iterator iter = results.find(jobid);
+  return ((iter != results.end())
+      && (iter->second != NoResult)
+      && (iter->second != ResultDelivered));
+}
+
+/** Delivers result for a finished job.
+ *
+ * \note we throw assertion if not present
+ *
+ * \param jobid id of job
+ * \return result for job of given \a jobid
+ */
+FragmentResult FragmentQueue::getResult(JobId_t jobid)
+{
+  ResultMap::iterator iter = results.find(jobid);
+  ASSERT(iter != results.end(),
+      "FragmentQueue::pushResult() - job "+toString(jobid)+" is not known to us.");
+  ASSERT(iter->second != NoResult,
+      "FragmentQueue::pushResult() - job "+toString(jobid)+"'s result has not arrived yet.");
+  ASSERT(iter->second != ResultDelivered,
+      "FragmentQueue::pushResult() - job "+toString(jobid)+"'s result has already been delivered.");
+  /// store result
+  FragmentResult result = iter->second;
+  /// mark as delivered in map
+  iter->second = ResultDelivered;
+  /// and return result
+  return result;
+}
+
+/** Pushes a result for a finished job.
+ *
+ * \note we throw assertion if job already has result or is not known.
+ *
+ * \param jobid id of job whose result is pushed
+ * \param result result of job to store
+ */
+void FragmentQueue::pushResult(const JobId_t jobid, FragmentResult &result)
+{
+  /// check for presence
+  ResultMap::iterator iter = results.find(jobid);
+  ASSERT(iter != results.end(),
+      "FragmentQueue::pushResult() - job "+toString(jobid)+" is not known to us.");
+  ASSERT(iter->second == NoResult,
+      "FragmentQueue::pushResult() - is not waiting for the result of job "+toString(jobid)+".");
+  /// and overwrite NoResult in found entry
+  iter->second = result;
+}
Index: src/Fragmentation/Automation/FragmentQueue.hpp
===================================================================
--- src/Fragmentation/Automation/FragmentQueue.hpp	(revision b5ebb569dab339861535e482277051aeb3f8943a)
+++ src/Fragmentation/Automation/FragmentQueue.hpp	(revision b5ebb569dab339861535e482277051aeb3f8943a)
@@ -0,0 +1,59 @@
+/*
+ * FragmentQueue.hpp
+ *
+ *  Created on: Oct 19, 2011
+ *      Author: heber
+ */
+
+#ifndef FRAGMENTQUEUE_HPP_
+#define FRAGMENTQUEUE_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <deque>
+#include <map>
+
+#include "types.hpp"
+#include "FragmentJob.hpp"
+#include "FragmentResult.hpp"
+
+
+/** This class contains a deque for temporarily storing the FragmentJob
+ * instances until they are receive by the server. Also all results are
+ * contained herein.
+ */
+class FragmentQueue
+{
+public:
+  FragmentQueue();
+  ~FragmentQueue();
+
+  // entering jobs into queue
+  void pushJob(FragmentJob &job);
+
+  // querying for results
+  bool isResultPresent(JobId_t jobid) const;
+  FragmentResult getResult(JobId_t jobid);
+  void pushResult(const JobId_t jobid, FragmentResult &result);
+
+
+private:
+  //!> result that takes place in ResultQueue until real result has arrived.
+  static FragmentResult NoResult;
+  //!> result that takes place in ResultQueue after real result has been delivered.
+  static FragmentResult ResultDelivered;
+
+  typedef std::deque<FragmentJob> JobQueue;
+  typedef std::map<JobId_t, FragmentResult> ResultMap;
+
+  //!> queue for all jobs
+  JobQueue jobs;
+  //!> map for all results that have been polled by the server
+  ResultMap results;
+};
+
+
+#endif /* FRAGMENTQUEUE_HPP_ */
Index: src/Fragmentation/Automation/FragmentResult.cpp
===================================================================
--- src/Fragmentation/Automation/FragmentResult.cpp	(revision b5ebb569dab339861535e482277051aeb3f8943a)
+++ src/Fragmentation/Automation/FragmentResult.cpp	(revision b5ebb569dab339861535e482277051aeb3f8943a)
@@ -0,0 +1,72 @@
+/*
+ * 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.
+ */
+
+/*
+ * FragmentResult.cpp
+ *
+ *  Created on: Oct 19, 2011
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "FragmentResult.hpp"
+
+
+/** Constructor of class FragmentResult.
+ *
+ * \param id id of FragmntJob associated to this FragmentResult.
+ */
+FragmentResult::FragmentResult(const JobId_t _id) :
+  id(_id),
+  result(std::string("Nothing"))
+{}
+
+/** Copy constructor of class FragmentResult.
+ *
+ */
+FragmentResult::FragmentResult(const FragmentResult &other) :
+  id(other.id),
+  result(other.result)
+{}
+
+/** Destructor of class FragmentResult.
+ *
+ */
+FragmentResult::~FragmentResult()
+{}
+
+/** Equality operator: Equal if both ids are the same
+ *
+ * \param other instance to check against
+ * \return true - both ids are the same, false - ids are not the same.
+ */
+bool FragmentResult::operator==(const FragmentResult &other) const
+{
+  return id == other.id;
+}
+
+/** Assigment operator.
+ *
+ * \note We can't use default assigment because of const member FragmentResult::id.
+ *
+ * \param other instance to make equal to
+ */
+FragmentResult& FragmentResult::operator=(const FragmentResult &other)
+{
+  /// check self-assignment
+  if (this != &other) {
+    const_cast<JobId_t &>(id) = other.id;
+    result = other.result;
+  }
+  return *this;
+}
Index: src/Fragmentation/Automation/FragmentResult.hpp
===================================================================
--- src/Fragmentation/Automation/FragmentResult.hpp	(revision b5ebb569dab339861535e482277051aeb3f8943a)
+++ src/Fragmentation/Automation/FragmentResult.hpp	(revision b5ebb569dab339861535e482277051aeb3f8943a)
@@ -0,0 +1,43 @@
+/*
+ * FragmentResult.hpp
+ *
+ *  Created on: Oct 19, 2011
+ *      Author: heber
+ */
+
+#ifndef FRAGMENTRESULT_HPP_
+#define FRAGMENTRESULT_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include <string>
+#include "types.hpp"
+
+/** This class contains the result to a specific FragmentJob.
+ *
+ */
+class FragmentResult
+{
+public:
+  FragmentResult(const JobId_t id);
+  FragmentResult(const FragmentResult &other);
+  ~FragmentResult();
+
+  FragmentResult& operator=(const FragmentResult &other);
+  bool operator==(const FragmentResult &other) const;
+  bool operator!=(const FragmentResult &other) const
+    { return !(*this == other); }
+
+
+  //!> this job's unique id
+  const JobId_t id;
+  //!> result
+  std::string result;
+};
+
+
+#endif /* FRAGMENTRESULT_HPP_ */
Index: src/Fragmentation/Automation/Makefile.am
===================================================================
--- src/Fragmentation/Automation/Makefile.am	(revision 4b58cccfcae20f61dca5d2d18f77c1db61bb9a98)
+++ src/Fragmentation/Automation/Makefile.am	(revision b5ebb569dab339861535e482277051aeb3f8943a)
@@ -4,4 +4,9 @@
 MOSTLYCLEANFILES =
 bin_PROGRAMS =
+TESTS =
+check_PROGRAMS =
+noinst_PROGRAMS =
+
+include unittests/Makefile.am
 
 AM_LDFLAGS = -ldl ${BOOST_LDFLAGS}
Index: src/Fragmentation/Automation/unittests/FragmentQueueUnitTest.cpp
===================================================================
--- src/Fragmentation/Automation/unittests/FragmentQueueUnitTest.cpp	(revision b5ebb569dab339861535e482277051aeb3f8943a)
+++ src/Fragmentation/Automation/unittests/FragmentQueueUnitTest.cpp	(revision b5ebb569dab339861535e482277051aeb3f8943a)
@@ -0,0 +1,59 @@
+/*
+ * 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.
+ */
+
+/*
+ * FragmentQueueUnitTest.cpp
+ *
+ *  Created on: Oct 23, 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 "FragmentQueue.hpp"
+
+#include "FragmentQueueUnitTest.hpp"
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( FragmentQueueTest );
+
+
+void FragmentQueueTest::setUp()
+{
+  queue = new FragmentQueue();
+}
+
+
+void FragmentQueueTest::tearDown()
+{
+  delete queue;
+}
+
+/** UnitTest for working JobQueue
+ */
+void FragmentQueueTest::JobsTest()
+{
+}
+
+/** UnitTest for working ResultMap
+ */
+void FragmentQueueTest::ResultsTest()
+{
+}
Index: src/Fragmentation/Automation/unittests/FragmentQueueUnitTest.hpp
===================================================================
--- src/Fragmentation/Automation/unittests/FragmentQueueUnitTest.hpp	(revision b5ebb569dab339861535e482277051aeb3f8943a)
+++ src/Fragmentation/Automation/unittests/FragmentQueueUnitTest.hpp	(revision b5ebb569dab339861535e482277051aeb3f8943a)
@@ -0,0 +1,41 @@
+/*
+ * FragmentQueueUnitTest.hpp
+ *
+ *  Created on: Oct 23, 2011
+ *      Author: heber
+ */
+
+#ifndef FRAGMENTQUEUEUNITTEST_HPP_
+#define FRAGMENTQUEUEUNITTEST_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class FragmentQueue;
+
+/********************************************** Test classes **************************************/
+
+class FragmentQueueTest : public CppUnit::TestFixture
+{
+    CPPUNIT_TEST_SUITE( FragmentQueueTest) ;
+    CPPUNIT_TEST ( JobsTest );
+    CPPUNIT_TEST ( ResultsTest );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+      void setUp();
+      void tearDown();
+      void JobsTest();
+      void ResultsTest();
+
+private:
+      FragmentQueue *queue;
+
+};
+
+#endif /* FRAGMENTQUEUEUNITTEST_HPP_ */
Index: src/Fragmentation/Automation/unittests/Makefile.am
===================================================================
--- src/Fragmentation/Automation/unittests/Makefile.am	(revision b5ebb569dab339861535e482277051aeb3f8943a)
+++ src/Fragmentation/Automation/unittests/Makefile.am	(revision b5ebb569dab339861535e482277051aeb3f8943a)
@@ -0,0 +1,36 @@
+# PLEASE adhere to the alphabetical ordering in this Makefile!
+# Also indentation by a single tab
+
+FRAGMENTATIONAUTOMATIONTESTSSOURCES = \
+  unittests/FragmentQueueUnitTest.cpp
+
+FRAGMENTATIONAUTOMATIONTESTSHEADERS = \
+  unittests/FragmentQueueUnitTest.hpp
+
+FRAGMENTATIONAUTOMATIONTESTS = \
+  FragmentQueueUnitTest
+
+
+TESTS += $(FRAGMENTATIONAUTOMATIONTESTS)
+check_PROGRAMS += $(FRAGMENTATIONAUTOMATIONTESTS) 
+noinst_PROGRAMS += $(FRAGMENTATIONAUTOMATIONTESTS)
+
+FRAGMENTATIONAUTOMATIONLIBS = \
+  $(BOOST_THREAD_LDFLAGS) $(BOOST_THREAD_LIBS) \
+  ${CodePatterns_LIBS}
+
+FragmentQueueUnitTest_LDFLAGS = ${CodePatterns_LIBS} $(CPPUNIT_LIBS) -ldl
+FragmentQueueUnitTest_CPPFLAGS = ${BOOST_CPPFLAGS} $(CPPUNIT_CFLAGS) ${CodePatterns_CFLAGS}
+FragmentQueueUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
+  unittests/FragmentQueueUnitTest.cpp \
+  unittests/FragmentQueueUnitTest.hpp \
+  FragmentJob.cpp \
+  FragmentJob.hpp \
+  FragmentQueue.cpp \
+  FragmentQueue.hpp \
+  FragmentResult.cpp \
+  FragmentResult.hpp
+FragmentQueueUnitTest_LDADD = $(FRAGMENTATIONAUTOMATIONLIBS)
+
+
+#AUTOMAKE_OPTIONS = parallel-tests
