Index: src/Fragmentation/Automation/Controller/Commands/EnrollInPoolOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/EnrollInPoolOperation.cpp	(revision 41c1b778849fcd8e13f030bc1e1012ac80cd8881)
+++ src/Fragmentation/Automation/Controller/Commands/EnrollInPoolOperation.cpp	(revision 41c1b778849fcd8e13f030bc1e1012ac80cd8881)
@@ -0,0 +1,94 @@
+/*
+ * 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"
+
+/// 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.
+    LOG(1, "INFO: Enrolling in pool with " << address << "...");
+    connection_.async_write(address,
+      boost::bind(&Operation::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(&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 sent of address
+void EnrollInPoolOperation::handle_sendAddress(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 sent of address
+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.");
+
+  Operation::handle_FinishOperation(e);
+}
Index: src/Fragmentation/Automation/Controller/Commands/EnrollInPoolOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/EnrollInPoolOperation.hpp	(revision 41c1b778849fcd8e13f030bc1e1012ac80cd8881)
+++ src/Fragmentation/Automation/Controller/Commands/EnrollInPoolOperation.hpp	(revision 41c1b778849fcd8e13f030bc1e1012ac80cd8881)
@@ -0,0 +1,64 @@
+/*
+ * 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/Operation.hpp"
+#include "Jobs/FragmentJob.hpp"
+#include "Results/FragmentResult.hpp"
+#include "WorkerAddress.hpp"
+
+class EnrollInPoolOperation : public Operation  {
+public:
+  /// Constructor for class EnrollInPoolOperation.
+  EnrollInPoolOperation(Connection &_connection, const WorkerAddress &_address) :
+    Operation(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 sent of address
+  void handle_sendAddress(const boost::system::error_code& e);
+
+  /// Handle sent of address
+  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/ObtainJobOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/ObtainJobOperation.cpp	(revision 41c1b778849fcd8e13f030bc1e1012ac80cd8881)
+++ src/Fragmentation/Automation/Controller/Commands/ObtainJobOperation.cpp	(revision 41c1b778849fcd8e13f030bc1e1012ac80cd8881)
@@ -0,0 +1,69 @@
+/*
+ * 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"
+
+/// 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() << ".");
+
+  Operation::handle_FinishOperation(e);
+}
Index: src/Fragmentation/Automation/Controller/Commands/ObtainJobOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/ObtainJobOperation.hpp	(revision 41c1b778849fcd8e13f030bc1e1012ac80cd8881)
+++ src/Fragmentation/Automation/Controller/Commands/ObtainJobOperation.hpp	(revision 41c1b778849fcd8e13f030bc1e1012ac80cd8881)
@@ -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 "Controller/Commands/Operation.hpp"
+#include "Jobs/FragmentJob.hpp"
+#include "Results/FragmentResult.hpp"
+
+class ObtainJobOperation : public Operation  {
+public:
+  /// Constructor for class ObtainJobOperation.
+  ObtainJobOperation(Connection &_connection) :
+    Operation(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/SendJobToWorkerOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/SendJobToWorkerOperation.cpp	(revision 41c1b778849fcd8e13f030bc1e1012ac80cd8881)
+++ src/Fragmentation/Automation/Controller/Commands/SendJobToWorkerOperation.cpp	(revision 41c1b778849fcd8e13f030bc1e1012ac80cd8881)
@@ -0,0 +1,65 @@
+/*
+ * 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 "types.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(&Operation::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 41c1b778849fcd8e13f030bc1e1012ac80cd8881)
+++ src/Fragmentation/Automation/Controller/Commands/SendJobToWorkerOperation.hpp	(revision 41c1b778849fcd8e13f030bc1e1012ac80cd8881)
@@ -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 "Controller/Commands/Operation.hpp"
+#include "Jobs/FragmentJob.hpp"
+#include "Jobs/SystemCommandJob.hpp"
+#include "WorkerAddress.hpp"
+
+class SendJobToWorkerOperation : public Operation  {
+public:
+  /// Constructor for class SendJobToWorkerOperation.
+  SendJobToWorkerOperation(Connection &_connection) :
+    Operation(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/ShutdownOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/ShutdownOperation.cpp	(revision 95454a7757cb2e73de8ed370a8d7b2ea5103e000)
+++ src/Fragmentation/Automation/Controller/Commands/ShutdownOperation.cpp	(revision 41c1b778849fcd8e13f030bc1e1012ac80cd8881)
@@ -2,5 +2,5 @@
  * Project: MoleCuilder
  * Description: creates and alters molecular systems
- * Copyright (C)  2011-2012 University of Bonn. All rights reserved.
+ * Copyright (C)  2012 University of Bonn. All rights reserved.
  * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
  */
@@ -9,5 +9,5 @@
  * ShutdownOperation.cpp
  *
- *  Created on: Dec 11, 2011
+ *  Created on: Feb 28, 2012
  *      Author: heber
  */
