Index: src/Fragmentation/Automation/Controller/CommandRegistry.hpp
===================================================================
--- src/Fragmentation/Automation/Controller/CommandRegistry.hpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ src/Fragmentation/Automation/Controller/CommandRegistry.hpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -14,6 +14,7 @@
 #endif
 
-#include "Controller/Commands/Operation.hpp"
 #include "CodePatterns/Registry.hpp"
+
+#include "Operations/Operation.hpp"
 
 class CommandRegistry : public Registry<Operation>
Index: src/Fragmentation/Automation/Controller/Commands/AsyncOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/AsyncOperation.cpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ 	(revision )
@@ -1,81 +1,0 @@
-/*
- * 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.
- */
-
-/*
- * AsyncOperation.cpp
- *
- *  Created on: Nov 11, 2011
- *      Author: heber
- */
-
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-// boost asio needs specific operator new
-#include <boost/asio.hpp>
-
-#include "CodePatterns/MemDebug.hpp"
-
-#include <boost/bind.hpp>
-#include <vector>
-#include "Connection.hpp" // Must come before boost/serialization headers.
-#include "CodePatterns/Info.hpp"
-#include "CodePatterns/Log.hpp"
-
-#include "Controller/Commands/AsyncOperation.hpp"
-
-/** Callback function when an operation has been completed.
- *
- * \param e error code if something went wrong
- */
-void AsyncOperation::handle_FinishOperation(const boost::system::error_code& e)
-{
-  Info info(__FUNCTION__);
-  if (!e)
-  {
-    LOG(1, "INFO: AsyncOperation completed.");
-  }
-  else
-  {
-    // An error occurred.
-    Exitflag = ErrorFlag;
-    ELOG(1, e.message());
-  }
-
-  // Since we are not starting a new operation the io_service will run out of
-  // work to do and the client will exit.
-  disconnect();
-}
-
-/** Internal function to disconnect connection_ correctly.
- *
- */
-void AsyncOperation::disconnect()
-{
-  connection_.socket().close();
-}
-
-void AsyncOperation::operator()(const std::string& _host, const std::string& _service)
-{
-  Info info(__FUNCTION__);
-  // Resolve the host name into an IP address.
-  boost::asio::ip::tcp::resolver resolver(connection_.socket().get_io_service());
-  boost::asio::ip::tcp::resolver::query query(_host, _service);
-  boost::asio::ip::tcp::resolver::iterator endpoint_iterator =
-    resolver.resolve(query);
-  boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
-
-  // Start an asynchronous connect operation.
-  std::cout << "Connecting to endpoint " << endpoint << " ..." << std::endl;
-  connection_.socket().async_connect(endpoint,
-    boost::bind(&AsyncOperation::handle_connect, this,
-      boost::asio::placeholders::error, ++endpoint_iterator));
-}
-
Index: src/Fragmentation/Automation/Controller/Commands/AsyncOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/AsyncOperation.hpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ 	(revision )
@@ -1,56 +1,0 @@
-/*
- * AsyncOperation.hpp
- *
- *  Created on: Nov 11, 2011
- *      Author: heber
- */
-
-#ifndef FRAGMENTCONTROLLER_ASYNCOPERATION_HPP_
-#define FRAGMENTCONTROLLER_ASYNCOPERATION_HPP_
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <boost/asio.hpp>
-#include <string>
-#include <vector>
-
-#include "Operation.hpp"
-
-class AsyncOperation : public Operation {
-public:
-  /** Constructor for class AsyncOperation.
-   *
-   * \param _name name for this AsyncOperation for retrieval from a registry
-   * \param _connection connection to operate on
-   */
-  AsyncOperation(const std::string &_name, Connection &_connection) :
-    Operation(_name, _connection)
-  {}
-
-  /** Destructor for class AsyncOperation.
-   *
-   */
-  virtual ~AsyncOperation()
-  {}
-
-public:
-  // virtual function pointer to the operation to do
-  void operator()(const std::string& _host, const std::string& _service);
-
-protected:
-  // virtual function pointer to the connection handler
-  virtual void handle_connect(const boost::system::error_code& e,
-      boost::asio::ip::tcp::resolver::iterator endpoint_iterator) = 0;
-
-  /// Handle completion of an operation.
-  void handle_FinishOperation(const boost::system::error_code& e);
-
-protected:
-  /// internal function to disconnect from server
-  void disconnect();
-};
-
-#endif /* FRAGMENTCONTROLLER_ASYNCOPERATION_HPP_ */
Index: src/Fragmentation/Automation/Controller/Commands/CheckResultsOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/CheckResultsOperation.cpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ 	(revision )
@@ -1,114 +1,0 @@
-/*
- * Project: MoleCuilder
- * Description: creates and alters molecular systems
- * Copyright (C)  2011-2012 University of Bonn. All rights reserved.
- * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
- */
-
-/*
- * CheckResultsOperation.cpp
- *
- *  Created on: Dec 11, 2011
- *      Author: heber
- */
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-// boost asio needs specific operator new
-#include <boost/asio.hpp>
-
-#include "CodePatterns/MemDebug.hpp"
-
-#include <boost/bind.hpp>
-#include <iostream>
-#include "Connection.hpp" // Must come before boost/serialization headers.
-#include <boost/serialization/vector.hpp>
-#include "CodePatterns/Info.hpp"
-#include "CodePatterns/Log.hpp"
-#include "ControllerChoices.hpp"
-
-#include "Controller/Commands/CheckResultsOperation.hpp"
-
-/** Handle connect operation to send number of done jobs.
- *
- * \param e error code if something went wrong
- * \param endpoint_iterator endpoint of the connection
- */
-void CheckResultsOperation::handle_connect(const boost::system::error_code& e,
-    boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
-{
-  Info info(__FUNCTION__);
-  if (!e)
-  {
-    // Successfully established connection. Give choice.
-    enum ControllerChoices choice = CheckState;
-    connection_.async_write(choice,
-      boost::bind(&CheckResultsOperation::handle_ReceiveJobInfo, this,
-      boost::asio::placeholders::error));
-  } else if (endpoint_iterator != boost::asio::ip::tcp::resolver::iterator()) {
-    // Try the next endpoint.
-    connection_.socket().close();
-    boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
-    connection_.socket().async_connect(endpoint,
-      boost::bind(&CheckResultsOperation::handle_connect, this,
-      boost::asio::placeholders::error, ++endpoint_iterator));
-  } else {
-    // An error occurred. Log it and return. Since we are not starting a new
-    // operation the io_service will run out of work to do and the client will
-    // exit.
-    Exitflag = ErrorFlag;
-    ELOG(1, e.message());
-  }
-}
-
-/** Callback function when doneJobs have been received.
- *
- * \param e error code if something went wrong
- */
-void CheckResultsOperation::handle_ReceiveJobInfo(const boost::system::error_code& e)
-{
-  Info info(__FUNCTION__);
-  if (!e)
-  {
-    // The connection::async_read() function will automatically
-    // decode the data that is written to the underlying socket.
-    LOG(1, "INFO: Obtaining number of present and done jobs ...");
-    connection_.async_read(jobInfo,
-      boost::bind(&CheckResultsOperation::handle_FinishOperation, this,
-      boost::asio::placeholders::error));
-  }
-  else
-  {
-    // An error occurred.
-    Exitflag = ErrorFlag;
-    ELOG(1, e.message());
-  }
-}
-
-/** Getter for jobInfo.
- *
- * \sa checkResults()
- * \param number of present jobs
- */
-size_t CheckResultsOperation::getPresentJobs() const
-{
-  ASSERT( jobInfo.size() == (size_t)2,
-      "CheckResultsOperation::getPresentJobs() - jobInfo does not contain present and done jobs.");
-  return jobInfo[0];
-}
-
-/** Getter for jobInfo.
- *
- * \sa checkResults()
- * \param number of done jobs
- */
-size_t CheckResultsOperation::getDoneJobs() const
-{
-  ASSERT( jobInfo.size() == (size_t)2,
-      "CheckResultsOperation::getPresentJobs() - jobInfo does not contain present and done jobs.");
-  return jobInfo[1];
-}
-
Index: src/Fragmentation/Automation/Controller/Commands/CheckResultsOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/CheckResultsOperation.hpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ 	(revision )
@@ -1,56 +1,0 @@
-/*
- * CheckResultsOperation.hpp
- *
- *  Created on: Dec 11, 2011
- *      Author: heber
- */
-
-#ifndef FRAGMENTCONTROLLER_CHECKRESULTSOPERATION_HPP_
-#define FRAGMENTCONTROLLER_CHECKRESULTSOPERATION_HPP_
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <boost/asio.hpp>
-#include <string>
-
-#include "Connection.hpp"
-
-#include "Controller/Commands/AsyncOperation.hpp"
-
-/** This Operations requests number of present jobs and present results (done
- * jobs) from the server.
- *
- */
-class CheckResultsOperation : public AsyncOperation  {
-public:
-  /// Constructor for class CheckResultsOperation.
-  CheckResultsOperation(Connection &_connection) :
-    AsyncOperation(std::string("checkresults"), _connection),
-    jobInfo((size_t)2, 0)
-        {}
-  /// Destructor for class CheckResultsOperation
-  ~CheckResultsOperation() {}
-
-public:
-  // virtual function pointer to the connection handler
-  virtual void handle_connect(const boost::system::error_code& e,
-      boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
-
-  /// Callback function when doneJobs have been received.
-  void handle_ReceiveJobInfo(const boost::system::error_code& e);
-
-  /// Getter for presentJobs
-  size_t getPresentJobs() const;
-
-  /// Getter for doneJobs
-  size_t getDoneJobs() const;
-
-protected:
-  /// current jobs left to calculate and currently calculated results
-  std::vector<size_t> jobInfo;
-};
-
-#endif /* FRAGMENTCONTROLLER_CHECKRESULTSOPERATION_HPP_ */
Index: src/Fragmentation/Automation/Controller/Commands/EnrollInPoolOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/EnrollInPoolOperation.cpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ 	(revision )
@@ -1,117 +1,0 @@
-/*
- * Project: MoleCuilder
- * Description: creates and alters molecular systems
- * Copyright (C)  2012 University of Bonn. All rights reserved.
- * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
- */
-
-/*
- * EnrollInPoolOperation.cpp
- *
- *  Created on: Feb 26, 2012
- *      Author: heber
- */
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-// boost asio needs specific operator new
-#include <boost/asio.hpp>
-
-#include "CodePatterns/MemDebug.hpp"
-
-#include "EnrollInPoolOperation.hpp"
-
-#include <boost/bind.hpp>
-#include "CodePatterns/Info.hpp"
-#include "CodePatterns/Log.hpp"
-#include "Jobs/FragmentJob.hpp"
-#include "WorkerAddress.hpp"
-#include "WorkerChoices.hpp"
-
-/// Handle completion of a connect operation.
-void EnrollInPoolOperation::handle_connect(const boost::system::error_code& e,
-    boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
-{
-  Info info(__FUNCTION__);
-  if (!e)
-  {
-    // Successfully established connection. Start operation to read the list
-    // of jobs. The connection::async_read() function will automatically
-    // decode the data that is read from the underlying socket.
-    connection_.async_write(address,
-      boost::bind(&EnrollInPoolOperation::handle_SendChoice, this,
-      boost::asio::placeholders::error));
-  } else if (endpoint_iterator != boost::asio::ip::tcp::resolver::iterator()) {
-    // Try the next endpoint.
-    connection_.socket().close();
-    boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
-    connection_.socket().async_connect(endpoint,
-      boost::bind(&EnrollInPoolOperation::handle_connect, this,
-      boost::asio::placeholders::error, ++endpoint_iterator));
-  } else {
-    // An error occurred. Log it and return. Since we are not starting a new
-    // operation the io_service will run out of work to do and the client will
-    // exit.
-    ELOG(1, e.message());
-  }
-}
-
-
-/// Handle sending choice
-void EnrollInPoolOperation::handle_SendChoice(const boost::system::error_code& e)
-{
-  Info info(__FUNCTION__);
-  if (!e)
-  {
-    // Successfully established connection. Start operation to read the list
-    // of jobs. The connection::async_read() function will automatically
-    // decode the data that is read from the underlying socket.
-    LOG(1, "INFO: Enrolling in pool with " << address << " ...");
-    enum WorkerChoices choice = EnrollInPool;
-    connection_.async_write(choice,
-      boost::bind(&EnrollInPoolOperation::handle_ReceiveFlag, this,
-      boost::asio::placeholders::error));
-  } else {
-    // An error occurred. Log it and return. Since we are not starting a new
-    // operation the io_service will run out of work to do and the client will
-    // exit.
-    ELOG(1, e.message());
-  }
-}
-
-
-/// Handle receiving flag
-void EnrollInPoolOperation::handle_ReceiveFlag(const boost::system::error_code& e)
-{
-  Info info(__FUNCTION__);
-  if (!e)
-  {
-    // Successfully established connection. Start operation to read the list
-    // of jobs. The connection::async_read() function will automatically
-    // decode the data that is read from the underlying socket.
-    connection_.async_read(flag,
-      boost::bind(&EnrollInPoolOperation::handle_FinishOperation, this,
-      boost::asio::placeholders::error));
-  } else {
-    // An error occurred. Log it and return. Since we are not starting a new
-    // operation the io_service will run out of work to do and the client will
-    // exit.
-    ELOG(1, e.message());
-  }
-}
-
-/// Handle received flag
-void EnrollInPoolOperation::handle_FinishOperation(const boost::system::error_code& e)
-{
-  Info info(__FUNCTION__);
-
-  if (flag == Success)
-    LOG(2, "DEBUG: Enrollment successful.");
-  else
-    LOG(2, "DEBUG: Enrollment failed.");
-
-  AsyncOperation::handle_FinishOperation(e);
-}
Index: src/Fragmentation/Automation/Controller/Commands/EnrollInPoolOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/EnrollInPoolOperation.hpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ 	(revision )
@@ -1,67 +1,0 @@
-/*
- * EnrollInPoolOperation.hpp
- *
- *  Created on: Feb 26, 2012
- *      Author: heber
- */
-
-#ifndef ENROLLINPOOLOPERATION_HPP_
-#define ENROLLINPOOLOPERATION_HPP_
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-
-#include <boost/asio.hpp>
-#include <string>
-#include <vector>
-
-#include "Connection.hpp"
-
-#include "Controller/Commands/AsyncOperation.hpp"
-#include "Jobs/FragmentJob.hpp"
-#include "Results/FragmentResult.hpp"
-#include "WorkerAddress.hpp"
-
-class EnrollInPoolOperation : public AsyncOperation  {
-public:
-  /// Constructor for class EnrollInPoolOperation.
-  EnrollInPoolOperation(Connection &_connection, const WorkerAddress &_address) :
-    AsyncOperation(std::string("enrollinpool"),_connection),
-    address(_address),
-    flag(Success)
-  {}
-  /// Destructor for class EnrollInPoolOperation
-  ~EnrollInPoolOperation() {}
-
-  enum EnrollFlag {
-    Success,
-    Fail
-  };
-
-protected:
-  // virtual function pointer to the connection handler
-  void handle_connect(const boost::system::error_code& e,
-      boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
-
-  /// Handle sending choice
-  void handle_SendChoice(const boost::system::error_code& e);
-
-  /// Handle receiving flag
-  void handle_ReceiveFlag(const boost::system::error_code& e);
-
-  /// Handle received flag
-  void handle_FinishOperation(const boost::system::error_code& e);
-
-private:
-  //!> address to enroll with
-  WorkerAddress address;
-
-  //!> flag returned by worker pool after enroll request
-  enum EnrollFlag flag;
-};
-
-
-#endif /* ENROLLINPOOLOPERATION_HPP_ */
Index: src/Fragmentation/Automation/Controller/Commands/GetNextJobIdOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/GetNextJobIdOperation.cpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ 	(revision )
@@ -1,118 +1,0 @@
-/*
- * Project: MoleCuilder
- * Description: creates and alters molecular systems
- * Copyright (C)  2012 University of Bonn. All rights reserved.
- * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
- */
-
-/*
- * GetNextJobIdOperation.cpp
- *
- *  Created on: Feb 16, 2012
- *      Author: heber
- */
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-// boost asio needs specific operator new
-#include <boost/asio.hpp>
-
-#include "CodePatterns/MemDebug.hpp"
-
-#include <boost/bind.hpp>
-#include <iostream>
-#include "Connection.hpp" // Must come before boost/serialization headers.
-#include <boost/serialization/vector.hpp>
-#include "CodePatterns/Info.hpp"
-#include "CodePatterns/Log.hpp"
-#include "ControllerChoices.hpp"
-#include "types.hpp"
-
-#include "Controller/Commands/GetNextJobIdOperation.hpp"
-
-/** Handle connect operation to send number of done jobs.
- *
- * \param e error code if something went wrong
- * \param endpoint_iterator endpoint of the connection
- */
-void GetNextJobIdOperation::handle_connect(const boost::system::error_code& e,
-    boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
-{
-  Info info(__FUNCTION__);
-  if (!e)
-  {
-    // Successfully established connection. Give choice.
-          enum ControllerChoices choice = GetNextJobId;
-    connection_.async_write(choice,
-      boost::bind(&GetNextJobIdOperation::handle_ReceiveNextId, this,
-      boost::asio::placeholders::error));
-  } else if (endpoint_iterator != boost::asio::ip::tcp::resolver::iterator()) {
-    // Try the next endpoint.
-    connection_.socket().close();
-    boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
-    connection_.socket().async_connect(endpoint,
-      boost::bind(&GetNextJobIdOperation::handle_connect, this,
-      boost::asio::placeholders::error, ++endpoint_iterator));
-  } else {
-    // An error occurred. Log it and return. Since we are not starting a new
-    // operation the io_service will run out of work to do and the client will
-    // exit.
-    ELOG(1, e.message());
-  }
-}
-
-/** Callback function when doneJobs have been received.
- *
- * \param e error code if something went wrong
- */
-void GetNextJobIdOperation::handle_ReceiveNextId(const boost::system::error_code& e)
-{
-  Info info(__FUNCTION__);
-  if (!e)
-  {
-    // The connection::async_read() function will automatically
-    // decode the data that is written to the underlying socket.
-    LOG(1, "INFO: Obtaining next available job id ...");
-    connection_.async_read(nextid,
-      boost::bind(&GetNextJobIdOperation::handle_FinishOperation, this,
-      boost::asio::placeholders::error));
-  }
-  else
-  {
-    // An error occurred.
-    ELOG(1, e.message());
-  }
-}
-
-/** Callback function when an operation has been completed.
- *
- * \param e error code if something went wrong
- */
-void GetNextJobIdOperation::handle_FinishOperation(const boost::system::error_code& e)
-{
-  Info info(__FUNCTION__);
-
-  // place id into nextids
-  nextids.push_back(nextid);
-  nextid = JobId::IllegalJob;
-
-  // and finish operation
-  AsyncOperation::handle_FinishOperation(e);
-}
-
-/** Getter for nextid.
- *
- * \sa checkResults()
- * \param next available JobId_t
- */
-size_t GetNextJobIdOperation::getNextId()
-{
-  ASSERT( nextids.size() != (size_t)0,
-      "GetNextJobIdOperation::getNextId() - no next id available.");
-  const JobId_t availableid = nextids.front();
-  nextids.pop_front();
-  return availableid;
-}
Index: src/Fragmentation/Automation/Controller/Commands/GetNextJobIdOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/GetNextJobIdOperation.hpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ 	(revision )
@@ -1,60 +1,0 @@
-/*
- * GetNextJobIdOperation.hpp
- *
- *  Created on: Feb 16, 2012
- *      Author: heber
- */
-
-#ifndef FRAGMENTCONTROLLER_GETNEXTJOBIDOPERATION_HPP_
-#define FRAGMENTCONTROLLER_GETNEXTJOBIDOPERATION_HPP_
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <boost/asio.hpp>
-
-#include "Connection.hpp"
-
-#include "Controller/Commands/AsyncOperation.hpp"
-#include "JobId.hpp"
-#include "types.hpp"
-
-/** This Operations requests number of present jobs and present results (done
- * jobs) from the server.
- *
- */
-class GetNextJobIdOperation : public AsyncOperation  {
-public:
-  /// Constructor for class GetNextJobIdOperation.
-  GetNextJobIdOperation(Connection &_connection) :
-    AsyncOperation(std::string("getnextjobid"), _connection),
-    nextid(JobId::IllegalJob)
-  {}
-  /// Destructor for class GetNextJobIdOperation
-  ~GetNextJobIdOperation() {}
-
-public:
-  // virtual function pointer to the connection handler
-  virtual void handle_connect(const boost::system::error_code& e,
-      boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
-
-  /// Callback function when doneJobs have been received.
-  void handle_ReceiveNextId(const boost::system::error_code& e);
-
-  /// Getter for nextid
-  size_t getNextId();
-
-protected:
-  /// Callback function when Operations finishes.
-  void handle_FinishOperation(const boost::system::error_code& e);
-
-  /// current jobs left to calculate and currently calculated results
-  std::list<JobId_t> nextids;
-
-  // temporary for receiving another job id
-  JobId_t nextid;
-};
-
-#endif /* FRAGMENTCONTROLLER_GETNEXTJOBIDOPERATION_HPP_ */
Index: src/Fragmentation/Automation/Controller/Commands/ObtainJobOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/ObtainJobOperation.cpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ 	(revision )
@@ -1,70 +1,0 @@
-/*
- * Project: MoleCuilder
- * Description: creates and alters molecular systems
- * Copyright (C)  2012 University of Bonn. All rights reserved.
- * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
- */
-
-/*
- * ObtainJobOperation.cpp
- *
- *  Created on: Feb 26, 2012
- *      Author: heber
- */
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-// boost asio needs specific operator new
-#include <boost/asio.hpp>
-
-#include "CodePatterns/MemDebug.hpp"
-
-#include "ObtainJobOperation.hpp"
-
-#include <boost/bind.hpp>
-#include "CodePatterns/Info.hpp"
-#include "CodePatterns/Log.hpp"
-#include "Jobs/FragmentJob.hpp"
-#include "WorkerChoices.hpp"
-
-/// Handle completion of a connect operation.
-void ObtainJobOperation::handle_connect(const boost::system::error_code& e,
-    boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
-{
-  Info info(__FUNCTION__);
-  if (!e)
-  {
-    // Successfully established connection. Start operation to read the list
-    // of jobs. The connection::async_read() function will automatically
-    // decode the data that is read from the underlying socket.
-    LOG(1, "INFO: Receiving a job ...");
-    connection_.async_read(job,
-      boost::bind(&ObtainJobOperation::handle_ReceiveJob, this,
-      boost::asio::placeholders::error));
-  } else if (endpoint_iterator != boost::asio::ip::tcp::resolver::iterator()) {
-    // Try the next endpoint.
-    connection_.socket().close();
-    boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
-    connection_.socket().async_connect(endpoint,
-      boost::bind(&ObtainJobOperation::handle_connect, this,
-      boost::asio::placeholders::error, ++endpoint_iterator));
-  } else {
-    // An error occurred. Log it and return. Since we are not starting a new
-    // operation the io_service will run out of work to do and the client will
-    // exit.
-    ELOG(1, e.message());
-  }
-}
-
-/// Callback function when job has been received.
-void ObtainJobOperation::handle_ReceiveJob(const boost::system::error_code& e)
-{
-  Info info(__FUNCTION__);
-
-  LOG(1, "INFO: Received job #" << job->getId() << ".");
-
-  AsyncOperation::handle_FinishOperation(e);
-}
Index: src/Fragmentation/Automation/Controller/Commands/ObtainJobOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/ObtainJobOperation.hpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ 	(revision )
@@ -1,58 +1,0 @@
-/*
- * ObtainJobOperation.hpp
- *
- *  Created on: Feb 26, 2012
- *      Author: heber
- */
-
-#ifndef OBTAINJOBOPERATION_HPP_
-#define OBTAINJOBOPERATION_HPP_
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-
-#include <boost/asio.hpp>
-#include <string>
-#include <vector>
-
-#include "Connection.hpp"
-
-#include "Controller/Commands/AsyncOperation.hpp"
-#include "Jobs/FragmentJob.hpp"
-#include "Results/FragmentResult.hpp"
-
-class ObtainJobOperation : public AsyncOperation  {
-public:
-  /// Constructor for class ObtainJobOperation.
-  ObtainJobOperation(Connection &_connection) :
-    AsyncOperation(std::string("obtainjob"),_connection) {}
-  /// Destructor for class ObtainJobOperation
-  ~ObtainJobOperation() {}
-
-  /** Getter for the obtained job.
-   *
-   * @return obtained FragmentJob
-   */
-  FragmentJob::ptr getJob()
-  {
-    return job;
-  }
-
-protected:
-  // virtual function pointer to the connection handler
-  void handle_connect(const boost::system::error_code& e,
-      boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
-
-  /// Callback function when job has been received.
-  void handle_ReceiveJob(const boost::system::error_code& e);
-
-private:
-  /// The data received from the server.
-  FragmentJob::ptr job;
-};
-
-
-#endif /* OBTAINJOBOPERATION_HPP_ */
Index: src/Fragmentation/Automation/Controller/Commands/Operation.hpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/Operation.hpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ 	(revision )
@@ -1,85 +1,0 @@
-/*
- * Operation.hpp
- *
- *  Created on: Mar 04, 2012
- *      Author: heber
- */
-
-#ifndef FRAGMENTCONTROLLER_OPERATION_HPP_
-#define FRAGMENTCONTROLLER_OPERATION_HPP_
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <string>
-
-#include "Connection.hpp"
-
-
-/** Class Operation defines the general interface common all Operations
- * whether synchronous or asynchronous. This allows for their storage in
- * a registry.
- *
- */
-class Operation
-{
-public:
-  /** Constructor for class Operation.
-   *
-   * @param _connection connection to use for connect and disconnect
-   * @param _name internal name to allow storage in a registry
-   */
-  Operation(const std::string &_name, Connection &_connection) :
-    connection_(_connection),
-    Exitflag(OkFlag),
-    name(_name)
-  {}
-  virtual ~Operation()
-  {}
-
-  /** Central virtual function that each class deriving from Operation has to implement.
-   *
-   * Here, connect, some read/writes, and disconnect should occur.
-   *
-   * @param _host host address to connect to
-   * @param _service service to connect to
-   */
-  virtual void operator()(const std::string& _host, const std::string& _service) = 0;
-
-  enum Exitflag_t {
-    OkFlag = 0,
-    ErrorFlag = 255
-  };
-
-  /** Getter for Exitflag.
-   *
-   * @return Exitflag
-   */
-  size_t getExitflag() const
-  {
-    return Exitflag;
-  }
-
-  /** Getter for name.
-   *
-   * @return const reference to Operation::name.
-   */
-  const std::string &getName() const {
-    return name;
-  }
-
-protected:
-  /// The Connection to the server.
-  Connection &connection_;
-
-  // exit flag of this operation, derived classes may change it
-  enum Exitflag_t Exitflag;
-
-private:
-  /// Name of this AsyncOperation (required for Registry pattern)
-  std::string name;
-};
-
-#endif /* FRAGMENTCONTROLLER_OPERATION_HPP_ */
Index: src/Fragmentation/Automation/Controller/Commands/ReceiveResultsOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/ReceiveResultsOperation.cpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ 	(revision )
@@ -1,115 +1,0 @@
-/*
- * Project: MoleCuilder
- * Description: creates and alters molecular systems
- * Copyright (C)  2011-2012 University of Bonn. All rights reserved.
- * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
- */
-
-/*
- * ReceiveResultsOperation.cpp
- *
- *  Created on: Dec 11, 2011
- *      Author: heber
- */
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-// boost asio needs specific operator new
-#include <boost/asio.hpp>
-
-#include "CodePatterns/MemDebug.hpp"
-
-#include <boost/bind.hpp>
-#include <iostream>
-#include <vector>
-#include "Connection.hpp" // Must come before boost/serialization headers.
-#include <boost/serialization/vector.hpp>
-#include "CodePatterns/Info.hpp"
-#include "CodePatterns/Log.hpp"
-#include "ControllerChoices.hpp"
-#include "Results/FragmentResult.hpp"
-
-#include "Controller/Commands/ReceiveResultsOperation.hpp"
-
-/** Handle connect operation to send results.
- *
- * \param e error code if something went wrong
- * \param endpoint_iterator endpoint of the connection
- */
-void ReceiveResultsOperation::handle_connect(const boost::system::error_code& e,
-    boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
-{
-  Info info(__FUNCTION__);
-  if (!e)
-  {
-    // Successfully established connection. Give choice.
-    enum ControllerChoices choice = ReceiveResults;
-    connection_.async_write(choice,
-      boost::bind(&ReceiveResultsOperation::handle_ReceivingResults, this,
-      boost::asio::placeholders::error));
-  } else if (endpoint_iterator != boost::asio::ip::tcp::resolver::iterator()) {
-    // Try the next endpoint.
-    connection_.socket().close();
-    boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
-    connection_.socket().async_connect(endpoint,
-      boost::bind(&ReceiveResultsOperation::handle_connect, this,
-      boost::asio::placeholders::error, ++endpoint_iterator));
-  } else {
-    // An error occurred. Log it and return. Since we are not starting a new
-    // operation the io_service will run out of work to do and the client will
-    // exit.
-    Exitflag = ErrorFlag;
-    ELOG(1, e.message());
-  }
-}
-
-/** Callback function when preparing to receive results
- *
- * \param e error code if something went wrong
- */
-void ReceiveResultsOperation::handle_ReceivingResults(const boost::system::error_code& e)
-{
-  Info info(__FUNCTION__);
-  if (!e)
-  {
-    // The connection::async_read() function will automatically
-    // decode the data that is written to the underlying socket.
-    LOG(1, "INFO: Sending "+toString(results.size())+" results ...");
-    connection_.async_read(results,
-      boost::bind(&ReceiveResultsOperation::handle_ReceivedResults, this,
-      boost::asio::placeholders::error));
-  }
-  else
-  {
-    // An error occurred.
-    Exitflag = ErrorFlag;
-    ELOG(1, e.message());
-  }
-}
-
-/** Callback function when results have been received.
- *
- * \param e error code if something went wrong
- */
-void ReceiveResultsOperation::handle_ReceivedResults(const boost::system::error_code& e)
-{
-  Info info(__FUNCTION__);
-
-  LOG(1, "INFO: Received "+toString(results.size())+" results.");
-
-  ReceiveResultsOperation::handle_FinishOperation(e);
-}
-
-/** Getter for results.
- *
- * \sa calculateResults()
- * \return vector of results for the added jobs (\sa addJobs()).
- */
-std::vector<FragmentResult::ptr> ReceiveResultsOperation::getResults()
-{
-  Info info(__FUNCTION__);
-  return results;
-}
Index: src/Fragmentation/Automation/Controller/Commands/ReceiveResultsOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/ReceiveResultsOperation.hpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ 	(revision )
@@ -1,52 +1,0 @@
-/*
- * ReceiveResultsOperation.hpp
- *
- *  Created on: Dec 11, 2011
- *      Author: heber
- */
-
-#ifndef FRAGMENTCONTROLLER_RECEIVERESULTSOPERATION_HPP_
-#define FRAGMENTCONTROLLER_RECEIVERESULTSOPERATION_HPP_
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <boost/asio.hpp>
-#include <string>
-#include <vector>
-
-#include "Connection.hpp"
-#include "Results/FragmentResult.hpp"
-
-#include "Controller/Commands/AsyncOperation.hpp"
-
-class ReceiveResultsOperation : public AsyncOperation  {
-public:
-  /// Constructor for class ReceiveResultsOperation.
-  ReceiveResultsOperation(Connection &_connection) :
-    AsyncOperation(std::string("receiveresults"), _connection) {}
-  /// Destructor for class ReceiveResultsOperation
-  ~ReceiveResultsOperation() {}
-
-public:
-  // virtual function pointer to the connection handler
-  virtual void handle_connect(const boost::system::error_code& e,
-      boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
-
-  /// Callback function when results are about to be received.
-  void handle_ReceivingResults(const boost::system::error_code& e);
-
-  /// Callback function when results have been received.
-  void handle_ReceivedResults(const boost::system::error_code& e);
-
-  /// Getter for results
-  std::vector<FragmentResult::ptr> getResults();
-
-protected:
-  /// bunch of results
-  std::vector<FragmentResult::ptr> results;
-};
-
-#endif /* FRAGMENTCONTROLLER_RECEIVERESULTSOPERATION_HPP_ */
Index: src/Fragmentation/Automation/Controller/Commands/RemoveFromPoolOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/RemoveFromPoolOperation.cpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ 	(revision )
@@ -1,45 +1,0 @@
-/*
- * 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.
- */
-
-/*
- * RemoveFromPoolOperation.cpp
- *
- *  Created on: Mar 01, 2012
- *      Author: heber
- */
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-// boost asio needs specific operator new
-#include <boost/asio.hpp>
-
-#include "CodePatterns/MemDebug.hpp"
-
-#include <boost/bind.hpp>
-#include <iostream>
-#include "Connection.hpp" // Must come before boost/serialization headers.
-#include "CodePatterns/Info.hpp"
-#include "CodePatterns/Log.hpp"
-#include "WorkerChoices.hpp"
-
-#include "Controller/Commands/RemoveFromPoolOperation.hpp"
-
-/** Internal operation after connect to give address and send remove signal
- *
- */
-void RemoveFromPoolOperation::internal()
-{
-  Info info(__FUNCTION__);
-
-  LOG(1, "INFO: Removing " << address << " from server's pool ...");
-  connection_.sync_write(address);
-  enum WorkerChoices choice = RemoveFromPool;
-  connection_.sync_write(choice);
-}
Index: src/Fragmentation/Automation/Controller/Commands/RemoveFromPoolOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/RemoveFromPoolOperation.hpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ 	(revision )
@@ -1,44 +1,0 @@
-/*
- * RemoveFromPoolOperation.hpp
- *
- *  Created on: Mar 01, 2012
- *      Author: heber
- */
-
-#ifndef FRAGMENTCONTROLLER_REMOVEFROMPOOLOPERATION_HPP_
-#define FRAGMENTCONTROLLER_REMOVEFROMPOOLOPERATION_HPP_
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <boost/asio.hpp>
-#include <string>
-#include <vector>
-
-#include "Connection.hpp"
-
-#include "Controller/Commands/SyncOperation.hpp"
-#include "WorkerAddress.hpp"
-
-class RemoveFromPoolOperation : public SyncOperation  {
-public:
-  /// Constructor for class RemoveFromPoolOperation.
-  RemoveFromPoolOperation(Connection &_connection, const WorkerAddress &_address) :
-    SyncOperation(std::string("shutdownworker"),_connection),
-    address(_address)
-  {}
-  /// Destructor for class RemoveFromPoolOperation
-  ~RemoveFromPoolOperation() {}
-
-public:
-  // function that implements read&writes in between connect/disconnect
-  virtual void internal();
-
-private:
-  //!> address to enroll with
-  WorkerAddress address;
-};
-
-#endif /* FRAGMENTCONTROLLER_REMOVEFROMPOOLOPERATION_HPP_ */
Index: src/Fragmentation/Automation/Controller/Commands/SendJobToWorkerOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/SendJobToWorkerOperation.cpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ 	(revision )
@@ -1,64 +1,0 @@
-/*
- * Project: MoleCuilder
- * Description: creates and alters molecular systems
- * Copyright (C)  2012 University of Bonn. All rights reserved.
- * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
- */
-
-/*
- * SendJobToWorkerOperation.cpp
- *
- *  Created on: Feb 22, 2012
- *      Author: heber
- */
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-// boost asio needs specific operator new
-#include <boost/asio.hpp>
-
-#include "CodePatterns/MemDebug.hpp"
-
-#include <boost/bind.hpp>
-#include <iostream>
-#include "Connection.hpp" // Must come before boost/serialization headers.
-#include "CodePatterns/Info.hpp"
-#include "CodePatterns/Log.hpp"
-
-#include "Controller/Commands/SendJobToWorkerOperation.hpp"
-
-/** Handle connect operation to shutdown scheduler.
- *
- * \param e error code if something went wrong
- * \param endpoint_iterator endpoint of the connection
- */
-void SendJobToWorkerOperation::handle_connect(const boost::system::error_code& e,
-    boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
-{
-  Info info(__FUNCTION__);
-  if (!e)
-  {
-    // The connection::async_write() function will automatically
-    // serialize the data structure for us.
-    LOG(1, "INFO: Sending job #" << job->getId() << ".");
-    connection_.async_write(job,
-      boost::bind(&SendJobToWorkerOperation::handle_FinishOperation, this,
-      boost::asio::placeholders::error));
-  } else if (endpoint_iterator != boost::asio::ip::tcp::resolver::iterator()) {
-    // Try the next endpoint.
-    connection_.socket().close();
-    boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
-    connection_.socket().async_connect(endpoint,
-      boost::bind(&SendJobToWorkerOperation::handle_connect, this,
-      boost::asio::placeholders::error, ++endpoint_iterator));
-  } else {
-    // An error occurred. Log it and return. Since we are not starting a new
-    // operation the io_service will run out of work to do and the client will
-    // exit.
-    Exitflag = ErrorFlag;
-    ELOG(1, e.message());
-  }
-}
Index: src/Fragmentation/Automation/Controller/Commands/SendJobToWorkerOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/SendJobToWorkerOperation.hpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ 	(revision )
@@ -1,57 +1,0 @@
-/*
- * SendJobToWorkerOperation.hpp
- *
- *  Created on: Feb 22, 2012
- *      Author: heber
- */
-
-#ifndef FRAGMENTCONTROLLER_SENDJOBTOWORKEROPERATION_HPP_
-#define FRAGMENTCONTROLLER_SENDJOBTOWORKEROPERATION_HPP_
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <boost/asio.hpp>
-#include <string>
-#include <vector>
-
-#include "Connection.hpp"
-
-#include "Controller/Commands/AsyncOperation.hpp"
-#include "Jobs/FragmentJob.hpp"
-#include "Jobs/SystemCommandJob.hpp"
-#include "WorkerAddress.hpp"
-
-class SendJobToWorkerOperation : public AsyncOperation  {
-public:
-  /// Constructor for class SendJobToWorkerOperation.
-  SendJobToWorkerOperation(Connection &_connection) :
-    AsyncOperation(std::string("sendjobtoworker"),_connection),
-    job( new SystemCommandJob(std::string("/bin/true"), std::string("donothing"), JobId::NoJob) )
-  {}
-  /// Destructor for class SendJobToWorkerOperation
-  ~SendJobToWorkerOperation() {}
-
-  /** Setter for job.
-   *
-   * @param _job job to take over internally
-   */
-  void setJob(FragmentJob::ptr &_job)
-  {
-    job.reset();
-    job = _job;
-  }
-
-public:
-  // virtual function pointer to the connection handler
-  virtual void handle_connect(const boost::system::error_code& e,
-      boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
-
-private:
-  //!> job to send to
-  FragmentJob::ptr job;
-};
-
-#endif /* FRAGMENTCONTROLLER_SENDJOBTOWORKEROPERATION_HPP_ */
Index: src/Fragmentation/Automation/Controller/Commands/SendJobsOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/SendJobsOperation.cpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ 	(revision )
@@ -1,124 +1,0 @@
-/*
- * Project: MoleCuilder
- * Description: creates and alters molecular systems
- * Copyright (C)  2011-2012 University of Bonn. All rights reserved.
- * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
- */
-
-/*
- * SendJobsOperation.cpp
- *
- *  Created on: Dec 11, 2011
- *      Author: heber
- */
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-// boost asio needs specific operator new
-#include <boost/asio.hpp>
-
-#include "CodePatterns/MemDebug.hpp"
-
-#include <boost/bind.hpp>
-#include <boost/foreach.hpp>
-#include <iostream>
-#include <vector>
-#include "Connection.hpp" // Must come before boost/serialization headers.
-#include <boost/serialization/vector.hpp>
-#include "CodePatterns/Info.hpp"
-#include "CodePatterns/Log.hpp"
-#include "ControllerChoices.hpp"
-#include "Jobs/FragmentJob.hpp"
-
-#include "Controller/Commands/SendJobsOperation.hpp"
-
-/** Handle connect operation to receive jobs from controller
- *
- * \param e error code if something went wrong
- * \param endpoint_iterator endpoint of the connection
- */
-void SendJobsOperation::handle_connect(const boost::system::error_code& e,
-    boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
-{
-  Info info(__FUNCTION__);
-  if (!e)
-  {
-    // Successfully established connection. Give choice.
-    enum ControllerChoices choice = SendJobs;
-    connection_.async_write(choice,
-      boost::bind(&SendJobsOperation::handle_SendJobs, this,
-      boost::asio::placeholders::error));
-  } else if (endpoint_iterator != boost::asio::ip::tcp::resolver::iterator()) {
-    // Try the next endpoint.
-    connection_.socket().close();
-    boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
-    connection_.socket().async_connect(endpoint,
-      boost::bind(&SendJobsOperation::handle_connect, this,
-      boost::asio::placeholders::error, ++endpoint_iterator));
-  } else {
-    // An error occurred. Log it and return. Since we are not starting a new
-    // operation the io_service will run out of work to do and the client will
-    // exit.
-    Exitflag = ErrorFlag;
-    ELOG(1, e.message());
-  }
-}
-
-/** Callback function when jobs have been sent.
- *
- * \param e error code if something went wrong
- */
-void SendJobsOperation::handle_SendJobs(const boost::system::error_code& e)
-{
-  Info info(__FUNCTION__);
-  if (!e)
-  {
-    // Successfully established connection. Start operation to read the vector
-    // of jobs. The connection::async_write() function will automatically
-    // encode the data that is written to the underlying socket.
-    LOG(1, "INFO: Sending "+toString(jobs.size())+" jobs ...");
-    connection_.async_write(jobs,
-      boost::bind(&SendJobsOperation::handle_FinishOperation, this,
-      boost::asio::placeholders::error));
-  }
-  else
-  {
-    // An error occurred.
-    Exitflag = ErrorFlag;
-    ELOG(1, e.message());
-  }
-
-  // Since we are not starting a new operation the io_service will run out of
-  // work to do and the client will exit.
-}
-
-/** Callback function when an operation has been completed.
- *
- * \param e error code if something went wrong
- */
-void SendJobsOperation::handle_FinishOperation(const boost::system::error_code& e)
-{
-  Info info(__FUNCTION__);
-
-  LOG(1, "INFO: Jobs have been sent. Clearing.");
-  jobs.clear();
-
-  AsyncOperation::handle_FinishOperation(e);
-}
-
-/** Place number of jobs into this controller.
- *
- * \param _jobs jobs to add
- */
-void SendJobsOperation::addJobs(const std::vector<FragmentJob::ptr> &_jobs)
-{
-  jobs.reserve(jobs.size()+_jobs.size());
-  BOOST_FOREACH(FragmentJob::ptr job, _jobs) {
-    jobs.push_back(job);
-  }
-  LOG(1, "INFO: SendJobsOperation now contains " << jobs.size() << " job(s).");
-}
-
Index: src/Fragmentation/Automation/Controller/Commands/SendJobsOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/SendJobsOperation.hpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ 	(revision )
@@ -1,60 +1,0 @@
-/*
- * SendJobsOperation.hpp
- *
- *  Created on: Dec 11, 2011
- *      Author: heber
- */
-
-#ifndef FRAGMENTCONTROLLER_SENDJOBSOPERATION_HPP_
-#define FRAGMENTCONTROLLER_SENDJOBSOPERATION_HPP_
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <boost/asio.hpp>
-#include <string>
-#include <vector>
-
-#include "Connection.hpp"
-#include "Jobs/FragmentJob.hpp"
-
-#include "Controller/Commands/AsyncOperation.hpp"
-
-class SendJobsOperation : public AsyncOperation {
-public:
-  /// Constructor for class SendJobsOperation.
-  SendJobsOperation(Connection &_connection) :
-    AsyncOperation(std::string("sendjobs"), _connection) {}
-  /// Destructor for class SendJobsOperation
-  ~SendJobsOperation() {}
-
-public:
-  // virtual function pointer to the connection handler
-  virtual void handle_connect(const boost::system::error_code& e,
-      boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
-
-  /// Callback function when bunch of jobs have been sent.
-  void handle_SendJobs(const boost::system::error_code& e);
-
-  /// Setter for jobs
-  void addJobs(const std::vector<FragmentJob::ptr> &jobs);
-
-  /** Getter for number of jobs present in the queue.
-   *
-   * \return jobs.size()
-   */
-  size_t getPresentJobs() const
-  {
-    return jobs.size();
-  }
-
-protected:
-  void handle_FinishOperation(const boost::system::error_code& e);
-
-  /// bunch of jobs
-  std::vector<FragmentJob::ptr> jobs;
-};
-
-#endif /* FRAGMENTCONTROLLER_SENDJOBSOPERATION_HPP_ */
Index: src/Fragmentation/Automation/Controller/Commands/ShutdownOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/ShutdownOperation.cpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ 	(revision )
@@ -1,42 +1,0 @@
-/*
- * Project: MoleCuilder
- * Description: creates and alters molecular systems
- * Copyright (C)  2012 University of Bonn. All rights reserved.
- * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
- */
-
-/*
- * ShutdownOperation.cpp
- *
- *  Created on: Feb 28, 2012
- *      Author: heber
- */
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-// boost asio needs specific operator new
-#include <boost/asio.hpp>
-
-#include "CodePatterns/MemDebug.hpp"
-
-#include <boost/bind.hpp>
-#include <iostream>
-#include "Connection.hpp" // Must come before boost/serialization headers.
-#include "CodePatterns/Info.hpp"
-#include "ControllerChoices.hpp"
-
-#include "Controller/Commands/ShutdownOperation.hpp"
-
-/** Virtual internal function to give shutdown choice.
- *
- */
-void ShutdownOperation::internal()
-{
-  Info info(__FUNCTION__);
-  enum ControllerChoices choice = ShutdownControllerSocket;
-  connection_.sync_write(choice);
-}
-
Index: src/Fragmentation/Automation/Controller/Commands/ShutdownOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/ShutdownOperation.hpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ 	(revision )
@@ -1,40 +1,0 @@
-/*
- * ShutdownOperation.hpp
- *
- *  Created on: Dec 11, 2011
- *      Author: heber
- */
-
-#ifndef FRAGMENTCONTROLLER_SHUTDOWNOPERATION_HPP_
-#define FRAGMENTCONTROLLER_SHUTDOWNOPERATION_HPP_
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <boost/asio.hpp>
-#include <string>
-#include <vector>
-
-#include "Connection.hpp"
-
-#include "Controller/Commands/SyncOperation.hpp"
-
-/** Synchronous operation that gives shutdown command.
- *
- */
-class ShutdownOperation : public SyncOperation  {
-public:
-  /// Constructor for class ShutdownOperation.
-  ShutdownOperation(Connection &_connection) :
-    SyncOperation(std::string("shutdown"),_connection) {}
-  /// Destructor for class ShutdownOperation
-  ~ShutdownOperation() {}
-
-public:
-  // function that implements read&writes in between connect/disconnect
-  virtual void internal();
-};
-
-#endif /* FRAGMENTCONTROLLER_SHUTDOWNOPERATION_HPP_ */
Index: src/Fragmentation/Automation/Controller/Commands/ShutdownWorkerOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/ShutdownWorkerOperation.cpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ 	(revision )
@@ -1,46 +1,0 @@
-/*
- * 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.
- */
-
-/*
- * ShutdownWorkerOperation.cpp
- *
- *  Created on: 11.12.2011
- *      Author: heber
- */
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-// boost asio needs specific operator new
-#include <boost/asio.hpp>
-
-#include "CodePatterns/MemDebug.hpp"
-
-#include <boost/bind.hpp>
-#include <iostream>
-#include "Connection.hpp" // Must come before boost/serialization headers.
-#include "CodePatterns/Info.hpp"
-#include "ControllerChoices.hpp"
-#include "Jobs/SystemCommandJob.hpp"
-#include "JobId.hpp"
-
-#include "Controller/Commands/ShutdownWorkerOperation.hpp"
-
-FragmentJob::ptr ShutdownWorkerOperation::NoJob(new SystemCommandJob(std::string(""), std::string(""), JobId::NoJob));
-
-/** Virtual internal function to give shutdown choice.
- *
- */
-void ShutdownWorkerOperation::internal()
-{
-  Info info(__FUNCTION__);
-
-  // send the NoJob
-  connection_.sync_write(NoJob);
-}
Index: src/Fragmentation/Automation/Controller/Commands/ShutdownWorkerOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/ShutdownWorkerOperation.hpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ 	(revision )
@@ -1,45 +1,0 @@
-/*
- * ShutdownWorkerOperation.hpp
- *
- *  Created on: Mar 04, 2012
- *      Author: heber
- */
-
-#ifndef FRAGMENTCONTROLLER_SHUTDOWNWORKEROPERATION_HPP_
-#define FRAGMENTCONTROLLER_SHUTDOWNWORKEROPERATION_HPP_
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <boost/asio.hpp>
-#include <string>
-#include <vector>
-
-#include "Connection.hpp"
-
-#include "Controller/Commands/SyncOperation.hpp"
-#include "Jobs/FragmentJob.hpp"
-
-/** Synchronous operation that gives shutdown command.
- *
- */
-class ShutdownWorkerOperation : public SyncOperation  {
-public:
-  /// Constructor for class ShutdownWorkerOperation.
-  ShutdownWorkerOperation(Connection &_connection) :
-    SyncOperation(std::string("shutdown"),_connection) {}
-  /// Destructor for class ShutdownWorkerOperation
-  ~ShutdownWorkerOperation() {}
-
-public:
-  // function that implements read&writes in between connect/disconnect
-  virtual void internal();
-
-private:
-  //!> static entity to indicate to clients that the queue is empty.
-  static FragmentJob::ptr NoJob;
-};
-
-#endif /* FRAGMENTCONTROLLER_SHUTDOWNWORKEROPERATION_HPP_ */
Index: src/Fragmentation/Automation/Controller/Commands/SubmitResultOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/SubmitResultOperation.cpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ 	(revision )
@@ -1,114 +1,0 @@
-/*
- * Project: MoleCuilder
- * Description: creates and alters molecular systems
- * Copyright (C)  2012 University of Bonn. All rights reserved.
- * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
- */
-
-/*
- * SubmitResultOperation.cpp
- *
- *  Created on: Feb 26, 2012
- *      Author: heber
- */
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-// boost asio needs specific operator new
-#include <boost/asio.hpp>
-
-#include "CodePatterns/MemDebug.hpp"
-
-#include "SubmitResultOperation.hpp"
-
-#include <boost/bind.hpp>
-#include "CodePatterns/Info.hpp"
-#include "CodePatterns/Log.hpp"
-#include "Results/FragmentResult.hpp"
-#include "WorkerChoices.hpp"
-
-
-/// Handle completion of a connect operation.
-void SubmitResultOperation::handle_connect(const boost::system::error_code& e,
-    boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
-{
-  Info info(__FUNCTION__);
-  if (!e)
-  {
-    // Successfully established connection. Start operation to read the list
-    // of jobs. The connection::async_write() function will automatically
-    // decode the data that is read from the underlying socket.
-    LOG(1, "INFO: Sending address " << address << " ...");
-    connection_.async_write(address,
-      boost::bind(&SubmitResultOperation::handle_SendChoice, this,
-      boost::asio::placeholders::error));
-  } else if (endpoint_iterator != boost::asio::ip::tcp::resolver::iterator()) {
-    // Try the next endpoint.
-    connection_.socket().close();
-    boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
-    connection_.socket().async_connect(endpoint,
-      boost::bind(&SubmitResultOperation::handle_connect, this,
-      boost::asio::placeholders::error, ++endpoint_iterator));
-  } else {
-    // An error occurred. Log it and return. Since we are not starting a new
-    // operation the io_service will run out of work to do and the client will
-    // exit.
-    exitflag = ErrorFlag;
-    ELOG(1, e.message());
-  }
-}
-
-/// Callback function when address has been sent and result is about to
-void SubmitResultOperation::handle_SendChoice(const boost::system::error_code& e)
-{
-  Info info(__FUNCTION__);
-  if (!e)
-  {
-    // Successfully established connection. Start operation to read the list
-    // of jobs. The connection::async_write() function will automatically
-    // decode the data that is read from the underlying socket.
-    enum WorkerChoices choice = SendResult;
-    connection_.async_write(choice,
-      boost::bind(&SubmitResultOperation::handle_SendResult, this,
-      boost::asio::placeholders::error));
-  } else {
-    // An error occurred. Log it and return. Since we are not starting a new
-    // operation the io_service will run out of work to do and the client will
-    // exit.
-    exitflag = ErrorFlag;
-    ELOG(1, e.message());
-  }
-}
-
-/// Callback function when address has been sent and result is about to
-void SubmitResultOperation::handle_SendResult(const boost::system::error_code& e)
-{
-  Info info(__FUNCTION__);
-  if (!e)
-  {
-    // Successfully established connection. Start operation to read the list
-    // of jobs. The connection::async_write() function will automatically
-    // decode the data that is read from the underlying socket.
-    LOG(1, "INFO: Sending result #" << result->getId() << " ...");
-    connection_.async_write(result,
-      boost::bind(&SubmitResultOperation::handle_FinishOperation, this,
-      boost::asio::placeholders::error));
-  } else {
-    // An error occurred. Log it and return. Since we are not starting a new
-    // operation the io_service will run out of work to do and the client will
-    // exit.
-    exitflag = ErrorFlag;
-    ELOG(1, e.message());
-  }
-}
-
-/// Callback function when result has been sent.
-void SubmitResultOperation::handle_FinishOperation(const boost::system::error_code& e)
-{
-  Info info(__FUNCTION__);
-  LOG(1, "INFO: result #" << result->getId() << " sent.");
-  AsyncOperation::handle_FinishOperation(e);
-}
Index: src/Fragmentation/Automation/Controller/Commands/SubmitResultOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/SubmitResultOperation.hpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ 	(revision )
@@ -1,90 +1,0 @@
-/*
- * SubmitResultOperation.hpp
- *
- *  Created on: Feb 26, 2012
- *      Author: heber
- */
-
-#ifndef SUBMITRESULTOPERATION_HPP_
-#define SUBMITRESULTOPERATION_HPP_
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-
-#include <boost/asio.hpp>
-#include <string>
-#include <vector>
-
-#include "Connection.hpp"
-
-#include "Controller/Commands/AsyncOperation.hpp"
-#include "Jobs/FragmentJob.hpp"
-#include "Results/FragmentResult.hpp"
-#include "WorkerAddress.hpp"
-
-class SubmitResultOperation : public AsyncOperation  {
-public:
-  /// Constructor for class SubmitResultOperation.
-  SubmitResultOperation(Connection &_connection, const WorkerAddress &_address) :
-    AsyncOperation(std::string("submitresult"),_connection),
-    result( new FragmentResult(JobId::NoJob, std::string("EmptyResult")) ),
-    address(_address),
-    exitflag(OkFlag)
-  {}
-  /// Destructor for class SubmitResultOperation
-  ~SubmitResultOperation() {}
-
-  /** Sets the result to submit.
-   *
-   * @param _result result to submit
-   */
-  void setResult(FragmentResult::ptr &_result)
-  {
-    result.reset();
-    result = _result;
-  }
-
-public:
-  enum {
-    OkFlag = 0,
-    ErrorFlag = 1
-  };
-
-  /** Returns the flag of the handled operation.
-   *
-   */
-  size_t getFlag() const
-  {
-    return exitflag;
-  }
-
-protected:
-  // virtual function pointer to the connection handler
-  void handle_connect(const boost::system::error_code& e,
-      boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
-
-  /// Callback function when address has been sent and result is about to.
-  void handle_SendChoice(const boost::system::error_code& e);
-
-  /// Callback function when result has been sent.
-  void handle_SendResult(const boost::system::error_code& e);
-
-  /// Callback function when result has been sent.
-  void handle_FinishOperation(const boost::system::error_code& e);
-
-private:
-  // static entity of an empty result
-  FragmentResult::ptr result;
-
-  //!> address for listener
-  WorkerAddress address;
-
-  /// exit flag
-  size_t exitflag;
-};
-
-
-#endif /* SUBMITRESULTOPERATION_HPP_ */
Index: src/Fragmentation/Automation/Controller/Commands/SyncOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/SyncOperation.cpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ 	(revision )
@@ -1,79 +1,0 @@
-/*
- * 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.
- */
-
-/*
- * SyncOperation.cpp
- *
- *  Created on: Mar 04, 2012
- *      Author: heber
- */
-
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-// boost asio needs specific operator new
-#include <boost/asio.hpp>
-
-#include "CodePatterns/MemDebug.hpp"
-
-#include <boost/bind.hpp>
-#include <vector>
-#include "Connection.hpp" // Must come before boost/serialization headers.
-#include "CodePatterns/Info.hpp"
-#include "CodePatterns/Log.hpp"
-
-#include "Controller/Commands/SyncOperation.hpp"
-
-/** Internal function to connect connection_.
- *
- */
-void SyncOperation::connect(const std::string& _host, const std::string& _service)
-{
-  // Resolve the host name into an IP address.
-  boost::asio::ip::tcp::resolver resolver(connection_.socket().get_io_service());
-  boost::asio::ip::tcp::resolver::query query(_host, _service);
-  boost::asio::ip::tcp::resolver::iterator endpoint_iterator =
-    resolver.resolve(query);
-  boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
-
-  // Start an asynchronous connect operation.
-  std::cout << "Connecting to endpoint " << endpoint << " ..." << std::endl;
-  connection_.socket().connect(endpoint);
-}
-
-
-/** Internal function to disconnect connection_ correctly.
- *
- */
-void SyncOperation::disconnect()
-{
-  connection_.socket().close();
-}
-
-/** Wrapper function for the virtual call to internal() that connects and disconnects.
- *
- * @param _host host address to connect to
- * @param _service service to connect to
- */
-void SyncOperation::operator()(const std::string& _host, const std::string& _service)
-{
-  LOG(1, "INFO: Commencing operation ...");
-
-  // connect
-  connect(_host, _service);
-
-  // call virtual function to continue
-  internal();
-
-  // disconnect
-  disconnect();
-
-  LOG(1, "INFO: Operation completed.");
-}
Index: src/Fragmentation/Automation/Controller/Commands/SyncOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/SyncOperation.hpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ 	(revision )
@@ -1,54 +1,0 @@
-/*
- * SyncOperation.hpp
- *
- *  Created on: Mar 04, 2012
- *      Author: heber
- */
-
-#ifndef FRAGMENTCONTROLLER_SYNCOPERATION_HPP_
-#define FRAGMENTCONTROLLER_SYNCOPERATION_HPP_
-
-// include config.h
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <boost/asio.hpp>
-#include <string>
-#include <vector>
-
-#include "Operation.hpp"
-
-class SyncOperation : public Operation {
-public:
-  /** Constructor for class SyncOperation.
-   *
-   * \param _name name for this Operation for retrieval from a registry
-   * \param _connection connection to operate on
-   */
-  SyncOperation(const std::string &_name, Connection &_connection) :
-    Operation(_name, _connection)
-  {}
-
-  /** Destructor for class SyncOperation.
-   *
-   */
-  virtual ~SyncOperation()
-  {}
-
-public:
-  // virtual function pointer to the operation to do
-  void operator()(const std::string& _host, const std::string& _service);
-
-protected:
-  // function that implements read&writes in between connect/disconnect
-  virtual void internal() = 0;
-
-  // internal function to connect to server
-  void connect(const std::string& _host, const std::string& _service);
-
-  /// internal function to disconnect from server
-  void disconnect();
-};
-
-#endif /* FRAGMENTCONTROLLER_SYNCOPERATION_HPP_ */
Index: src/Fragmentation/Automation/Controller/FragmentController.cpp
===================================================================
--- src/Fragmentation/Automation/Controller/FragmentController.cpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ src/Fragmentation/Automation/Controller/FragmentController.cpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -23,14 +23,15 @@
 #include "CodePatterns/MemDebug.hpp"
 
+#include "FragmentController.hpp"
+
 #include "Connection.hpp" // Must come before boost/serialization headers.
 #include "CodePatterns/Info.hpp"
 #include "CodePatterns/Log.hpp"
 
-#include "Controller/FragmentController.hpp"
-#include "Controller/Commands/CheckResultsOperation.hpp"
-#include "Controller/Commands/GetNextJobIdOperation.hpp"
-#include "Controller/Commands/ReceiveResultsOperation.hpp"
-#include "Controller/Commands/SendJobsOperation.hpp"
-#include "Controller/Commands/ShutdownOperation.hpp"
+#include "Operations/Controllers/CheckResultsOperation.hpp"
+#include "Operations/Controllers/GetNextJobIdOperation.hpp"
+#include "Operations/Controllers/ReceiveResultsOperation.hpp"
+#include "Operations/Controllers/SendJobsOperation.hpp"
+#include "Operations/Controllers/ShutdownOperation.hpp"
 
 /** Constructor of class FragmentController.
Index: src/Fragmentation/Automation/FragmentScheduler.cpp
===================================================================
--- src/Fragmentation/Automation/FragmentScheduler.cpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ src/Fragmentation/Automation/FragmentScheduler.cpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -36,5 +36,5 @@
 #include "CodePatterns/Observer/Notification.hpp"
 #include "ControllerChoices.hpp"
-#include "Controller/Commands/EnrollInPoolOperation.hpp"
+#include "Operations/Workers/EnrollInPoolOperation.hpp"
 #include "Jobs/MPQCCommandJob.hpp"
 #include "Jobs/SystemCommandJob.hpp"
Index: src/Fragmentation/Automation/FragmentScheduler.hpp
===================================================================
--- src/Fragmentation/Automation/FragmentScheduler.hpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ src/Fragmentation/Automation/FragmentScheduler.hpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -21,6 +21,6 @@
 #include "Connection.hpp"
 #include "ControllerChoices.hpp"
-#include "Controller/Commands/SendJobToWorkerOperation.hpp"
-#include "Controller/Commands/ShutdownWorkerOperation.hpp""
+#include "Operations/Servers/SendJobToWorkerOperation.hpp"
+#include "Operations/Servers/ShutdownWorkerOperation.hpp"
 #include "ControllerChoices.hpp"
 #include "FragmentQueue.hpp"
Index: src/Fragmentation/Automation/Makefile.am
===================================================================
--- src/Fragmentation/Automation/Makefile.am	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ src/Fragmentation/Automation/Makefile.am	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -42,42 +42,42 @@
   $(BOOST_IOSTREAMS_LDFLAGS) $(BOOST_IOSTREAMS_LIBS)
 
-FRAGMENTATIONCOMMANDSSOURCE = \
-  Controller/Commands/AsyncOperation.cpp \
-  Controller/Commands/CheckResultsOperation.cpp \
-  Controller/Commands/EnrollInPoolOperation.cpp \
-  Controller/Commands/GetNextJobIdOperation.cpp \
-  Controller/Commands/ObtainJobOperation.cpp \
-  Controller/Commands/ReceiveResultsOperation.cpp \
-  Controller/Commands/RemoveFromPoolOperation.cpp \
-  Controller/Commands/SendJobsOperation.cpp \
-  Controller/Commands/SendJobToWorkerOperation.cpp \
-  Controller/Commands/ShutdownOperation.cpp \
-  Controller/Commands/ShutdownWorkerOperation.cpp \
-  Controller/Commands/SubmitResultOperation.cpp \
-  Controller/Commands/SyncOperation.cpp
+FRAGMENTATIONOPERATIONSSOURCE = \
+  Operations/AsyncOperation.cpp \
+  Operations/SyncOperation.cpp \
+  Operations/Controllers/CheckResultsOperation.cpp \
+  Operations/Controllers/GetNextJobIdOperation.cpp \
+  Operations/Controllers/ReceiveResultsOperation.cpp \
+  Operations/Controllers/SendJobsOperation.cpp \
+  Operations/Controllers/ShutdownOperation.cpp \
+  Operations/Servers/SendJobToWorkerOperation.cpp \
+  Operations/Servers/ShutdownWorkerOperation.cpp \
+  Operations/Workers/EnrollInPoolOperation.cpp \
+  Operations/Workers/ObtainJobOperation.cpp \
+  Operations/Workers/RemoveFromPoolOperation.cpp \
+  Operations/Workers/SubmitResultOperation.cpp
 
-FRAGMENTATIONCOMMANDSHEADER = \
+FRAGMENTATIONOPERATIONSHEADER = \
   ControllerChoices.hpp \
-  Controller/Commands/AsyncOperation.hpp \
-  Controller/Commands/CheckResultsOperation.hpp \
-  Controller/Commands/EnrollInPoolOperation.hpp \
-  Controller/Commands/GetNextJobIdOperation.hpp \
-  Controller/Commands/ObtainJobOperation.hpp \
-  Controller/Commands/Operation.hpp \
-  Controller/Commands/ReceiveResultsOperation.hpp \
-  Controller/Commands/RemoveFromPoolOperation.hpp \
-  Controller/Commands/SendJobsOperation.hpp \
-  Controller/Commands/SendJobToWorkerOperation.hpp \
-  Controller/Commands/ShutdownOperation.hpp \
-  Controller/Commands/ShutdownWorkerOperation.hpp \
-  Controller/Commands/SubmitResultOperation.hpp \
-  Controller/Commands/SyncOperation.hpp \
+  Operations/AsyncOperation.hpp \
+  Operations/Operation.hpp \
+  Operations/SyncOperation.hpp \
+  Operations/Controllers/CheckResultsOperation.hpp \
+  Operations/Controllers/GetNextJobIdOperation.hpp \
+  Operations/Controllers/ReceiveResultsOperation.hpp \
+  Operations/Controllers/SendJobsOperation.hpp \
+  Operations/Controllers/ShutdownOperation.hpp \
+  Operations/Servers/SendJobToWorkerOperation.hpp \
+  Operations/Servers/ShutdownWorkerOperation.hpp \
+  Operations/Workers/EnrollInPoolOperation.hpp \
+  Operations/Workers/ObtainJobOperation.hpp \
+  Operations/Workers/RemoveFromPoolOperation.hpp \
+  Operations/Workers/SubmitResultOperation.hpp \
   WorkerChoices.hpp
 
-noinst_LTLIBRARIES += libMolecuilderFragmentationCommands.la
-libMolecuilderFragmentationCommands_la_includedir = $(includedir)/MoleCuilder/Fragmentation/Automation/
-nobase_libMolecuilderFragmentationCommands_la_include_HEADERS = $(FRAGMENTATIONCOMMANDSHEADER)
-libMolecuilderFragmentationCommands_la_CXXFLAGS = ${BOOST_CPPFLAGS} ${CodePatterns_CFLAGS} $(BOOST_ASIO_DEBUG)
-libMolecuilderFragmentationCommands_la_SOURCES = $(FRAGMENTATIONCOMMANDSSOURCE)
+noinst_LTLIBRARIES += libMolecuilderFragmentationOperations.la
+libMolecuilderFragmentationOperations_la_includedir = $(includedir)/MoleCuilder/Fragmentation/Automation/
+nobase_libMolecuilderFragmentationOperations_la_include_HEADERS = $(FRAGMENTATIONOPERATIONSHEADER)
+libMolecuilderFragmentationOperations_la_CXXFLAGS = ${BOOST_CPPFLAGS} ${CodePatterns_CFLAGS} $(BOOST_ASIO_DEBUG)
+libMolecuilderFragmentationOperations_la_SOURCES = $(FRAGMENTATIONOPERATIONSSOURCE)
 
 FRAGMENTATIONAUTOMATIONHELPERSOURCE = \
@@ -137,5 +137,5 @@
 Controller_LDADD = \
   libMolecuilderFragmentationAutomationHelper.la \
-  libMolecuilderFragmentationCommands.la \
+  libMolecuilderFragmentationOperations.la \
   libMolecuilderFragmentJobs.la \
   $(BOOST_ASIO_LIBS) \
@@ -150,5 +150,5 @@
 PoolWorker_LDADD = \
   libMolecuilderFragmentationAutomationHelper.la \
-  libMolecuilderFragmentationCommands.la \
+  libMolecuilderFragmentationOperations.la \
   libMolecuilderFragmentJobs.la \
   $(BOOST_ASIO_LIBS) \
@@ -163,5 +163,5 @@
 Server_LDADD = \
   libMolecuilderFragmentationAutomationHelper.la \
-  libMolecuilderFragmentationCommands.la \
+  libMolecuilderFragmentationOperations.la \
   libMolecuilderFragmentJobs.la \
   $(BOOST_ASIO_LIBS) \
Index: src/Fragmentation/Automation/Operations/AsyncOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Operations/AsyncOperation.cpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
+++ src/Fragmentation/Automation/Operations/AsyncOperation.cpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ */
+
+/*
+ * AsyncOperation.cpp
+ *
+ *  Created on: Nov 11, 2011
+ *      Author: heber
+ */
+
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+// boost asio needs specific operator new
+#include <boost/asio.hpp>
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "AsyncOperation.hpp"
+
+#include <boost/bind.hpp>
+#include <vector>
+#include "Connection.hpp" // Must come before boost/serialization headers.
+#include "CodePatterns/Info.hpp"
+#include "CodePatterns/Log.hpp"
+
+/** Callback function when an operation has been completed.
+ *
+ * \param e error code if something went wrong
+ */
+void AsyncOperation::handle_FinishOperation(const boost::system::error_code& e)
+{
+  Info info(__FUNCTION__);
+  if (!e)
+  {
+    LOG(1, "INFO: AsyncOperation completed.");
+  }
+  else
+  {
+    // An error occurred.
+    Exitflag = ErrorFlag;
+    ELOG(1, e.message());
+  }
+
+  // Since we are not starting a new operation the io_service will run out of
+  // work to do and the client will exit.
+  disconnect();
+}
+
+/** Internal function to disconnect connection_ correctly.
+ *
+ */
+void AsyncOperation::disconnect()
+{
+  connection_.socket().close();
+}
+
+void AsyncOperation::operator()(const std::string& _host, const std::string& _service)
+{
+  Info info(__FUNCTION__);
+  // Resolve the host name into an IP address.
+  boost::asio::ip::tcp::resolver resolver(connection_.socket().get_io_service());
+  boost::asio::ip::tcp::resolver::query query(_host, _service);
+  boost::asio::ip::tcp::resolver::iterator endpoint_iterator =
+    resolver.resolve(query);
+  boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
+
+  // Start an asynchronous connect operation.
+  std::cout << "Connecting to endpoint " << endpoint << " ..." << std::endl;
+  connection_.socket().async_connect(endpoint,
+    boost::bind(&AsyncOperation::handle_connect, this,
+      boost::asio::placeholders::error, ++endpoint_iterator));
+}
+
Index: src/Fragmentation/Automation/Operations/AsyncOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Operations/AsyncOperation.hpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
+++ src/Fragmentation/Automation/Operations/AsyncOperation.hpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -0,0 +1,56 @@
+/*
+ * AsyncOperation.hpp
+ *
+ *  Created on: Nov 11, 2011
+ *      Author: heber
+ */
+
+#ifndef FRAGMENTCONTROLLER_ASYNCOPERATION_HPP_
+#define FRAGMENTCONTROLLER_ASYNCOPERATION_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <boost/asio.hpp>
+#include <string>
+#include <vector>
+
+#include "Operation.hpp"
+
+class AsyncOperation : public Operation {
+public:
+  /** Constructor for class AsyncOperation.
+   *
+   * \param _name name for this AsyncOperation for retrieval from a registry
+   * \param _connection connection to operate on
+   */
+  AsyncOperation(const std::string &_name, Connection &_connection) :
+    Operation(_name, _connection)
+  {}
+
+  /** Destructor for class AsyncOperation.
+   *
+   */
+  virtual ~AsyncOperation()
+  {}
+
+public:
+  // virtual function pointer to the operation to do
+  void operator()(const std::string& _host, const std::string& _service);
+
+protected:
+  // virtual function pointer to the connection handler
+  virtual void handle_connect(const boost::system::error_code& e,
+      boost::asio::ip::tcp::resolver::iterator endpoint_iterator) = 0;
+
+  /// Handle completion of an operation.
+  void handle_FinishOperation(const boost::system::error_code& e);
+
+protected:
+  /// internal function to disconnect from server
+  void disconnect();
+};
+
+#endif /* FRAGMENTCONTROLLER_ASYNCOPERATION_HPP_ */
Index: src/Fragmentation/Automation/Operations/Controllers/CheckResultsOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Operations/Controllers/CheckResultsOperation.cpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
+++ src/Fragmentation/Automation/Operations/Controllers/CheckResultsOperation.cpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -0,0 +1,114 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2011-2012 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * CheckResultsOperation.cpp
+ *
+ *  Created on: Dec 11, 2011
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+// boost asio needs specific operator new
+#include <boost/asio.hpp>
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "CheckResultsOperation.hpp"
+
+#include <boost/bind.hpp>
+#include <iostream>
+#include "Connection.hpp" // Must come before boost/serialization headers.
+#include <boost/serialization/vector.hpp>
+#include "CodePatterns/Info.hpp"
+#include "CodePatterns/Log.hpp"
+#include "ControllerChoices.hpp"
+
+/** Handle connect operation to send number of done jobs.
+ *
+ * \param e error code if something went wrong
+ * \param endpoint_iterator endpoint of the connection
+ */
+void CheckResultsOperation::handle_connect(const boost::system::error_code& e,
+    boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
+{
+  Info info(__FUNCTION__);
+  if (!e)
+  {
+    // Successfully established connection. Give choice.
+    enum ControllerChoices choice = CheckState;
+    connection_.async_write(choice,
+      boost::bind(&CheckResultsOperation::handle_ReceiveJobInfo, this,
+      boost::asio::placeholders::error));
+  } else if (endpoint_iterator != boost::asio::ip::tcp::resolver::iterator()) {
+    // Try the next endpoint.
+    connection_.socket().close();
+    boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
+    connection_.socket().async_connect(endpoint,
+      boost::bind(&CheckResultsOperation::handle_connect, this,
+      boost::asio::placeholders::error, ++endpoint_iterator));
+  } else {
+    // An error occurred. Log it and return. Since we are not starting a new
+    // operation the io_service will run out of work to do and the client will
+    // exit.
+    Exitflag = ErrorFlag;
+    ELOG(1, e.message());
+  }
+}
+
+/** Callback function when doneJobs have been received.
+ *
+ * \param e error code if something went wrong
+ */
+void CheckResultsOperation::handle_ReceiveJobInfo(const boost::system::error_code& e)
+{
+  Info info(__FUNCTION__);
+  if (!e)
+  {
+    // The connection::async_read() function will automatically
+    // decode the data that is written to the underlying socket.
+    LOG(1, "INFO: Obtaining number of present and done jobs ...");
+    connection_.async_read(jobInfo,
+      boost::bind(&CheckResultsOperation::handle_FinishOperation, this,
+      boost::asio::placeholders::error));
+  }
+  else
+  {
+    // An error occurred.
+    Exitflag = ErrorFlag;
+    ELOG(1, e.message());
+  }
+}
+
+/** Getter for jobInfo.
+ *
+ * \sa checkResults()
+ * \param number of present jobs
+ */
+size_t CheckResultsOperation::getPresentJobs() const
+{
+  ASSERT( jobInfo.size() == (size_t)2,
+      "CheckResultsOperation::getPresentJobs() - jobInfo does not contain present and done jobs.");
+  return jobInfo[0];
+}
+
+/** Getter for jobInfo.
+ *
+ * \sa checkResults()
+ * \param number of done jobs
+ */
+size_t CheckResultsOperation::getDoneJobs() const
+{
+  ASSERT( jobInfo.size() == (size_t)2,
+      "CheckResultsOperation::getPresentJobs() - jobInfo does not contain present and done jobs.");
+  return jobInfo[1];
+}
+
Index: src/Fragmentation/Automation/Operations/Controllers/CheckResultsOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Operations/Controllers/CheckResultsOperation.hpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
+++ src/Fragmentation/Automation/Operations/Controllers/CheckResultsOperation.hpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -0,0 +1,56 @@
+/*
+ * CheckResultsOperation.hpp
+ *
+ *  Created on: Dec 11, 2011
+ *      Author: heber
+ */
+
+#ifndef FRAGMENTCONTROLLER_CHECKRESULTSOPERATION_HPP_
+#define FRAGMENTCONTROLLER_CHECKRESULTSOPERATION_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <boost/asio.hpp>
+#include <string>
+
+#include "Connection.hpp"
+
+#include "Operations/AsyncOperation.hpp"
+
+/** This Operations requests number of present jobs and present results (done
+ * jobs) from the server.
+ *
+ */
+class CheckResultsOperation : public AsyncOperation  {
+public:
+  /// Constructor for class CheckResultsOperation.
+  CheckResultsOperation(Connection &_connection) :
+    AsyncOperation(std::string("checkresults"), _connection),
+    jobInfo((size_t)2, 0)
+        {}
+  /// Destructor for class CheckResultsOperation
+  ~CheckResultsOperation() {}
+
+public:
+  // virtual function pointer to the connection handler
+  virtual void handle_connect(const boost::system::error_code& e,
+      boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
+
+  /// Callback function when doneJobs have been received.
+  void handle_ReceiveJobInfo(const boost::system::error_code& e);
+
+  /// Getter for presentJobs
+  size_t getPresentJobs() const;
+
+  /// Getter for doneJobs
+  size_t getDoneJobs() const;
+
+protected:
+  /// current jobs left to calculate and currently calculated results
+  std::vector<size_t> jobInfo;
+};
+
+#endif /* FRAGMENTCONTROLLER_CHECKRESULTSOPERATION_HPP_ */
Index: src/Fragmentation/Automation/Operations/Controllers/GetNextJobIdOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Operations/Controllers/GetNextJobIdOperation.cpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
+++ src/Fragmentation/Automation/Operations/Controllers/GetNextJobIdOperation.cpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -0,0 +1,118 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2012 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * GetNextJobIdOperation.cpp
+ *
+ *  Created on: Feb 16, 2012
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+// boost asio needs specific operator new
+#include <boost/asio.hpp>
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "GetNextJobIdOperation.hpp"
+
+#include <boost/bind.hpp>
+#include <iostream>
+#include "Connection.hpp" // Must come before boost/serialization headers.
+#include <boost/serialization/vector.hpp>
+#include "CodePatterns/Info.hpp"
+#include "CodePatterns/Log.hpp"
+#include "ControllerChoices.hpp"
+#include "types.hpp"
+
+/** Handle connect operation to send number of done jobs.
+ *
+ * \param e error code if something went wrong
+ * \param endpoint_iterator endpoint of the connection
+ */
+void GetNextJobIdOperation::handle_connect(const boost::system::error_code& e,
+    boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
+{
+  Info info(__FUNCTION__);
+  if (!e)
+  {
+    // Successfully established connection. Give choice.
+          enum ControllerChoices choice = GetNextJobId;
+    connection_.async_write(choice,
+      boost::bind(&GetNextJobIdOperation::handle_ReceiveNextId, this,
+      boost::asio::placeholders::error));
+  } else if (endpoint_iterator != boost::asio::ip::tcp::resolver::iterator()) {
+    // Try the next endpoint.
+    connection_.socket().close();
+    boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
+    connection_.socket().async_connect(endpoint,
+      boost::bind(&GetNextJobIdOperation::handle_connect, this,
+      boost::asio::placeholders::error, ++endpoint_iterator));
+  } else {
+    // An error occurred. Log it and return. Since we are not starting a new
+    // operation the io_service will run out of work to do and the client will
+    // exit.
+    ELOG(1, e.message());
+  }
+}
+
+/** Callback function when doneJobs have been received.
+ *
+ * \param e error code if something went wrong
+ */
+void GetNextJobIdOperation::handle_ReceiveNextId(const boost::system::error_code& e)
+{
+  Info info(__FUNCTION__);
+  if (!e)
+  {
+    // The connection::async_read() function will automatically
+    // decode the data that is written to the underlying socket.
+    LOG(1, "INFO: Obtaining next available job id ...");
+    connection_.async_read(nextid,
+      boost::bind(&GetNextJobIdOperation::handle_FinishOperation, this,
+      boost::asio::placeholders::error));
+  }
+  else
+  {
+    // An error occurred.
+    ELOG(1, e.message());
+  }
+}
+
+/** Callback function when an operation has been completed.
+ *
+ * \param e error code if something went wrong
+ */
+void GetNextJobIdOperation::handle_FinishOperation(const boost::system::error_code& e)
+{
+  Info info(__FUNCTION__);
+
+  // place id into nextids
+  nextids.push_back(nextid);
+  nextid = JobId::IllegalJob;
+
+  // and finish operation
+  AsyncOperation::handle_FinishOperation(e);
+}
+
+/** Getter for nextid.
+ *
+ * \sa checkResults()
+ * \param next available JobId_t
+ */
+size_t GetNextJobIdOperation::getNextId()
+{
+  ASSERT( nextids.size() != (size_t)0,
+      "GetNextJobIdOperation::getNextId() - no next id available.");
+  const JobId_t availableid = nextids.front();
+  nextids.pop_front();
+  return availableid;
+}
Index: src/Fragmentation/Automation/Operations/Controllers/GetNextJobIdOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Operations/Controllers/GetNextJobIdOperation.hpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
+++ src/Fragmentation/Automation/Operations/Controllers/GetNextJobIdOperation.hpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -0,0 +1,60 @@
+/*
+ * GetNextJobIdOperation.hpp
+ *
+ *  Created on: Feb 16, 2012
+ *      Author: heber
+ */
+
+#ifndef FRAGMENTCONTROLLER_GETNEXTJOBIDOPERATION_HPP_
+#define FRAGMENTCONTROLLER_GETNEXTJOBIDOPERATION_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <boost/asio.hpp>
+
+#include "Connection.hpp"
+
+#include "JobId.hpp"
+#include "Operations/AsyncOperation.hpp"
+#include "types.hpp"
+
+/** This Operations requests number of present jobs and present results (done
+ * jobs) from the server.
+ *
+ */
+class GetNextJobIdOperation : public AsyncOperation  {
+public:
+  /// Constructor for class GetNextJobIdOperation.
+  GetNextJobIdOperation(Connection &_connection) :
+    AsyncOperation(std::string("getnextjobid"), _connection),
+    nextid(JobId::IllegalJob)
+  {}
+  /// Destructor for class GetNextJobIdOperation
+  ~GetNextJobIdOperation() {}
+
+public:
+  // virtual function pointer to the connection handler
+  virtual void handle_connect(const boost::system::error_code& e,
+      boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
+
+  /// Callback function when doneJobs have been received.
+  void handle_ReceiveNextId(const boost::system::error_code& e);
+
+  /// Getter for nextid
+  size_t getNextId();
+
+protected:
+  /// Callback function when Operations finishes.
+  void handle_FinishOperation(const boost::system::error_code& e);
+
+  /// current jobs left to calculate and currently calculated results
+  std::list<JobId_t> nextids;
+
+  // temporary for receiving another job id
+  JobId_t nextid;
+};
+
+#endif /* FRAGMENTCONTROLLER_GETNEXTJOBIDOPERATION_HPP_ */
Index: src/Fragmentation/Automation/Operations/Controllers/ReceiveResultsOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Operations/Controllers/ReceiveResultsOperation.cpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
+++ src/Fragmentation/Automation/Operations/Controllers/ReceiveResultsOperation.cpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -0,0 +1,115 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2011-2012 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * ReceiveResultsOperation.cpp
+ *
+ *  Created on: Dec 11, 2011
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+// boost asio needs specific operator new
+#include <boost/asio.hpp>
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "ReceiveResultsOperation.hpp"
+
+#include <boost/bind.hpp>
+#include <iostream>
+#include <vector>
+#include "Connection.hpp" // Must come before boost/serialization headers.
+#include <boost/serialization/vector.hpp>
+#include "CodePatterns/Info.hpp"
+#include "CodePatterns/Log.hpp"
+#include "ControllerChoices.hpp"
+#include "Results/FragmentResult.hpp"
+
+/** Handle connect operation to send results.
+ *
+ * \param e error code if something went wrong
+ * \param endpoint_iterator endpoint of the connection
+ */
+void ReceiveResultsOperation::handle_connect(const boost::system::error_code& e,
+    boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
+{
+  Info info(__FUNCTION__);
+  if (!e)
+  {
+    // Successfully established connection. Give choice.
+    enum ControllerChoices choice = ReceiveResults;
+    connection_.async_write(choice,
+      boost::bind(&ReceiveResultsOperation::handle_ReceivingResults, this,
+      boost::asio::placeholders::error));
+  } else if (endpoint_iterator != boost::asio::ip::tcp::resolver::iterator()) {
+    // Try the next endpoint.
+    connection_.socket().close();
+    boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
+    connection_.socket().async_connect(endpoint,
+      boost::bind(&ReceiveResultsOperation::handle_connect, this,
+      boost::asio::placeholders::error, ++endpoint_iterator));
+  } else {
+    // An error occurred. Log it and return. Since we are not starting a new
+    // operation the io_service will run out of work to do and the client will
+    // exit.
+    Exitflag = ErrorFlag;
+    ELOG(1, e.message());
+  }
+}
+
+/** Callback function when preparing to receive results
+ *
+ * \param e error code if something went wrong
+ */
+void ReceiveResultsOperation::handle_ReceivingResults(const boost::system::error_code& e)
+{
+  Info info(__FUNCTION__);
+  if (!e)
+  {
+    // The connection::async_read() function will automatically
+    // decode the data that is written to the underlying socket.
+    LOG(1, "INFO: Sending "+toString(results.size())+" results ...");
+    connection_.async_read(results,
+      boost::bind(&ReceiveResultsOperation::handle_ReceivedResults, this,
+      boost::asio::placeholders::error));
+  }
+  else
+  {
+    // An error occurred.
+    Exitflag = ErrorFlag;
+    ELOG(1, e.message());
+  }
+}
+
+/** Callback function when results have been received.
+ *
+ * \param e error code if something went wrong
+ */
+void ReceiveResultsOperation::handle_ReceivedResults(const boost::system::error_code& e)
+{
+  Info info(__FUNCTION__);
+
+  LOG(1, "INFO: Received "+toString(results.size())+" results.");
+
+  ReceiveResultsOperation::handle_FinishOperation(e);
+}
+
+/** Getter for results.
+ *
+ * \sa calculateResults()
+ * \return vector of results for the added jobs (\sa addJobs()).
+ */
+std::vector<FragmentResult::ptr> ReceiveResultsOperation::getResults()
+{
+  Info info(__FUNCTION__);
+  return results;
+}
Index: src/Fragmentation/Automation/Operations/Controllers/ReceiveResultsOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Operations/Controllers/ReceiveResultsOperation.hpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
+++ src/Fragmentation/Automation/Operations/Controllers/ReceiveResultsOperation.hpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -0,0 +1,52 @@
+/*
+ * ReceiveResultsOperation.hpp
+ *
+ *  Created on: Dec 11, 2011
+ *      Author: heber
+ */
+
+#ifndef FRAGMENTCONTROLLER_RECEIVERESULTSOPERATION_HPP_
+#define FRAGMENTCONTROLLER_RECEIVERESULTSOPERATION_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <boost/asio.hpp>
+#include <string>
+#include <vector>
+
+#include "Connection.hpp"
+#include "Operations/AsyncOperation.hpp"
+#include "Results/FragmentResult.hpp"
+
+
+class ReceiveResultsOperation : public AsyncOperation  {
+public:
+  /// Constructor for class ReceiveResultsOperation.
+  ReceiveResultsOperation(Connection &_connection) :
+    AsyncOperation(std::string("receiveresults"), _connection) {}
+  /// Destructor for class ReceiveResultsOperation
+  ~ReceiveResultsOperation() {}
+
+public:
+  // virtual function pointer to the connection handler
+  virtual void handle_connect(const boost::system::error_code& e,
+      boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
+
+  /// Callback function when results are about to be received.
+  void handle_ReceivingResults(const boost::system::error_code& e);
+
+  /// Callback function when results have been received.
+  void handle_ReceivedResults(const boost::system::error_code& e);
+
+  /// Getter for results
+  std::vector<FragmentResult::ptr> getResults();
+
+protected:
+  /// bunch of results
+  std::vector<FragmentResult::ptr> results;
+};
+
+#endif /* FRAGMENTCONTROLLER_RECEIVERESULTSOPERATION_HPP_ */
Index: src/Fragmentation/Automation/Operations/Controllers/SendJobsOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Operations/Controllers/SendJobsOperation.cpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
+++ src/Fragmentation/Automation/Operations/Controllers/SendJobsOperation.cpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -0,0 +1,124 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2011-2012 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * SendJobsOperation.cpp
+ *
+ *  Created on: Dec 11, 2011
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+// boost asio needs specific operator new
+#include <boost/asio.hpp>
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "SendJobsOperation.hpp"
+
+#include <boost/bind.hpp>
+#include <boost/foreach.hpp>
+#include <iostream>
+#include <vector>
+#include "Connection.hpp" // Must come before boost/serialization headers.
+#include <boost/serialization/vector.hpp>
+#include "CodePatterns/Info.hpp"
+#include "CodePatterns/Log.hpp"
+#include "ControllerChoices.hpp"
+#include "Jobs/FragmentJob.hpp"
+
+/** Handle connect operation to receive jobs from controller
+ *
+ * \param e error code if something went wrong
+ * \param endpoint_iterator endpoint of the connection
+ */
+void SendJobsOperation::handle_connect(const boost::system::error_code& e,
+    boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
+{
+  Info info(__FUNCTION__);
+  if (!e)
+  {
+    // Successfully established connection. Give choice.
+    enum ControllerChoices choice = SendJobs;
+    connection_.async_write(choice,
+      boost::bind(&SendJobsOperation::handle_SendJobs, this,
+      boost::asio::placeholders::error));
+  } else if (endpoint_iterator != boost::asio::ip::tcp::resolver::iterator()) {
+    // Try the next endpoint.
+    connection_.socket().close();
+    boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
+    connection_.socket().async_connect(endpoint,
+      boost::bind(&SendJobsOperation::handle_connect, this,
+      boost::asio::placeholders::error, ++endpoint_iterator));
+  } else {
+    // An error occurred. Log it and return. Since we are not starting a new
+    // operation the io_service will run out of work to do and the client will
+    // exit.
+    Exitflag = ErrorFlag;
+    ELOG(1, e.message());
+  }
+}
+
+/** Callback function when jobs have been sent.
+ *
+ * \param e error code if something went wrong
+ */
+void SendJobsOperation::handle_SendJobs(const boost::system::error_code& e)
+{
+  Info info(__FUNCTION__);
+  if (!e)
+  {
+    // Successfully established connection. Start operation to read the vector
+    // of jobs. The connection::async_write() function will automatically
+    // encode the data that is written to the underlying socket.
+    LOG(1, "INFO: Sending "+toString(jobs.size())+" jobs ...");
+    connection_.async_write(jobs,
+      boost::bind(&SendJobsOperation::handle_FinishOperation, this,
+      boost::asio::placeholders::error));
+  }
+  else
+  {
+    // An error occurred.
+    Exitflag = ErrorFlag;
+    ELOG(1, e.message());
+  }
+
+  // Since we are not starting a new operation the io_service will run out of
+  // work to do and the client will exit.
+}
+
+/** Callback function when an operation has been completed.
+ *
+ * \param e error code if something went wrong
+ */
+void SendJobsOperation::handle_FinishOperation(const boost::system::error_code& e)
+{
+  Info info(__FUNCTION__);
+
+  LOG(1, "INFO: Jobs have been sent. Clearing.");
+  jobs.clear();
+
+  AsyncOperation::handle_FinishOperation(e);
+}
+
+/** Place number of jobs into this controller.
+ *
+ * \param _jobs jobs to add
+ */
+void SendJobsOperation::addJobs(const std::vector<FragmentJob::ptr> &_jobs)
+{
+  jobs.reserve(jobs.size()+_jobs.size());
+  BOOST_FOREACH(FragmentJob::ptr job, _jobs) {
+    jobs.push_back(job);
+  }
+  LOG(1, "INFO: SendJobsOperation now contains " << jobs.size() << " job(s).");
+}
+
Index: src/Fragmentation/Automation/Operations/Controllers/SendJobsOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Operations/Controllers/SendJobsOperation.hpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
+++ src/Fragmentation/Automation/Operations/Controllers/SendJobsOperation.hpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -0,0 +1,60 @@
+/*
+ * SendJobsOperation.hpp
+ *
+ *  Created on: Dec 11, 2011
+ *      Author: heber
+ */
+
+#ifndef FRAGMENTCONTROLLER_SENDJOBSOPERATION_HPP_
+#define FRAGMENTCONTROLLER_SENDJOBSOPERATION_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <boost/asio.hpp>
+#include <string>
+#include <vector>
+
+#include "Connection.hpp"
+#include "Jobs/FragmentJob.hpp"
+
+#include "Operations/AsyncOperation.hpp"
+
+class SendJobsOperation : public AsyncOperation {
+public:
+  /// Constructor for class SendJobsOperation.
+  SendJobsOperation(Connection &_connection) :
+    AsyncOperation(std::string("sendjobs"), _connection) {}
+  /// Destructor for class SendJobsOperation
+  ~SendJobsOperation() {}
+
+public:
+  // virtual function pointer to the connection handler
+  virtual void handle_connect(const boost::system::error_code& e,
+      boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
+
+  /// Callback function when bunch of jobs have been sent.
+  void handle_SendJobs(const boost::system::error_code& e);
+
+  /// Setter for jobs
+  void addJobs(const std::vector<FragmentJob::ptr> &jobs);
+
+  /** Getter for number of jobs present in the queue.
+   *
+   * \return jobs.size()
+   */
+  size_t getPresentJobs() const
+  {
+    return jobs.size();
+  }
+
+protected:
+  void handle_FinishOperation(const boost::system::error_code& e);
+
+  /// bunch of jobs
+  std::vector<FragmentJob::ptr> jobs;
+};
+
+#endif /* FRAGMENTCONTROLLER_SENDJOBSOPERATION_HPP_ */
Index: src/Fragmentation/Automation/Operations/Controllers/ShutdownOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Operations/Controllers/ShutdownOperation.cpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
+++ src/Fragmentation/Automation/Operations/Controllers/ShutdownOperation.cpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -0,0 +1,42 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2012 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * ShutdownOperation.cpp
+ *
+ *  Created on: Feb 28, 2012
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+// boost asio needs specific operator new
+#include <boost/asio.hpp>
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "ShutdownOperation.hpp"
+
+#include <boost/bind.hpp>
+#include <iostream>
+#include "Connection.hpp" // Must come before boost/serialization headers.
+#include "CodePatterns/Info.hpp"
+#include "ControllerChoices.hpp"
+
+/** Virtual internal function to give shutdown choice.
+ *
+ */
+void ShutdownOperation::internal()
+{
+  Info info(__FUNCTION__);
+  enum ControllerChoices choice = ShutdownControllerSocket;
+  connection_.sync_write(choice);
+}
+
Index: src/Fragmentation/Automation/Operations/Controllers/ShutdownOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Operations/Controllers/ShutdownOperation.hpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
+++ src/Fragmentation/Automation/Operations/Controllers/ShutdownOperation.hpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -0,0 +1,39 @@
+/*
+ * ShutdownOperation.hpp
+ *
+ *  Created on: Dec 11, 2011
+ *      Author: heber
+ */
+
+#ifndef FRAGMENTCONTROLLER_SHUTDOWNOPERATION_HPP_
+#define FRAGMENTCONTROLLER_SHUTDOWNOPERATION_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <boost/asio.hpp>
+#include <string>
+#include <vector>
+
+#include "Connection.hpp"
+#include "Operations/SyncOperation.hpp"
+
+/** Synchronous operation that gives shutdown command.
+ *
+ */
+class ShutdownOperation : public SyncOperation  {
+public:
+  /// Constructor for class ShutdownOperation.
+  ShutdownOperation(Connection &_connection) :
+    SyncOperation(std::string("shutdown"),_connection) {}
+  /// Destructor for class ShutdownOperation
+  ~ShutdownOperation() {}
+
+public:
+  // function that implements read&writes in between connect/disconnect
+  virtual void internal();
+};
+
+#endif /* FRAGMENTCONTROLLER_SHUTDOWNOPERATION_HPP_ */
Index: src/Fragmentation/Automation/Operations/Operation.hpp
===================================================================
--- src/Fragmentation/Automation/Operations/Operation.hpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
+++ src/Fragmentation/Automation/Operations/Operation.hpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -0,0 +1,85 @@
+/*
+ * Operation.hpp
+ *
+ *  Created on: Mar 04, 2012
+ *      Author: heber
+ */
+
+#ifndef FRAGMENTCONTROLLER_OPERATION_HPP_
+#define FRAGMENTCONTROLLER_OPERATION_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string>
+
+#include "Connection.hpp"
+
+
+/** Class Operation defines the general interface common all Operations
+ * whether synchronous or asynchronous. This allows for their storage in
+ * a registry.
+ *
+ */
+class Operation
+{
+public:
+  /** Constructor for class Operation.
+   *
+   * @param _connection connection to use for connect and disconnect
+   * @param _name internal name to allow storage in a registry
+   */
+  Operation(const std::string &_name, Connection &_connection) :
+    connection_(_connection),
+    Exitflag(OkFlag),
+    name(_name)
+  {}
+  virtual ~Operation()
+  {}
+
+  /** Central virtual function that each class deriving from Operation has to implement.
+   *
+   * Here, connect, some read/writes, and disconnect should occur.
+   *
+   * @param _host host address to connect to
+   * @param _service service to connect to
+   */
+  virtual void operator()(const std::string& _host, const std::string& _service) = 0;
+
+  enum Exitflag_t {
+    OkFlag = 0,
+    ErrorFlag = 255
+  };
+
+  /** Getter for Exitflag.
+   *
+   * @return Exitflag
+   */
+  size_t getExitflag() const
+  {
+    return Exitflag;
+  }
+
+  /** Getter for name.
+   *
+   * @return const reference to Operation::name.
+   */
+  const std::string &getName() const {
+    return name;
+  }
+
+protected:
+  /// The Connection to the server.
+  Connection &connection_;
+
+  // exit flag of this operation, derived classes may change it
+  enum Exitflag_t Exitflag;
+
+private:
+  /// Name of this AsyncOperation (required for Registry pattern)
+  std::string name;
+};
+
+#endif /* FRAGMENTCONTROLLER_OPERATION_HPP_ */
Index: src/Fragmentation/Automation/Operations/Servers/SendJobToWorkerOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Operations/Servers/SendJobToWorkerOperation.cpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
+++ src/Fragmentation/Automation/Operations/Servers/SendJobToWorkerOperation.cpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -0,0 +1,64 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2012 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * SendJobToWorkerOperation.cpp
+ *
+ *  Created on: Feb 22, 2012
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+// boost asio needs specific operator new
+#include <boost/asio.hpp>
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "SendJobToWorkerOperation.hpp"
+
+#include <boost/bind.hpp>
+#include <iostream>
+#include "Connection.hpp" // Must come before boost/serialization headers.
+#include "CodePatterns/Info.hpp"
+#include "CodePatterns/Log.hpp"
+
+/** Handle connect operation to shutdown scheduler.
+ *
+ * \param e error code if something went wrong
+ * \param endpoint_iterator endpoint of the connection
+ */
+void SendJobToWorkerOperation::handle_connect(const boost::system::error_code& e,
+    boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
+{
+  Info info(__FUNCTION__);
+  if (!e)
+  {
+    // The connection::async_write() function will automatically
+    // serialize the data structure for us.
+    LOG(1, "INFO: Sending job #" << job->getId() << ".");
+    connection_.async_write(job,
+      boost::bind(&SendJobToWorkerOperation::handle_FinishOperation, this,
+      boost::asio::placeholders::error));
+  } else if (endpoint_iterator != boost::asio::ip::tcp::resolver::iterator()) {
+    // Try the next endpoint.
+    connection_.socket().close();
+    boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
+    connection_.socket().async_connect(endpoint,
+      boost::bind(&SendJobToWorkerOperation::handle_connect, this,
+      boost::asio::placeholders::error, ++endpoint_iterator));
+  } else {
+    // An error occurred. Log it and return. Since we are not starting a new
+    // operation the io_service will run out of work to do and the client will
+    // exit.
+    Exitflag = ErrorFlag;
+    ELOG(1, e.message());
+  }
+}
Index: src/Fragmentation/Automation/Operations/Servers/SendJobToWorkerOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Operations/Servers/SendJobToWorkerOperation.hpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
+++ src/Fragmentation/Automation/Operations/Servers/SendJobToWorkerOperation.hpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -0,0 +1,57 @@
+/*
+ * SendJobToWorkerOperation.hpp
+ *
+ *  Created on: Feb 22, 2012
+ *      Author: heber
+ */
+
+#ifndef FRAGMENTCONTROLLER_SENDJOBTOWORKEROPERATION_HPP_
+#define FRAGMENTCONTROLLER_SENDJOBTOWORKEROPERATION_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <boost/asio.hpp>
+#include <string>
+#include <vector>
+
+#include "Connection.hpp"
+
+#include "Jobs/FragmentJob.hpp"
+#include "Jobs/SystemCommandJob.hpp"
+#include "Operations/AsyncOperation.hpp"
+#include "WorkerAddress.hpp"
+
+class SendJobToWorkerOperation : public AsyncOperation  {
+public:
+  /// Constructor for class SendJobToWorkerOperation.
+  SendJobToWorkerOperation(Connection &_connection) :
+    AsyncOperation(std::string("sendjobtoworker"),_connection),
+    job( new SystemCommandJob(std::string("/bin/true"), std::string("donothing"), JobId::NoJob) )
+  {}
+  /// Destructor for class SendJobToWorkerOperation
+  ~SendJobToWorkerOperation() {}
+
+  /** Setter for job.
+   *
+   * @param _job job to take over internally
+   */
+  void setJob(FragmentJob::ptr &_job)
+  {
+    job.reset();
+    job = _job;
+  }
+
+public:
+  // virtual function pointer to the connection handler
+  virtual void handle_connect(const boost::system::error_code& e,
+      boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
+
+private:
+  //!> job to send to
+  FragmentJob::ptr job;
+};
+
+#endif /* FRAGMENTCONTROLLER_SENDJOBTOWORKEROPERATION_HPP_ */
Index: src/Fragmentation/Automation/Operations/Servers/ShutdownWorkerOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Operations/Servers/ShutdownWorkerOperation.cpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
+++ src/Fragmentation/Automation/Operations/Servers/ShutdownWorkerOperation.cpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+/*
+ * ShutdownWorkerOperation.cpp
+ *
+ *  Created on: 11.12.2011
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+// boost asio needs specific operator new
+#include <boost/asio.hpp>
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "ShutdownWorkerOperation.hpp"
+
+#include <boost/bind.hpp>
+#include <iostream>
+#include "Connection.hpp" // Must come before boost/serialization headers.
+#include "CodePatterns/Info.hpp"
+#include "ControllerChoices.hpp"
+#include "Jobs/SystemCommandJob.hpp"
+#include "JobId.hpp"
+
+FragmentJob::ptr ShutdownWorkerOperation::NoJob(new SystemCommandJob(std::string(""), std::string(""), JobId::NoJob));
+
+/** Virtual internal function to give shutdown choice.
+ *
+ */
+void ShutdownWorkerOperation::internal()
+{
+  Info info(__FUNCTION__);
+
+  // send the NoJob
+  connection_.sync_write(NoJob);
+}
Index: src/Fragmentation/Automation/Operations/Servers/ShutdownWorkerOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Operations/Servers/ShutdownWorkerOperation.hpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
+++ src/Fragmentation/Automation/Operations/Servers/ShutdownWorkerOperation.hpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -0,0 +1,45 @@
+/*
+ * ShutdownWorkerOperation.hpp
+ *
+ *  Created on: Mar 04, 2012
+ *      Author: heber
+ */
+
+#ifndef FRAGMENTCONTROLLER_SHUTDOWNWORKEROPERATION_HPP_
+#define FRAGMENTCONTROLLER_SHUTDOWNWORKEROPERATION_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <boost/asio.hpp>
+#include <string>
+#include <vector>
+
+#include "Connection.hpp"
+
+#include "Jobs/FragmentJob.hpp"
+#include "Operations/SyncOperation.hpp"
+
+/** Synchronous operation that gives shutdown command.
+ *
+ */
+class ShutdownWorkerOperation : public SyncOperation  {
+public:
+  /// Constructor for class ShutdownWorkerOperation.
+  ShutdownWorkerOperation(Connection &_connection) :
+    SyncOperation(std::string("shutdown"),_connection) {}
+  /// Destructor for class ShutdownWorkerOperation
+  ~ShutdownWorkerOperation() {}
+
+public:
+  // function that implements read&writes in between connect/disconnect
+  virtual void internal();
+
+private:
+  //!> static entity to indicate to clients that the queue is empty.
+  static FragmentJob::ptr NoJob;
+};
+
+#endif /* FRAGMENTCONTROLLER_SHUTDOWNWORKEROPERATION_HPP_ */
Index: src/Fragmentation/Automation/Operations/SyncOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Operations/SyncOperation.cpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
+++ src/Fragmentation/Automation/Operations/SyncOperation.cpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ */
+
+/*
+ * SyncOperation.cpp
+ *
+ *  Created on: Mar 04, 2012
+ *      Author: heber
+ */
+
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+// boost asio needs specific operator new
+#include <boost/asio.hpp>
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "SyncOperation.hpp"
+
+#include <boost/bind.hpp>
+#include <vector>
+#include "Connection.hpp" // Must come before boost/serialization headers.
+#include "CodePatterns/Info.hpp"
+#include "CodePatterns/Log.hpp"
+
+/** Internal function to connect connection_.
+ *
+ */
+void SyncOperation::connect(const std::string& _host, const std::string& _service)
+{
+  // Resolve the host name into an IP address.
+  boost::asio::ip::tcp::resolver resolver(connection_.socket().get_io_service());
+  boost::asio::ip::tcp::resolver::query query(_host, _service);
+  boost::asio::ip::tcp::resolver::iterator endpoint_iterator =
+    resolver.resolve(query);
+  boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
+
+  // Start an asynchronous connect operation.
+  std::cout << "Connecting to endpoint " << endpoint << " ..." << std::endl;
+  connection_.socket().connect(endpoint);
+}
+
+
+/** Internal function to disconnect connection_ correctly.
+ *
+ */
+void SyncOperation::disconnect()
+{
+  connection_.socket().close();
+}
+
+/** Wrapper function for the virtual call to internal() that connects and disconnects.
+ *
+ * @param _host host address to connect to
+ * @param _service service to connect to
+ */
+void SyncOperation::operator()(const std::string& _host, const std::string& _service)
+{
+  LOG(1, "INFO: Commencing operation ...");
+
+  // connect
+  connect(_host, _service);
+
+  // call virtual function to continue
+  internal();
+
+  // disconnect
+  disconnect();
+
+  LOG(1, "INFO: Operation completed.");
+}
Index: src/Fragmentation/Automation/Operations/SyncOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Operations/SyncOperation.hpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
+++ src/Fragmentation/Automation/Operations/SyncOperation.hpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -0,0 +1,54 @@
+/*
+ * SyncOperation.hpp
+ *
+ *  Created on: Mar 04, 2012
+ *      Author: heber
+ */
+
+#ifndef FRAGMENTCONTROLLER_SYNCOPERATION_HPP_
+#define FRAGMENTCONTROLLER_SYNCOPERATION_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <boost/asio.hpp>
+#include <string>
+#include <vector>
+
+#include "Operation.hpp"
+
+class SyncOperation : public Operation {
+public:
+  /** Constructor for class SyncOperation.
+   *
+   * \param _name name for this Operation for retrieval from a registry
+   * \param _connection connection to operate on
+   */
+  SyncOperation(const std::string &_name, Connection &_connection) :
+    Operation(_name, _connection)
+  {}
+
+  /** Destructor for class SyncOperation.
+   *
+   */
+  virtual ~SyncOperation()
+  {}
+
+public:
+  // virtual function pointer to the operation to do
+  void operator()(const std::string& _host, const std::string& _service);
+
+protected:
+  // function that implements read&writes in between connect/disconnect
+  virtual void internal() = 0;
+
+  // internal function to connect to server
+  void connect(const std::string& _host, const std::string& _service);
+
+  /// internal function to disconnect from server
+  void disconnect();
+};
+
+#endif /* FRAGMENTCONTROLLER_SYNCOPERATION_HPP_ */
Index: src/Fragmentation/Automation/Operations/Workers/EnrollInPoolOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Operations/Workers/EnrollInPoolOperation.cpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
+++ src/Fragmentation/Automation/Operations/Workers/EnrollInPoolOperation.cpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -0,0 +1,117 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2012 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * EnrollInPoolOperation.cpp
+ *
+ *  Created on: Feb 26, 2012
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+// boost asio needs specific operator new
+#include <boost/asio.hpp>
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "EnrollInPoolOperation.hpp"
+
+#include <boost/bind.hpp>
+#include "CodePatterns/Info.hpp"
+#include "CodePatterns/Log.hpp"
+#include "Jobs/FragmentJob.hpp"
+#include "WorkerAddress.hpp"
+#include "WorkerChoices.hpp"
+
+/// Handle completion of a connect operation.
+void EnrollInPoolOperation::handle_connect(const boost::system::error_code& e,
+    boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
+{
+  Info info(__FUNCTION__);
+  if (!e)
+  {
+    // Successfully established connection. Start operation to read the list
+    // of jobs. The connection::async_read() function will automatically
+    // decode the data that is read from the underlying socket.
+    connection_.async_write(address,
+      boost::bind(&EnrollInPoolOperation::handle_SendChoice, this,
+      boost::asio::placeholders::error));
+  } else if (endpoint_iterator != boost::asio::ip::tcp::resolver::iterator()) {
+    // Try the next endpoint.
+    connection_.socket().close();
+    boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
+    connection_.socket().async_connect(endpoint,
+      boost::bind(&EnrollInPoolOperation::handle_connect, this,
+      boost::asio::placeholders::error, ++endpoint_iterator));
+  } else {
+    // An error occurred. Log it and return. Since we are not starting a new
+    // operation the io_service will run out of work to do and the client will
+    // exit.
+    ELOG(1, e.message());
+  }
+}
+
+
+/// Handle sending choice
+void EnrollInPoolOperation::handle_SendChoice(const boost::system::error_code& e)
+{
+  Info info(__FUNCTION__);
+  if (!e)
+  {
+    // Successfully established connection. Start operation to read the list
+    // of jobs. The connection::async_read() function will automatically
+    // decode the data that is read from the underlying socket.
+    LOG(1, "INFO: Enrolling in pool with " << address << " ...");
+    enum WorkerChoices choice = EnrollInPool;
+    connection_.async_write(choice,
+      boost::bind(&EnrollInPoolOperation::handle_ReceiveFlag, this,
+      boost::asio::placeholders::error));
+  } else {
+    // An error occurred. Log it and return. Since we are not starting a new
+    // operation the io_service will run out of work to do and the client will
+    // exit.
+    ELOG(1, e.message());
+  }
+}
+
+
+/// Handle receiving flag
+void EnrollInPoolOperation::handle_ReceiveFlag(const boost::system::error_code& e)
+{
+  Info info(__FUNCTION__);
+  if (!e)
+  {
+    // Successfully established connection. Start operation to read the list
+    // of jobs. The connection::async_read() function will automatically
+    // decode the data that is read from the underlying socket.
+    connection_.async_read(flag,
+      boost::bind(&EnrollInPoolOperation::handle_FinishOperation, this,
+      boost::asio::placeholders::error));
+  } else {
+    // An error occurred. Log it and return. Since we are not starting a new
+    // operation the io_service will run out of work to do and the client will
+    // exit.
+    ELOG(1, e.message());
+  }
+}
+
+/// Handle received flag
+void EnrollInPoolOperation::handle_FinishOperation(const boost::system::error_code& e)
+{
+  Info info(__FUNCTION__);
+
+  if (flag == Success)
+    LOG(2, "DEBUG: Enrollment successful.");
+  else
+    LOG(2, "DEBUG: Enrollment failed.");
+
+  AsyncOperation::handle_FinishOperation(e);
+}
Index: src/Fragmentation/Automation/Operations/Workers/EnrollInPoolOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Operations/Workers/EnrollInPoolOperation.hpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
+++ src/Fragmentation/Automation/Operations/Workers/EnrollInPoolOperation.hpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -0,0 +1,67 @@
+/*
+ * EnrollInPoolOperation.hpp
+ *
+ *  Created on: Feb 26, 2012
+ *      Author: heber
+ */
+
+#ifndef ENROLLINPOOLOPERATION_HPP_
+#define ENROLLINPOOLOPERATION_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include <boost/asio.hpp>
+#include <string>
+#include <vector>
+
+#include "Connection.hpp"
+
+#include "Jobs/FragmentJob.hpp"
+#include "Operations/AsyncOperation.hpp"
+#include "Results/FragmentResult.hpp"
+#include "WorkerAddress.hpp"
+
+class EnrollInPoolOperation : public AsyncOperation  {
+public:
+  /// Constructor for class EnrollInPoolOperation.
+  EnrollInPoolOperation(Connection &_connection, const WorkerAddress &_address) :
+    AsyncOperation(std::string("enrollinpool"),_connection),
+    address(_address),
+    flag(Success)
+  {}
+  /// Destructor for class EnrollInPoolOperation
+  ~EnrollInPoolOperation() {}
+
+  enum EnrollFlag {
+    Success,
+    Fail
+  };
+
+protected:
+  // virtual function pointer to the connection handler
+  void handle_connect(const boost::system::error_code& e,
+      boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
+
+  /// Handle sending choice
+  void handle_SendChoice(const boost::system::error_code& e);
+
+  /// Handle receiving flag
+  void handle_ReceiveFlag(const boost::system::error_code& e);
+
+  /// Handle received flag
+  void handle_FinishOperation(const boost::system::error_code& e);
+
+private:
+  //!> address to enroll with
+  WorkerAddress address;
+
+  //!> flag returned by worker pool after enroll request
+  enum EnrollFlag flag;
+};
+
+
+#endif /* ENROLLINPOOLOPERATION_HPP_ */
Index: src/Fragmentation/Automation/Operations/Workers/ObtainJobOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Operations/Workers/ObtainJobOperation.cpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
+++ src/Fragmentation/Automation/Operations/Workers/ObtainJobOperation.cpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -0,0 +1,70 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2012 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * ObtainJobOperation.cpp
+ *
+ *  Created on: Feb 26, 2012
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+// boost asio needs specific operator new
+#include <boost/asio.hpp>
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "ObtainJobOperation.hpp"
+
+#include <boost/bind.hpp>
+#include "CodePatterns/Info.hpp"
+#include "CodePatterns/Log.hpp"
+#include "Jobs/FragmentJob.hpp"
+#include "WorkerChoices.hpp"
+
+/// Handle completion of a connect operation.
+void ObtainJobOperation::handle_connect(const boost::system::error_code& e,
+    boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
+{
+  Info info(__FUNCTION__);
+  if (!e)
+  {
+    // Successfully established connection. Start operation to read the list
+    // of jobs. The connection::async_read() function will automatically
+    // decode the data that is read from the underlying socket.
+    LOG(1, "INFO: Receiving a job ...");
+    connection_.async_read(job,
+      boost::bind(&ObtainJobOperation::handle_ReceiveJob, this,
+      boost::asio::placeholders::error));
+  } else if (endpoint_iterator != boost::asio::ip::tcp::resolver::iterator()) {
+    // Try the next endpoint.
+    connection_.socket().close();
+    boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
+    connection_.socket().async_connect(endpoint,
+      boost::bind(&ObtainJobOperation::handle_connect, this,
+      boost::asio::placeholders::error, ++endpoint_iterator));
+  } else {
+    // An error occurred. Log it and return. Since we are not starting a new
+    // operation the io_service will run out of work to do and the client will
+    // exit.
+    ELOG(1, e.message());
+  }
+}
+
+/// Callback function when job has been received.
+void ObtainJobOperation::handle_ReceiveJob(const boost::system::error_code& e)
+{
+  Info info(__FUNCTION__);
+
+  LOG(1, "INFO: Received job #" << job->getId() << ".");
+
+  AsyncOperation::handle_FinishOperation(e);
+}
Index: src/Fragmentation/Automation/Operations/Workers/ObtainJobOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Operations/Workers/ObtainJobOperation.hpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
+++ src/Fragmentation/Automation/Operations/Workers/ObtainJobOperation.hpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -0,0 +1,58 @@
+/*
+ * ObtainJobOperation.hpp
+ *
+ *  Created on: Feb 26, 2012
+ *      Author: heber
+ */
+
+#ifndef OBTAINJOBOPERATION_HPP_
+#define OBTAINJOBOPERATION_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include <boost/asio.hpp>
+#include <string>
+#include <vector>
+
+#include "Connection.hpp"
+
+#include "Jobs/FragmentJob.hpp"
+#include "Operations/AsyncOperation.hpp"
+#include "Results/FragmentResult.hpp"
+
+class ObtainJobOperation : public AsyncOperation  {
+public:
+  /// Constructor for class ObtainJobOperation.
+  ObtainJobOperation(Connection &_connection) :
+    AsyncOperation(std::string("obtainjob"),_connection) {}
+  /// Destructor for class ObtainJobOperation
+  ~ObtainJobOperation() {}
+
+  /** Getter for the obtained job.
+   *
+   * @return obtained FragmentJob
+   */
+  FragmentJob::ptr getJob()
+  {
+    return job;
+  }
+
+protected:
+  // virtual function pointer to the connection handler
+  void handle_connect(const boost::system::error_code& e,
+      boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
+
+  /// Callback function when job has been received.
+  void handle_ReceiveJob(const boost::system::error_code& e);
+
+private:
+  /// The data received from the server.
+  FragmentJob::ptr job;
+};
+
+
+#endif /* OBTAINJOBOPERATION_HPP_ */
Index: src/Fragmentation/Automation/Operations/Workers/RemoveFromPoolOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Operations/Workers/RemoveFromPoolOperation.cpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
+++ src/Fragmentation/Automation/Operations/Workers/RemoveFromPoolOperation.cpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+/*
+ * RemoveFromPoolOperation.cpp
+ *
+ *  Created on: Mar 01, 2012
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+// boost asio needs specific operator new
+#include <boost/asio.hpp>
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "RemoveFromPoolOperation.hpp"
+
+#include <boost/bind.hpp>
+#include <iostream>
+#include "Connection.hpp" // Must come before boost/serialization headers.
+#include "CodePatterns/Info.hpp"
+#include "CodePatterns/Log.hpp"
+#include "WorkerChoices.hpp"
+
+
+/** Internal operation after connect to give address and send remove signal
+ *
+ */
+void RemoveFromPoolOperation::internal()
+{
+  Info info(__FUNCTION__);
+
+  LOG(1, "INFO: Removing " << address << " from server's pool ...");
+  connection_.sync_write(address);
+  enum WorkerChoices choice = RemoveFromPool;
+  connection_.sync_write(choice);
+}
Index: src/Fragmentation/Automation/Operations/Workers/RemoveFromPoolOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Operations/Workers/RemoveFromPoolOperation.hpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
+++ src/Fragmentation/Automation/Operations/Workers/RemoveFromPoolOperation.hpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -0,0 +1,44 @@
+/*
+ * RemoveFromPoolOperation.hpp
+ *
+ *  Created on: Mar 01, 2012
+ *      Author: heber
+ */
+
+#ifndef FRAGMENTCONTROLLER_REMOVEFROMPOOLOPERATION_HPP_
+#define FRAGMENTCONTROLLER_REMOVEFROMPOOLOPERATION_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <boost/asio.hpp>
+#include <string>
+#include <vector>
+
+#include "Connection.hpp"
+
+#include "Operations/SyncOperation.hpp"
+#include "WorkerAddress.hpp"
+
+class RemoveFromPoolOperation : public SyncOperation  {
+public:
+  /// Constructor for class RemoveFromPoolOperation.
+  RemoveFromPoolOperation(Connection &_connection, const WorkerAddress &_address) :
+    SyncOperation(std::string("shutdownworker"),_connection),
+    address(_address)
+  {}
+  /// Destructor for class RemoveFromPoolOperation
+  ~RemoveFromPoolOperation() {}
+
+public:
+  // function that implements read&writes in between connect/disconnect
+  virtual void internal();
+
+private:
+  //!> address to enroll with
+  WorkerAddress address;
+};
+
+#endif /* FRAGMENTCONTROLLER_REMOVEFROMPOOLOPERATION_HPP_ */
Index: src/Fragmentation/Automation/Operations/Workers/SubmitResultOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Operations/Workers/SubmitResultOperation.cpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
+++ src/Fragmentation/Automation/Operations/Workers/SubmitResultOperation.cpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -0,0 +1,114 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2012 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * SubmitResultOperation.cpp
+ *
+ *  Created on: Feb 26, 2012
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+// boost asio needs specific operator new
+#include <boost/asio.hpp>
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "SubmitResultOperation.hpp"
+
+#include <boost/bind.hpp>
+#include "CodePatterns/Info.hpp"
+#include "CodePatterns/Log.hpp"
+#include "Results/FragmentResult.hpp"
+#include "WorkerChoices.hpp"
+
+
+/// Handle completion of a connect operation.
+void SubmitResultOperation::handle_connect(const boost::system::error_code& e,
+    boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
+{
+  Info info(__FUNCTION__);
+  if (!e)
+  {
+    // Successfully established connection. Start operation to read the list
+    // of jobs. The connection::async_write() function will automatically
+    // decode the data that is read from the underlying socket.
+    LOG(1, "INFO: Sending address " << address << " ...");
+    connection_.async_write(address,
+      boost::bind(&SubmitResultOperation::handle_SendChoice, this,
+      boost::asio::placeholders::error));
+  } else if (endpoint_iterator != boost::asio::ip::tcp::resolver::iterator()) {
+    // Try the next endpoint.
+    connection_.socket().close();
+    boost::asio::ip::tcp::endpoint endpoint = *endpoint_iterator;
+    connection_.socket().async_connect(endpoint,
+      boost::bind(&SubmitResultOperation::handle_connect, this,
+      boost::asio::placeholders::error, ++endpoint_iterator));
+  } else {
+    // An error occurred. Log it and return. Since we are not starting a new
+    // operation the io_service will run out of work to do and the client will
+    // exit.
+    exitflag = ErrorFlag;
+    ELOG(1, e.message());
+  }
+}
+
+/// Callback function when address has been sent and result is about to
+void SubmitResultOperation::handle_SendChoice(const boost::system::error_code& e)
+{
+  Info info(__FUNCTION__);
+  if (!e)
+  {
+    // Successfully established connection. Start operation to read the list
+    // of jobs. The connection::async_write() function will automatically
+    // decode the data that is read from the underlying socket.
+    enum WorkerChoices choice = SendResult;
+    connection_.async_write(choice,
+      boost::bind(&SubmitResultOperation::handle_SendResult, this,
+      boost::asio::placeholders::error));
+  } else {
+    // An error occurred. Log it and return. Since we are not starting a new
+    // operation the io_service will run out of work to do and the client will
+    // exit.
+    exitflag = ErrorFlag;
+    ELOG(1, e.message());
+  }
+}
+
+/// Callback function when address has been sent and result is about to
+void SubmitResultOperation::handle_SendResult(const boost::system::error_code& e)
+{
+  Info info(__FUNCTION__);
+  if (!e)
+  {
+    // Successfully established connection. Start operation to read the list
+    // of jobs. The connection::async_write() function will automatically
+    // decode the data that is read from the underlying socket.
+    LOG(1, "INFO: Sending result #" << result->getId() << " ...");
+    connection_.async_write(result,
+      boost::bind(&SubmitResultOperation::handle_FinishOperation, this,
+      boost::asio::placeholders::error));
+  } else {
+    // An error occurred. Log it and return. Since we are not starting a new
+    // operation the io_service will run out of work to do and the client will
+    // exit.
+    exitflag = ErrorFlag;
+    ELOG(1, e.message());
+  }
+}
+
+/// Callback function when result has been sent.
+void SubmitResultOperation::handle_FinishOperation(const boost::system::error_code& e)
+{
+  Info info(__FUNCTION__);
+  LOG(1, "INFO: result #" << result->getId() << " sent.");
+  AsyncOperation::handle_FinishOperation(e);
+}
Index: src/Fragmentation/Automation/Operations/Workers/SubmitResultOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Operations/Workers/SubmitResultOperation.hpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
+++ src/Fragmentation/Automation/Operations/Workers/SubmitResultOperation.hpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -0,0 +1,90 @@
+/*
+ * SubmitResultOperation.hpp
+ *
+ *  Created on: Feb 26, 2012
+ *      Author: heber
+ */
+
+#ifndef SUBMITRESULTOPERATION_HPP_
+#define SUBMITRESULTOPERATION_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include <boost/asio.hpp>
+#include <string>
+#include <vector>
+
+#include "Connection.hpp"
+
+#include "Jobs/FragmentJob.hpp"
+#include "Operations/AsyncOperation.hpp"
+#include "Results/FragmentResult.hpp"
+#include "WorkerAddress.hpp"
+
+class SubmitResultOperation : public AsyncOperation  {
+public:
+  /// Constructor for class SubmitResultOperation.
+  SubmitResultOperation(Connection &_connection, const WorkerAddress &_address) :
+    AsyncOperation(std::string("submitresult"),_connection),
+    result( new FragmentResult(JobId::NoJob, std::string("EmptyResult")) ),
+    address(_address),
+    exitflag(OkFlag)
+  {}
+  /// Destructor for class SubmitResultOperation
+  ~SubmitResultOperation() {}
+
+  /** Sets the result to submit.
+   *
+   * @param _result result to submit
+   */
+  void setResult(FragmentResult::ptr &_result)
+  {
+    result.reset();
+    result = _result;
+  }
+
+public:
+  enum {
+    OkFlag = 0,
+    ErrorFlag = 1
+  };
+
+  /** Returns the flag of the handled operation.
+   *
+   */
+  size_t getFlag() const
+  {
+    return exitflag;
+  }
+
+protected:
+  // virtual function pointer to the connection handler
+  void handle_connect(const boost::system::error_code& e,
+      boost::asio::ip::tcp::resolver::iterator endpoint_iterator);
+
+  /// Callback function when address has been sent and result is about to.
+  void handle_SendChoice(const boost::system::error_code& e);
+
+  /// Callback function when result has been sent.
+  void handle_SendResult(const boost::system::error_code& e);
+
+  /// Callback function when result has been sent.
+  void handle_FinishOperation(const boost::system::error_code& e);
+
+private:
+  // static entity of an empty result
+  FragmentResult::ptr result;
+
+  //!> address for listener
+  WorkerAddress address;
+
+  /// exit flag
+  size_t exitflag;
+};
+
+
+#endif /* SUBMITRESULTOPERATION_HPP_ */
Index: src/Fragmentation/Automation/Pool/PoolWorker.hpp
===================================================================
--- src/Fragmentation/Automation/Pool/PoolWorker.hpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ src/Fragmentation/Automation/Pool/PoolWorker.hpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -22,7 +22,7 @@
 #include "Connection.hpp"
 #include "Jobs/FragmentJob.hpp"
-#include "Controller/Commands/EnrollInPoolOperation.hpp"
-#include "Controller/Commands/RemoveFromPoolOperation.hpp"
-#include "Controller/Commands/SubmitResultOperation.hpp"
+#include "Operations/Workers/EnrollInPoolOperation.hpp"
+#include "Operations/Workers/RemoveFromPoolOperation.hpp"
+#include "Operations/Workers/SubmitResultOperation.hpp"
 #include "Listener.hpp"
 #include "WorkerAddress.hpp"
Index: src/Fragmentation/Automation/controller.cpp
===================================================================
--- src/Fragmentation/Automation/controller.cpp	(revision 9d14c39cb7829a84513a9389e0526347eb30c2be)
+++ src/Fragmentation/Automation/controller.cpp	(revision 50d0954c9954f199b1e23cb238803411a30172b2)
@@ -40,9 +40,9 @@
 #include "CodePatterns/Log.hpp"
 #include "Controller/FragmentController.hpp"
-#include "Controller/Commands/CheckResultsOperation.hpp"
-#include "Controller/Commands/GetNextJobIdOperation.hpp"
-#include "Controller/Commands/ReceiveResultsOperation.hpp"
-#include "Controller/Commands/SendJobsOperation.hpp"
-#include "Controller/Commands/ShutdownOperation.hpp"
+#include "Operations/Controllers/CheckResultsOperation.hpp"
+#include "Operations/Controllers/GetNextJobIdOperation.hpp"
+#include "Operations/Controllers/ReceiveResultsOperation.hpp"
+#include "Operations/Controllers/SendJobsOperation.hpp"
+#include "Operations/Controllers/ShutdownOperation.hpp"
 #include "Jobs/MPQCCommandJob.hpp"
 #include "Jobs/MPQCCommandJob_MPQCData.hpp"
