Index: src/ControllerCommand.hpp
===================================================================
--- src/ControllerCommand.hpp	(revision ee61ce4beaab0d3c2f7cf501fc17d4a09765d3b7)
+++ src/ControllerCommand.hpp	(revision ee61ce4beaab0d3c2f7cf501fc17d4a09765d3b7)
@@ -0,0 +1,91 @@
+/*
+ * ControllerCommand.hpp
+ *
+ *  Created on: 01.06.2012
+ *      Author: heber
+ */
+
+#ifndef CONTROLLERCOMMAND_HPP_
+#define CONTROLLERCOMMAND_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <boost/function.hpp>
+#include <deque>
+#include <string>
+
+/** ControllerCommand associates a single name with a certain deque of
+ *  (conntroller) commands.
+ *
+ * The ControllerCommand can be used as follows:
+ * \code
+ * ControllerCommand command;
+ * for (ControllerCommand::const_iterator iter = command.begin();
+ *    iter != command.end(); ++iter) {
+ *    ...
+ *    // execute current command
+ *    (*iter)();
+ *    ...
+ * }
+ * \endcode
+ *
+ */
+struct ControllerCommand
+{
+public:
+  //!> commands are simply bound functions
+  typedef boost::function<void ()> commands_t;
+  //!> typedef for deque with commands_t to execute
+  typedef std::deque<commands_t> queue_t;
+  //!> convenience constant iterator to queue_t
+  typedef std::deque<commands_t>::const_iterator const_iterator;
+
+  /** Constructor of class ControllerCommand.
+   *
+   * \param _name name of this command
+   * \param _commands command queue to associated with this command
+   */
+  ControllerCommand(const std::string &_name, const queue_t &_commands) :
+    name(_name),
+    commands(_commands)
+  {}
+  /** Destructor of class ControllerCommand.
+   *
+   */
+  ControllerCommand()
+  {}
+
+  /** Getter for begin of deque.
+   *
+   * \return iterator pointing at first command
+   */
+  const_iterator begin() const
+  { return commands.begin(); }
+
+  /** Getter for one after end of command deque.
+   *
+   * \return iterator at one position after last command
+   */
+  const_iterator end() const
+  { return commands.end(); }
+
+  /** Getter for internal name of this ControllerCommand.
+   *
+   * \note this is required for Repository pattern.
+   *
+   * \return name of this ControllerCommand
+   */
+  const std::string &getName() const
+  { return name; }
+
+private:
+  //!> name of this ControllerCommand
+  const std::string name;
+  //!> commands to execute
+  const queue_t commands;
+};
+
+#endif /* CONTROLLERCOMMAND_HPP_ */
Index: src/ControllerCommandRegistry.cpp
===================================================================
--- src/ControllerCommandRegistry.cpp	(revision ee61ce4beaab0d3c2f7cf501fc17d4a09765d3b7)
+++ src/ControllerCommandRegistry.cpp	(revision ee61ce4beaab0d3c2f7cf501fc17d4a09765d3b7)
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+/*
+ * ControllerCommandRepository.cpp
+ *
+ *  Created on: 01.06.2012
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "ControllerCommandRegistry.hpp"
+
+#include "CodePatterns/Registry_impl.hpp"
+
+ControllerCommandRegistry::ControllerCommandRegistry()
+{}
+
+ControllerCommandRegistry::~ControllerCommandRegistry()
+{
+  cleanup();
+}
+
+CONSTRUCT_REGISTRY(ControllerCommand)
Index: src/ControllerCommandRegistry.hpp
===================================================================
--- src/ControllerCommandRegistry.hpp	(revision ee61ce4beaab0d3c2f7cf501fc17d4a09765d3b7)
+++ src/ControllerCommandRegistry.hpp	(revision ee61ce4beaab0d3c2f7cf501fc17d4a09765d3b7)
@@ -0,0 +1,28 @@
+/*
+ * ControllerCommandRegistry.hpp
+ *
+ *  Created on: 01.06.2012
+ *      Author: heber
+ */
+
+#ifndef CONTROLLERCOMMANDREGISTRY_HPP_
+#define CONTROLLERCOMMANDREGISTRY_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string>
+
+#include "CodePatterns/Registry.hpp"
+
+#include "ControllerCommand.hpp"
+
+struct ControllerCommandRegistry : public Registry<ControllerCommand>
+{
+  ControllerCommandRegistry();
+  virtual ~ControllerCommandRegistry();
+};
+
+#endif /* CONTROLLERCOMMANDREGISTRY_HPP_ */
Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision 865a21813c77962eaecd6f2a35712d565b481ffe)
+++ src/Makefile.am	(revision ee61ce4beaab0d3c2f7cf501fc17d4a09765d3b7)
@@ -381,5 +381,5 @@
   Fragmentation/Automation/Pool/WorkerPool.hpp
 
