Index: trunk/src/util/object_manager.cc
===================================================================
--- trunk/src/util/object_manager.cc	(revision 5828)
+++ trunk/src/util/object_manager.cc	(revision 6142)
@@ -10,5 +10,5 @@
 
    ### File Specific:
-   main-programmer: ...
+   main-programmer: Benjamin Grauer
    co-programmer: ...
 */
@@ -19,13 +19,16 @@
 #include "class_list.h"
 
-#include "p_node.h"
 #include "world_entity.h"
-#include "list.h"
+
+#include "shell_command.h"
+
+#include <assert.h>
 
 using namespace std;
-
-
-/**
- * standard constructor
+SHELL_COMMAND(debug, ObjectManager, debug)
+    ->defaultValues(2, NULL, 0);
+
+/**
+ * @brief standard constructor
  */
 ObjectManager::ObjectManager ()
@@ -37,16 +40,67 @@
 }
 
-/**
- *  the singleton reference to this class
- */
-ObjectManager* ObjectManager::singletonRef = NULL;
-
-/**
-   @brief standard deconstructor
+
+/**
+ * @brief standard deconstructor
+ *
+ * this also removes ALL entitites in existence.
  */
 ObjectManager::~ObjectManager ()
 {
-  ObjectManager::singletonRef = NULL;
-}
+  this->flush();
+}
+
+/**
+ * @brief flushes all entities
+ *
+ * this function deletes all entities that exist within the ObjectManager.
+ * It does this by poping each list from the front, and delete the given object.
+ *
+ * automatically called by a destructor.
+ */
+void ObjectManager::flush()
+{
+  for (unsigned int i = 0; i < OM_SIZE; ++i)
+    while(!this->objectLists[i].empty())
+      delete this->objectLists[i].front();
+}
+
+
+/**
+ * @brief moves an Entity from an old list to a new One
+ * @param entity the entity to move.
+ * @param omList the new List to move the entity to.
+ *
+ * this will erase the entity from the old list
+ */
+void ObjectManager::toList (WorldEntity* entity, OM_LIST omList)
+{
+  assert (omList != OM_SIZE);
+
+  if (likely(entity->getOMListNumber() != OM_INIT))
+    this->objectLists[entity->getOMListNumber()].erase(entity->getEntityIterator());
+
+  if (likely(omList != OM_INIT))
+  {
+    this->objectLists[omList].push_back(entity);
+    entity->getEntityIterator() = --this->objectLists[omList].end();
+    entity->getOMListNumber() = omList;
+  }
+}
+
+
+/**
+ * @see ObjectManager::toList(WorldEntity* OM_LIST)
+ * @param entity the entity to move.
+ * @param omList the new List to move the entity to.
+ *
+ * this function also does a transformation from omList as char* to OM_LIST.
+ */
+void ObjectManager::toList (WorldEntity* entity, const char* omList)
+{
+  this->toList(entity, ObjectManager::StringToOMList(omList));
+}
+
+
 
 /**
@@ -68,2 +122,124 @@
   return NULL;
 }
+
+
+/**
+ * @brief print out nice debug information about Elements in the list OM_LIST
+ * @param omList the List to debug.
+ * @param level: level 0: only show list info; level 1: also show entities and their names.
+ */
+void ObjectManager::debug(OM_LIST omList, unsigned int level) const
+{
+  if (omList != OM_INIT || omList == OM_SIZE)
+  {
+    PRINT(0)(" +ObjectManager-LIST: '%s'==size='%d'==---\n", ObjectManager::OMListToString((OM_LIST)omList), this->objectLists[omList].size());
+  //  if (level >= 1)
+    {
+      std::list<WorldEntity*>::const_iterator entity;
+      for (entity = this->objectLists[omList].begin(); entity != this->objectLists[omList].end(); entity++)
+      {
+        PRINT(0)(" | %s::%s\n",(*entity)->getClassName(), (*entity)->getName());
+      }
+    }
+  }
+  else
+    PRINTF(2)("Invalid query. for OM_INIT-LIST or OM_SIZE\n");
+}
+
+
+/**
+ * @brief prints out very nice debug information
+ * @param listName the Name of the list to get Debug information from
+ * @param level: level 0: only show list info; level 1: also show entities and their names.
+ */
+void ObjectManager::debug(const char* listName, unsigned int level)
+{
+  PRINT(0)("=================================\n");
+  PRINT(0)("=ObjectManager-DEBUG=============\n");
+  PRINT(0)("=================================\n");
+  if (listName == NULL || listName[0] == '\0')
+    for (unsigned int i = 0; i < OM_SIZE; ++i)
+      debug((OM_LIST) i, level);
+  else
+    debug(ObjectManager::StringToOMList(listName));
+  PRINT(0)("=========================== OM ==\n");
+}
+
+
+
+/**
+ * @brief transforms an omList into a String (usefull for debugging).
+ * @param omList the OM_LIST to be transformed into a String.
+ * @returns the String transformed from omList.
+ */
+const char* ObjectManager::OMListToString(OM_LIST omList)
+{
+  if (omList == OM_INIT || omList == OM_SIZE)
+    return "===invalid===";
+
+  printf("%d\n", omList);
+  return ObjectManager::objectManagerListNames[omList];
+}
+
+
+
+/**
+ * @brief transforms a String into an OM_LIST (usefull for debugging/Loading).
+ * @param listName the OM_LIST-name to be transformed into an OM_LIST.
+ * @returns the OM_LIST transformed from listName. or the default, if not found or NULL.
+ */
+OM_LIST ObjectManager::StringToOMList(const char* listName)
+{
+  if (unlikely(listName == NULL)) return OM_DEFAULT_LIST;
+
+  for(unsigned int i = 0; i < OM_SIZE; ++i) {
+    if(!strcmp(listName, ObjectManager::objectManagerListNames[i])) {
+      return (OM_LIST)i;
+    }
+  }
+  return OM_DEFAULT_LIST;
+}
+
+
+
+const char* ObjectManager::objectManagerListNames[] = {
+    "null",
+    "dead",
+    "dead-tick",
+    "environ-notick",
+    "environ",
+    "common",
+
+    "group00",
+    "group00-proj",
+    "group01",
+    "group01-proj",
+    "group02",
+    "group02-proj",
+    "group03",
+    "group03-proj",
+    "group04",
+    "group04-proj",
+    "group05",
+    "group05-proj",
+    "group06",
+    "group06-proj",
+    "group07",
+    "group07-proj",
+    "group08",
+    "group08-proj",
+    "group09",
+    "group09-proj",
+    "group10",
+    "group10-proj",
+    "group11",
+    "group11-proj",
+    "group12",
+    "group12-proj",
+    "group13",
+    "group13-proj",
+    "group14",
+    "group14-proj",
+    "group15",
+    "group15-proj"
+};