Index: src/Fragmentation/Automation/Controller/Commands/SubmitResultOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/SubmitResultOperation.cpp	(revision 41c1b778849fcd8e13f030bc1e1012ac80cd8881)
+++ src/Fragmentation/Automation/Controller/Commands/SubmitResultOperation.cpp	(revision 41c1b778849fcd8e13f030bc1e1012ac80cd8881)
@@ -0,0 +1,99 @@
+/*
+ * 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"
+
+
+/// 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_SendAddress, 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_SendAddress(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_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 result has been sent.
+void SubmitResultOperation::handle_SendResult(const boost::system::error_code& e)
+{
+  Info info(__FUNCTION__);
+  if (!e) {
+    LOG(1, "INFO: result #" << result->getId() << " sent.");
+    Operation::handle_FinishOperation(e);
+  } 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/SubmitResultOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/SubmitResultOperation.hpp	(revision 41c1b778849fcd8e13f030bc1e1012ac80cd8881)
+++ src/Fragmentation/Automation/Controller/Commands/SubmitResultOperation.hpp	(revision 41c1b778849fcd8e13f030bc1e1012ac80cd8881)
@@ -0,0 +1,87 @@
+/*
+ * 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/Operation.hpp"
+#include "Jobs/FragmentJob.hpp"
+#include "Results/FragmentResult.hpp"
+#include "WorkerAddress.hpp"
+
+class SubmitResultOperation : public Operation  {
+public:
+  /// Constructor for class SubmitResultOperation.
+  SubmitResultOperation(Connection &_connection, const WorkerAddress &_address) :
+    Operation(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_SendAddress(const boost::system::error_code& e);
+
+  /// Callback function when result has been sent.
+  void handle_SendResult(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/WorkOnJobOperation.cpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/WorkOnJobOperation.cpp	(revision 95454a7757cb2e73de8ed370a8d7b2ea5103e000)
+++ 	(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.
- */
-
-/*
- * WorkOnJobOperation.cpp
- *
- *  Created on: 22.02.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 "WorkOnJobOperation.hpp"
-
-#include <boost/bind.hpp>
-#include "CodePatterns/Info.hpp"
-#include "CodePatterns/Log.hpp"
-#include "Jobs/FragmentJob.hpp"
-#include "Jobs/MPQCCommandJob.hpp"
-#include "Jobs/SystemCommandJob.hpp"
-#include "Results/FragmentResult.hpp"
-
-FragmentResult::ptr WorkOnJobOperation::EmptyResult( new FragmentResult(JobId::NoJob, std::string("EmptyResult")) );
-
-/// Handle completion of a connect operation.
-void WorkOnJobOperation::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(&WorkOnJobOperation::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(&WorkOnJobOperation::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 job has been received.
-void WorkOnJobOperation::handle_ReceiveJob(const boost::system::error_code& e)
-{
-  Info info(__FUNCTION__);
-  if (!e)
-  {
-    LOG(1, "INFO: Received job #" << job->getId() << ".");
-    if (job->getId() != JobId::NoJob) {
-      // Print out the data that was received.
-      std::cout << "Job id: " << job->getId() << "\n";
-
-      // do something .. right now: wait
-      LOG(1, "INFO: Calculating job #" << job->getId() << " ...");
-      FragmentResult::ptr result(job->Work());
-
-      // write the result to the server
-      LOG(1, "INFO: Sending result for job #" << job->getId() << " ...");
-      connection_.async_write(result,
-        boost::bind(&WorkOnJobOperation::handle_SendResult, this,
-        boost::asio::placeholders::error));
-
-    } else {
-      std::cout << "The server has no job for me." << std::endl;
-      // send out empty result
-      LOG(1, "INFO: Sending empty result ...");
-      connection_.async_write(EmptyResult,
-        boost::bind(&WorkOnJobOperation::handle_SendResult, this,
-        boost::asio::placeholders::error));
-      exitflag = ErrorFlag;
-    }
-  }
-  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 result has been sent.
-void WorkOnJobOperation::handle_SendResult(const boost::system::error_code& e)
-{
-  Info info(__FUNCTION__);
-  // Nothing to do.
-  LOG(1, "INFO: Job #" << job->getId() << " calculated and sent.");
-  // erase job
-  job.reset();
-}
Index: src/Fragmentation/Automation/Controller/Commands/WorkOnJobOperation.hpp
===================================================================
--- src/Fragmentation/Automation/Controller/Commands/WorkOnJobOperation.hpp	(revision 95454a7757cb2e73de8ed370a8d7b2ea5103e000)
+++ 	(revision )
@@ -1,72 +1,0 @@
-/*
- * WorkOnJobOperation.hpp
- *
- *  Created on: 22.02.2012
- *      Author: heber
- */
-
-#ifndef WORKONJOBOPERATION_HPP_
-#define WORKONJOBOPERATION_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/Operation.hpp"
-#include "Jobs/FragmentJob.hpp"
-#include "Results/FragmentResult.hpp"
-
-class WorkOnJobOperation : public Operation  {
-public:
-  /// Constructor for class WorkOnJobOperation.
-  WorkOnJobOperation(Connection &_connection) :
-    Operation(std::string("workonjob"),_connection) {}
-  /// Destructor for class WorkOnJobOperation
-  ~WorkOnJobOperation() {}
-
-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 job has been received.
-  void handle_ReceiveJob(const boost::system::error_code& e);
-
-  /// Callback function when result has been sent.
-  void handle_SendResult(const boost::system::error_code& e);
-
-private:
-  // static entity of an empty result
-  static FragmentResult::ptr EmptyResult;
-
-  /// The data received from the server.
-  FragmentJob::ptr job;
-
-  /// exit flag
-  size_t exitflag;
-};
-
-
-#endif /* WORKONJOBOPERATION_HPP_ */