-Controller_SOURCES = $(CONTROLLERSOURCE) $(CONTROLLERHEADER) controller.cpp DefaultOptions.cpp DefaultOptions.hpp ControllerOptions.cpp ControllerOptions.hpp ControllerOptions_MPQCCommandJob.cpp ControllerOptions_MPQCCommandJob.hpp ControllerOptions_SystemCommandJob.cpp ControllerOptions_SystemCommandJob.hpp
+Controller_SOURCES = $(CONTROLLERSOURCE) $(CONTROLLERHEADER) controller.cpp ControllerCommand.hpp ControllerCommandRegistry.cpp ControllerCommandRegistry.hpp DefaultOptions.cpp DefaultOptions.hpp ControllerOptions.cpp ControllerOptions.hpp ControllerOptions_MPQCCommandJob.cpp ControllerOptions_MPQCCommandJob.hpp ControllerOptions_SystemCommandJob.cpp ControllerOptions_SystemCommandJob.hpp
 Controller_LDFLAGS = $(AM_LDFLAGS) $(BOOST_PROGRAM__OPTIONS_LDFLAGS) $(BOOST_SYSTEM_LDFLAGS) $(BOOST_THREAD_LDFLAGS) $(BOOST_SERIALIZATION_LDFLAGS)
 Controller_CXXFLAGS = $(AM_CPPFLAGS)
Index: src/controller.cpp
===================================================================
--- src/controller.cpp	(revision 865a21813c77962eaecd6f2a35712d565b481ffe)
+++ src/controller.cpp	(revision ee61ce4beaab0d3c2f7cf501fc17d4a09765d3b7)
@@ -50,4 +50,6 @@
 #include "Fragmentation/Automation/Results/FragmentResult.hpp"
 #include "ControllerOptions_MPQCCommandJob.hpp"
+#include "ControllerOptions_SystemCommandJob.hpp"
+#include "ControllerCommandRegistry.hpp"
 
 /** Print the status of scheduled and done jobs.
@@ -320,59 +322,57 @@
   boost::program_options::variables_map vm;
 
-  typedef boost::function<void ()> ControllerCommand;
-  typedef std::map<std::string, std::deque<ControllerCommand> > CommandsMap_t;
-  CommandsMap_t CommandsMap;
-
-  // prepare the command queues for each ControllerCommand
-  // note: we need "< ControllerCommand >" because parseExecutable(),... return int
+  // prepare ControllerCommand
+  // note: we need "< ControllerCommand::commands_t >" because parseExecutable(),... return int
   // in contrast to other functions that return void
-  std::deque<ControllerCommand> addjobsQueue = boost::assign::list_of< ControllerCommand >
+  ControllerCommandRegistry ControllerCommands;
+  ControllerCommands.registerInstance(new ControllerCommand("addjobs",
+      boost::assign::list_of< ControllerCommand::commands_t >
       (boost::bind(&FragmentController::requestIds,
           boost::ref(controller), boost::cref(ControllerInfo.server), boost::cref(ControllerInfo.serverport),
           boost::bind(&std::vector<std::string>::size, boost::cref(ControllerInfo.jobfiles))))
       (boost::bind(&AddJobs, boost::ref(controller), boost::cref(ControllerInfo)))
-      ;
-  std::deque<ControllerCommand> createjobsQueue = boost::assign::list_of< ControllerCommand >
-      (boost::bind(&FragmentController::requestIds,
-          boost::ref(controller), boost::cref(ControllerInfo.server), boost::cref(ControllerInfo.serverport), 1))
-      (boost::bind(&createJobs, boost::ref(controller), boost::cref(ControllerInfo)))
-      ;
-  std::deque<ControllerCommand> checkresultsQueue = boost::assign::list_of< ControllerCommand >
-      (boost::bind(&FragmentController::checkResults,
-          boost::ref(controller), boost::cref(ControllerInfo.server), boost::cref(ControllerInfo.serverport)))
-      (boost::bind(&printJobStatus,
-          boost::bind(&FragmentController::getJobStatus, boost::ref(controller))))
-      ;
-  std::deque<ControllerCommand> receiveresultsQueue = boost::assign::list_of< ControllerCommand >
-      (boost::bind(&FragmentController::receiveResults,
-          boost::ref(controller), boost::cref(ControllerInfo.server), boost::cref(ControllerInfo.serverport)))
-      (boost::bind(&printReceivedResults,
-          boost::bind(&FragmentController::getReceivedResults, boost::ref(controller))))
-      ;
-  std::deque<ControllerCommand> receivempqcresultsQueue = boost::assign::list_of< ControllerCommand >
-      (boost::bind(&FragmentController::receiveResults,
-          boost::ref(controller), boost::cref(ControllerInfo.server), boost::cref(ControllerInfo.serverport)))
-      (boost::bind(&printReceivedMPQCResults,
-          boost::bind(&FragmentController::getReceivedResults, boost::ref(controller)),
-          boost::cref(ControllerInfo.fragmentpath),
-          boost::bind(&getNoAtomsFromAdjacencyFile, boost::cref(ControllerInfo.fragmentpath))))
-      ;
-  std::deque<ControllerCommand> removeallQueue = boost::assign::list_of< ControllerCommand >
-      (boost::bind(&FragmentController::removeall,
-          boost::ref(controller), boost::cref(ControllerInfo.server), boost::cref(ControllerInfo.serverport)))
-      ;
-  std::deque<ControllerCommand> shutdownQueue = boost::assign::list_of< ControllerCommand >
-      (boost::bind(&FragmentController::shutdown,
-          boost::ref(controller), boost::cref(ControllerInfo.server), boost::cref(ControllerInfo.serverport)))
-      ;
-  CommandsMap.insert( std::make_pair("addjobs", addjobsQueue) );
-  CommandsMap.insert( std::make_pair("createjobs", createjobsQueue) );
-  CommandsMap.insert( std::make_pair("checkresults", checkresultsQueue) );
-  CommandsMap.insert( std::make_pair("receiveresults", receiveresultsQueue) );
-  CommandsMap.insert( std::make_pair("receivempqc", receivempqcresultsQueue) );
-  CommandsMap.insert( std::make_pair("removeall", removeallQueue) );
-  CommandsMap.insert( std::make_pair("shutdown", shutdownQueue) );
+      ));
+  ControllerCommands.registerInstance(new ControllerCommand("createjobs",
+      boost::assign::list_of< ControllerCommand::commands_t >
+        (boost::bind(&FragmentController::requestIds,
+            boost::ref(controller), boost::cref(ControllerInfo.server), boost::cref(ControllerInfo.serverport), 1))
+        (boost::bind(&createJobs, boost::ref(controller), boost::cref(ControllerInfo)))
+      ));
+  ControllerCommands.registerInstance(new ControllerCommand("checkresults",
+      boost::assign::list_of< ControllerCommand::commands_t >
+        (boost::bind(&FragmentController::checkResults,
+            boost::ref(controller), boost::cref(ControllerInfo.server), boost::cref(ControllerInfo.serverport)))
+        (boost::bind(&printJobStatus,
+            boost::bind(&FragmentController::getJobStatus, boost::ref(controller))))
+      ));
+  ControllerCommands.registerInstance(new ControllerCommand("receiveresults",
+      boost::assign::list_of< ControllerCommand::commands_t >
+        (boost::bind(&FragmentController::receiveResults,
+            boost::ref(controller), boost::cref(ControllerInfo.server), boost::cref(ControllerInfo.serverport)))
+        (boost::bind(&printReceivedResults,
+            boost::bind(&FragmentController::getReceivedResults, boost::ref(controller))))
+      ));
+  ControllerCommands.registerInstance(new ControllerCommand("receivempqc",
+      boost::assign::list_of< ControllerCommand::commands_t >
+        (boost::bind(&FragmentController::receiveResults,
+            boost::ref(controller), boost::cref(ControllerInfo.server), boost::cref(ControllerInfo.serverport)))
+        (boost::bind(&printReceivedMPQCResults,
+            boost::bind(&FragmentController::getReceivedResults, boost::ref(controller)),
+            boost::cref(ControllerInfo.fragmentpath),
+            boost::bind(&getNoAtomsFromAdjacencyFile, boost::cref(ControllerInfo.fragmentpath))))
+      ));
+  ControllerCommands.registerInstance(new ControllerCommand("removeall",
+      boost::assign::list_of< ControllerCommand::commands_t >
+        (boost::bind(&FragmentController::removeall,
+            boost::ref(controller), boost::cref(ControllerInfo.server), boost::cref(ControllerInfo.serverport)))
+      ));
+  ControllerCommands.registerInstance(new ControllerCommand("shutdown",
+      boost::assign::list_of< ControllerCommand::commands_t >
+        (boost::bind(&FragmentController::shutdown,
+            boost::ref(controller), boost::cref(ControllerInfo.server), boost::cref(ControllerInfo.serverport)))
+      ));
   std::vector<std::string> Commands;
-  for (CommandsMap_t::const_iterator iter = CommandsMap.begin(); iter != CommandsMap.end(); ++iter)
+  for (ControllerCommandRegistry::const_iterator iter = ControllerCommands.getBeginIter();
+      iter != ControllerCommands.getEndIter(); ++iter)
     Commands.push_back(iter->first);
 
@@ -416,17 +416,16 @@
 
   // parse given ControllerCommand
-  if( CommandsMap.count(ControllerInfo.command) == 0) {
+  if(!ControllerCommands.isPresentByName(ControllerInfo.command)) {
     ELOG(1, "Unrecognized command '"+toString(ControllerInfo.command)+"'.");
     return 255;
   }
-  std::deque<ControllerCommand> &commands = CommandsMap[ControllerInfo.command];
+  const ControllerCommand *commands = ControllerCommands.getByName(ControllerInfo.command);
   try
   {
     // execute each command in the queue synchronously
     size_t phase = 1;
-    while (!commands.empty()) {
-      ControllerCommand command = commands.front();
-      commands.pop_front();
-      command();
+    for (ControllerCommand::const_iterator iter = commands->begin();
+       iter != commands->end(); ++iter, ++phase) {
+      (*iter)();
       {
         io_service.reset();
