Index: trunk/src/lib/util/loading/dynamic_loader.cc
===================================================================
--- trunk/src/lib/util/loading/dynamic_loader.cc	(revision 9675)
+++ trunk/src/lib/util/loading/dynamic_loader.cc	(revision 9869)
@@ -24,5 +24,5 @@
 
 
-
+ObjectListDefinition(DynamicLoader);
 
 /**
@@ -31,7 +31,7 @@
 */
 DynamicLoader::DynamicLoader (const std::string& libName)
-    : Factory(NULL, CL_NULL)
+    : Factory(libName)
 {
-  this->setClassID(CL_DYNAMIC_LOADER, "DynamicLoader");
+  this->registerObject(this, DynamicLoader::_objectList);
 
   this->handle = NULL;
Index: trunk/src/lib/util/loading/dynamic_loader.h
===================================================================
--- trunk/src/lib/util/loading/dynamic_loader.h	(revision 9675)
+++ trunk/src/lib/util/loading/dynamic_loader.h	(revision 9869)
@@ -19,4 +19,5 @@
 class DynamicLoader : public Factory
 {
+  ObjectListDeclaration(DynamicLoader);
 
 public:
Index: trunk/src/lib/util/loading/factory.cc
===================================================================
--- trunk/src/lib/util/loading/factory.cc	(revision 9675)
+++ trunk/src/lib/util/loading/factory.cc	(revision 9869)
@@ -15,9 +15,9 @@
 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_LOADING
 
-#include "util/loading/factory.h"
+#include "factory.h"
 #include "debug.h"
 //#include "shell_command.h"
 
-
+ObjectListDefinition(Factory);
 
 //SHELL_COMMAND(create, Factory, fabricate);
@@ -28,18 +28,20 @@
  * set everything to zero and define factoryName
  */
-Factory::Factory (const std::string& factoryName, ClassID classID)
-    : classID(classID), className(factoryName)
+Factory::Factory (const ClassID& classID)
+    : _classID(classID)
 {
-  this->setClassID(CL_FACTORY, "Factory");
-  this->setName(factoryName);
+  PRINTF(4)("Factory::create(%s::%d)\n", classID.name().c_str(), classID.id());
+  //this->registerObject(this, Factory::_objectList);
+  this->setName(classID.name());
 
-  if( Factory::factoryList == NULL)
-    Factory::factoryList = new std::list<Factory*>;
-
-  Factory::factoryList->push_back(this);
+  Factory::_factoryIDMap[classID] = this;
+  Factory::_factoryStringMap[classID.name()] = this;
 }
 
-/** @brief a reference to the First Factory */
-std::list<Factory*>* Factory::factoryList = NULL;
+/** @brief A Map of all Factories ordered by ID. */
+Factory::FactoryIDMap Factory::_factoryIDMap;
+
+/** @brief A Map of all Factories ordered by Name. */
+Factory::FactoryStringMap Factory::_factoryStringMap;
 
 /**
@@ -48,24 +50,11 @@
 Factory::~Factory ()
 {
-  //  printf("%s\n", this->factoryName);
-  //  Factory* tmpDel = this->next;
-  //  this->next = NULL;
-}
+  FactoryIDMap::iterator it = Factory::_factoryIDMap.find(this->_classID);
+  if (it != Factory::_factoryIDMap.end() && (*it).second == this)
+    Factory::_factoryIDMap.erase(it);
 
-/**
- * @brief deletes all the Factories. (cleanup)
- */
-void Factory::deleteFactories()
-{
-  if (Factory::factoryList != NULL)
-  {
-    while(!Factory::factoryList->empty())
-    {
-      delete Factory::factoryList->front();
-      Factory::factoryList->pop_front();
-    }
-    delete Factory::factoryList;
-    Factory::factoryList = NULL;
-  }
+  FactoryStringMap::iterator stringIt = Factory::_factoryStringMap.find(this->_classID.name());
+  if (stringIt != Factory::_factoryStringMap.end() && (*stringIt).second == this)
+    Factory::_factoryStringMap.erase(stringIt);
 }
 
@@ -74,18 +63,9 @@
  * @returns true on match, false otherwise
  */
-bool Factory::operator==(ClassID classID) const
+bool Factory::operator==(int classID) const
 {
-  return (this->classID == classID);
+  return (this->_classID == classID);
 }
 
-/**
- * @brief Compares the Factories Name against a given ClassName
- * @param className the Name of the Class to Query
- * @returns true on match, false otherwise.
- */
-bool Factory::operator==(const char* className) const
-{
-  return (className != NULL && this->className == className);
-}
 
 /**
@@ -96,5 +76,5 @@
 bool Factory::operator==(const std::string& className) const
 {
-  return (this->className == className);
+  return (this->_classID.name() == className);
 }
 
@@ -107,16 +87,15 @@
 BaseObject* Factory::fabricate(const TiXmlElement* root)
 {
-  assert (root != NULL && Factory::factoryList != NULL);
-
-  std::list<Factory*>::const_iterator factory;
-  for (factory = Factory::factoryList->begin(); factory != Factory::factoryList->end(); factory++)
-    if (*(*factory) == root->Value())
-    {
-      PRINTF(2)("Create a new Object of type %s\n", (*factory)->getCName());
-      return (*factory)->fabricateObject(root);
-    }
-
-  PRINTF(2)("Could not Fabricate an Object of Class '%s'\n", root->Value());
-  return NULL;
+  FactoryStringMap::const_iterator it = Factory::_factoryStringMap.find(root->Value());
+  if (it != Factory::_factoryStringMap.end())
+  {
+    PRINTF(2)("Create a new Object of type %s\n", (*it).second->getCName());
+    return (*it).second->fabricateObject(root);
+  }
+  else
+  {
+    PRINTF(2)("Could not Fabricate an Object of Class '%s'\n", root->Value());
+    return NULL;
+  }
 }
 
@@ -129,18 +108,16 @@
 BaseObject* Factory::fabricate(const std::string& className)
 {
-  if (Factory::factoryList == NULL)
+  FactoryStringMap::const_iterator it = Factory::_factoryStringMap.find(className);
+  if (it != Factory::_factoryStringMap.end())
+  {
+    PRINTF(2)("Create a new Object of type %s\n", (*it).second->getCName());
+    return (*it).second->fabricateObject(NULL);
+  }
+  else
+  {
+    PRINTF(2)("Could not Fabricate an Object of Class '%s'\n", className.c_str());
     return NULL;
-
-  std::list<Factory*>::const_iterator factory;
-  for (factory = Factory::factoryList->begin(); factory != Factory::factoryList->end(); factory++)
-    if (*(*factory) == className)
-    {
-      PRINTF(4)("Create a new Object of type %s\n", (*factory)->getCName());
-      return (*factory)->fabricateObject(NULL);
-    }
-  PRINTF(2)("Could not Fabricate an Object of Class '%s'\n", className.c_str());
-  return NULL;
+  }
 }
-
 
 /**
@@ -149,18 +126,36 @@
  * @returns a new Object of Type classID on match, NULL otherwise
  */
-BaseObject* Factory::fabricate(ClassID classID)
+BaseObject* Factory::fabricate(const ClassID& classID)
 {
-  if (Factory::factoryList == NULL)
+  FactoryIDMap::const_iterator it = Factory::_factoryIDMap.find(classID);
+  if (it != Factory::_factoryIDMap.end())
+  {
+    PRINTF(4)("Create a new Object of type %s\n", (*it).second->getCName());
+    return (*it).second->fabricateObject(NULL);
+  }
+  else
+  {
+    PRINTF(2)("Could not Fabricate an Object of ClassID '%d'\n", classID.id());
     return NULL;
+  }
+}
 
-  std::list<Factory*>::const_iterator factory;
-  for (factory = Factory::factoryList->begin(); factory != Factory::factoryList->end(); factory++)
-    if (*(*factory) == classID)
-    {
-      PRINTF(4)("Create a new Object of type %s\n", (*factory)->getCName());
-      return (*factory)->fabricateObject(NULL);
 
-    }
-  PRINTF(2)("Could not Fabricate an Object of ClassID '0x%h'\n", classID);
-  return NULL;
+/**
+ * @brief print out some nice litte debug information about the Factory.
+ */
+void Factory::debug() const
+{
+  PRINTF(0)("Factory of class '%s' with ClassID: %d\n", this->_classID.name().c_str(), this->_classID.id());
 }
+
+/**
+ * @brief Prints out some nice Debug information about all factories
+ */
+void Factory::debugAll()
+{
+  PRINTF(0)("Debugging all %d Factories\n", Factory::_factoryStringMap.size());
+  Factory::FactoryStringMap::const_iterator it;
+  for (it = Factory::_factoryStringMap.begin(); it != Factory::_factoryStringMap.end(); ++it)
+    (*it).second->debug();
+}
Index: trunk/src/lib/util/loading/factory.h
===================================================================
--- trunk/src/lib/util/loading/factory.h	(revision 9675)
+++ trunk/src/lib/util/loading/factory.h	(revision 9869)
@@ -20,6 +20,6 @@
 
 
-#ifndef _FACTORY_H
-#define _FACTORY_H
+#ifndef __FACTORY_H
+#define __FACTORY_H
 
 class BaseObject;
@@ -27,6 +27,5 @@
 #include "parser/tinyxml/tinyxml.h"
 #include "base_object.h"
-#include <vector>
-#include <list>
+#include <map>
 
 /**
@@ -34,32 +33,50 @@
  * this should be used at the beginning of all the Classes that should be loadable (in the cc-file)
  */
-#define CREATE_FACTORY(CLASS_NAME, CLASS_ID) \
-    tFactory<CLASS_NAME>* global_##CLASS_NAME##_Factory = new tFactory<CLASS_NAME>(#CLASS_NAME, CLASS_ID)
+#define CREATE_FACTORY(CLASS_NAME) \
+    tFactory<CLASS_NAME> global_##CLASS_NAME##_Factory = tFactory<CLASS_NAME>(CLASS_NAME::staticClassID())
 
 //! The Factory is a loadable object handler
-class Factory : public BaseObject {
-
- public:
+class Factory : public BaseObject
+{
+  //! Declare the ObjectList at the BaseObject List
+  ObjectListDeclaration(Factory);
+public:
   virtual ~Factory ();
 
-  static void deleteFactories();
+  static  BaseObject* fabricate(const std::string& className);
+  static  BaseObject* fabricate(const ClassID& classID);
+  static  BaseObject* fabricate(const TiXmlElement* root);
 
-  static  BaseObject* fabricate(const std::string& className);
-  static  BaseObject* fabricate(ClassID classID);
-  static  BaseObject* fabricate(const TiXmlElement* root = NULL);
+  bool operator==(int classID) const;
+  bool operator==(const std::string& className) const;
+  /** @param classID the ID to compare @returns true if the ID's match */
+  bool operator==(const ClassID& classID) const { return _classID == classID; };
 
 
-  bool operator==(ClassID classID) const;
-  bool operator==(const char* className) const;
-  bool operator==(const std::string& className) const;
+  void debug() const;
+  static void debugAll();
 
-  protected:
-    Factory (const std::string& factoryName, ClassID classID);
-    virtual BaseObject* fabricateObject(const TiXmlElement* root = NULL) const = 0;
+protected:
+  Factory (const ClassID& id);
+  /**
+   * @brief The core function of the Factory. Creates objects of the Factories Type.
+   * @param root The TiXmlElement of the Factory.
+   * @returns the created Object in BaseType* format.
+   */
+  virtual BaseObject* fabricateObject(const TiXmlElement* root = NULL) const = 0;
 
-  protected:
-    const ClassID                 classID;              //!< The Class-Identifyer of the Factory.
-    const std::string             className;            //!< The name of the Class.
-    static std::list<Factory*>*   factoryList;          //!< List of Registered Factories
+private:
+  //! Copy Constructor is hidden.
+  Factory (const Factory&) {};
+
+protected:
+  /** The Type of the FactoryMap that is sorted by ID */
+  typedef std::map<const ClassID, Factory*>  FactoryIDMap;
+  /** The Type of the FactoryMap that is sorted by Name */
+  typedef std::map<std::string, Factory*>    FactoryStringMap;
+
+  const ClassID                 _classID;              //!< The Class-Identifyer of the Factory.
+  static FactoryIDMap           _factoryIDMap;         //!< List of Registered Factories
+  static FactoryStringMap       _factoryStringMap;     //!< List of Registered Factories
 };
 
@@ -70,24 +87,27 @@
 template<class T> class tFactory : public Factory
 {
- public:
- /**
-  * @brief creates a new type Factory to enable the loading of T
-  * @param factoryName the Name of the Factory to load.
-  * @param classID the ID of the Class to be created.
-  */
-  tFactory (const char* factoryName, ClassID classID)
-   : Factory(factoryName, classID)
+public:
+  /**
+   * @brief creates a new type Factory to enable the loading of T
+   * @param classID the ID of the Class to be created.
+   */
+  tFactory (const ClassID& classID)
+      : Factory(classID)
   {  }
+  /**
+   * @brief copy constructor
+   * @param factory the Factory to copy
+   */
+  tFactory (const tFactory& factory) : Factory(factory._classID) {};
 
-  private:
-   /**
-    * @brief fabricates an Object of type T, with the constructor T::T(const TiXmlElemnt*)
-    * @param root the TiXmlElement T should load parameters from.
-    * @return the newly fabricated T.
-    */
-    virtual BaseObject* fabricateObject(const TiXmlElement* root = NULL) const
-    {
-      return new T(root);
-    }
+  /**
+   * @brief fabricates an Object of type T, with the constructor T::T(const TiXmlElemnt*)
+   * @param root the TiXmlElement T should load parameters from.
+   * @return the newly fabricated T.
+   */
+  virtual BaseObject* fabricateObject(const TiXmlElement* root = NULL) const
+  {
+    return new T(root);
+  }
 };
 
Index: trunk/src/lib/util/loading/fast_factory.cc
===================================================================
--- trunk/src/lib/util/loading/fast_factory.cc	(revision 9869)
+++ trunk/src/lib/util/loading/fast_factory.cc	(revision 9869)
@@ -0,0 +1,281 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+### File Specific:
+   main-programmer: Benjamin Grauer
+*/
+
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_LOAD
+
+#include "fast_factory.h"
+
+#include "compiler.h"
+#include "debug.h"
+
+
+ObjectListDefinition(FastFactory);
+
+/**
+ * @brief Initializes a FastFactory
+ * @param classID the ClassID this Class belongs to (the top-most)
+ * @param fastFactoryName the Name of the ObjectClass-handled here
+ * @return a new FastFactory
+ */
+FastFactory::FastFactory (const ClassID& classID, const std::string& fastFactoryName)
+{
+  this->registerObject(this, FastFactory::_objectList);
+  this->setName(fastFactoryName);
+
+  this->storedClassID = classID;
+  this->next = NULL;
+
+  this->deadList = NULL;
+  this->unusedContainers = NULL;
+
+  this->storedDeadObjects = 0;
+
+  FastFactory::registerFastFactory(this);
+}
+
+/** a reference to the First FastFactory */
+FastFactory* FastFactory::first = NULL;
+
+/**
+ *  destructor
+ * deletes all the Instances of the FastFactory.
+ */
+FastFactory::~FastFactory ()
+{
+  if (this == first)
+    this->first = NULL;
+  this->flush();
+
+  if (this->next)
+    delete this->next;
+}
+
+/**
+ * deletes all FastFactories
+ */
+void FastFactory::deleteAll()
+{
+  if (FastFactory::first)
+    delete FastFactory::first;
+}
+
+/**
+ * registers a Factory to the List of known factories.
+ * @param fastFactory The factory to add
+ *
+ * needed, to step through all the FastFactories.
+ */
+void FastFactory::registerFastFactory(FastFactory* fastFactory)
+{
+  PRINTF(4)("Registered FastFactory for '%s'\n", fastFactory->getCName());
+
+  if( FastFactory::first == NULL)
+    FastFactory::first = fastFactory;
+  else
+  {
+    FastFactory* tmpFac = FastFactory::first;
+    while( tmpFac->next != NULL)
+      tmpFac = tmpFac->next;
+    tmpFac->setNext(fastFactory);
+  }
+}
+
+/**
+ * searches for a FastFactory
+ * @param classID the ClassID of the FastFactory to search for
+ * @returns true if found, false otherwise.
+ */
+FastFactory* FastFactory::searchFastFactory(const ClassID& classID)
+{
+  if (FastFactory::first == NULL)
+    return NULL;
+  else
+  {
+    FastFactory* tmpFac = FastFactory::first;
+    while (tmpFac != NULL)
+    {
+      if (tmpFac->storedClassID == classID)
+        return tmpFac;
+      tmpFac = tmpFac->next;
+    }
+  }
+  return NULL;
+}
+
+/**
+ * searches for a FastFactory
+ * @param classID the ClassID of the FastFactory to search for
+ * @returns true if found, false otherwise.
+ */
+FastFactory* FastFactory::searchFastFactory(const std::string& fastFactoryName)
+{
+  if (FastFactory::first == NULL)
+    return NULL;
+  else
+  {
+    FastFactory* tmpFac = FastFactory::first;
+    while (tmpFac != NULL)
+    {
+      if (fastFactoryName == tmpFac->getCName())
+        return tmpFac;
+      tmpFac = tmpFac->next;
+    }
+  }
+  return NULL;
+}
+
+/**
+ * Removes all the stored Containers, and sets the Lists back to emptienes.
+ * @param hardFLUSH if true the containing Objects will also be deleted !! THIS IS DANGEROUS !!
+ */
+void FastFactory::flushAll(bool hardFLUSH)
+{
+  FastFactory* tmpFac = FastFactory::first;
+  while (tmpFac != NULL)
+  {
+    PRINTF(4)("DELETEING ALL OF %s\n",tmpFac->getCName());
+    tmpFac->flush(hardFLUSH);
+    tmpFac = tmpFac->next;
+  }
+}
+
+/**
+ * ereases all the remaining containers, without deleting the stored Objects inside of them.
+ * @param hardFLUSH if the the containing Objects will also be deleted !! THIS IS DANGEROUS !!
+ */
+void FastFactory::flush(bool hardFLUSH)
+{
+  FastObjectMember* tmpMember = this->deadList, *delMember = NULL;
+  while (tmpMember != NULL)
+  {
+    delMember = tmpMember;
+    tmpMember = tmpMember->next;
+    if (hardFLUSH)
+      delete delMember->objectPointer;
+    delete delMember;
+  }
+  this->deadList = NULL;
+
+  tmpMember = this->unusedContainers;
+  while (tmpMember != NULL)
+  {
+    delMember = tmpMember;
+    tmpMember = tmpMember->next;
+    delete delMember;
+  }
+  this->unusedContainers = NULL;
+}
+
+/**
+ * generates count new Object of the Corresponding class. (precaching)
+ * @param count How many instances of the class should be generated.
+ */
+void FastFactory::prepare(unsigned int count)
+{
+/*  if (this->storedDeadObjects + this->storedLivingObjects >= count)
+  {
+  PRINTF(3)("not creating new Objects for class %s, because the requested count already exists\n", this->getClassCName());
+}*/
+  for (unsigned int i = this->storedDeadObjects; i < count; i++)
+  {
+    this->fabricate();
+  }
+}
+
+/**
+ * gives back live to one Object.
+ * @return the Object to resurrect.
+ */
+BaseObject* FastFactory::resurrect()
+{
+  PRINTF(4)("Resurecting Object of type %s\n", this->getCName());
+  if (unlikely(this->deadList == NULL))
+  {
+    PRINTF(3)("The deadList of Class %s is empty, this may be either because it has not been filled yet, or the cache is to small.\n" \
+        "  Developer: try increasing the count with FastFactory::prepare(contHigher than actual)\n" \
+        "    Fabricating a new %s\n", this->getCName(), this->getCName());
+    this->fabricate();
+    return this->resurrect();
+  }
+  else
+  {
+    FastObjectMember* tmpC = this->deadList;
+    this->deadList = this->deadList->next;
+
+    tmpC->next = this->unusedContainers;
+    this->unusedContainers = tmpC;
+
+    return tmpC->objectPointer;
+  }
+}
+
+/**
+ * gives back live to one Object.
+ * @param classID the class From which to resurrect an Object.
+ * @return the Object to resurrect, NULL if classID is not found.
+ */
+BaseObject* FastFactory::resurrect(const ClassID& classID)
+{
+  FastFactory* tmpFac = FastFactory::getFirst();
+
+  while (tmpFac != NULL)
+  {
+    if (classID == tmpFac->storedClassID)
+      return tmpFac->resurrect();
+    tmpFac = tmpFac->next;
+  }
+  return NULL;
+}
+
+/**
+ * kills Object object, meaning, that it will be stored in the deadList of the FastFactory, and waiting for resurrection
+ * @param object the Object to kill.
+ *
+ * synony that would be really grate would be abolish, but this is more like exterminate than pause-mode.
+ */
+void FastFactory::kill(BaseObject* object)
+{
+  FastObjectMember* tmpC;
+  if (unlikely(this->unusedContainers == NULL))
+  {
+    tmpC = new FastObjectMember;
+  }
+  else
+  {
+    tmpC = this->unusedContainers;
+    this->unusedContainers = this->unusedContainers->next;
+  }
+
+  tmpC->next = this->deadList;
+  tmpC->objectPointer = object;
+  this->deadList = tmpC;
+}
+
+
+void FastFactory::kill(BaseObject* object, bool searchForFastFactory)
+{
+  if (likely(searchForFastFactory == true))
+  {
+    FastFactory* tmpFac = FastFactory::first;
+    while (tmpFac != NULL)
+    {
+      if (object->isA(tmpFac->storedClassID))
+      {
+        tmpFac->kill(object);
+        return;
+      }
+      tmpFac = tmpFac->next;
+    }
+  }
+}
Index: trunk/src/lib/util/loading/fast_factory.h
===================================================================
--- trunk/src/lib/util/loading/fast_factory.h	(revision 9869)
+++ trunk/src/lib/util/loading/fast_factory.h	(revision 9869)
@@ -0,0 +1,176 @@
+/*!
+ * @file fast_factory.h
+ * The ObjectManager (FastFactory) is designed, to automatically generate and remove
+ * (without to much overhead) many instances of different classes.
+ *
+ * It is especially usefull for objects, that come only for a short time into existence,
+ * and get killed after a small amount of time (like shots).
+ *
+ * The Creation of an Object is usually done in the Weapon Class, where one subscribes
+ * a Projectile with:
+ * this->bulletFactory = tFastFactory<TestBullet>::getFastFactory(CL_TEST_BULLET, "TestBullet");
+ * (this might change over time).
+ * Then you can at loading time initialize an amount of the class with something like:
+ * this->bulletFactory->prepare(100); // creates 100 entities of TestBullet (dead ones)
+ * afterwards one can just retrieve an Object form the Class with
+ * this->bulletFactory->resurrect();  // this returns a BaseObject an Object of the class.
+ *
+ * The big difference to the FastFactory-class is, that this one is used more for the purpose
+ * of fast game-interaction than for loading. althought one can also load FastFactorized classes
+ * it is not the main topic.
+ */
+
+#ifndef _FAST_FACTORY_H
+#define _FAST_FACTORY_H
+
+#include "base_object.h"
+/**
+ * Creates a FastFactory to a Createable FastFactory.
+ */
+#define CREATE_FAST_FACTORY(CLASS_NAME, CLASS_ID) \
+  FastFactory* global_##CLASS_NAME##_FastFactory = tFastFactory<CLASS_NAME>::getFastFactory(CLASS_ID, #CLASS_NAME)
+/**
+ * Creates a FastFactory for a Class' static function named ClassName::fastFactory.
+ * @param CLASS_NAME the name of the Class to create the fast-factory for.
+ * @param CLASS_ID the ID of the class to create the fast-factory for @see "class_id_DEPRECATED.h"
+ *
+ * notice, that the Class to be called, must implement:
+ * static FastFactory*         fastFactory;
+ */
+#define CREATE_FAST_FACTORY_STATIC(CLASS_NAME) \
+  FastFactory* CLASS_NAME::fastFactory = tFastFactory<CLASS_NAME>::getFastFactory(CLASS_NAME::staticClassID(), #CLASS_NAME)
+
+//! A struct, that holds Lists of Objects of a certain type.
+typedef struct FastObjectMember
+{
+  BaseObject*          objectPointer;      //!< Pointer to the Object Stored in this Class (if it is the DeadList, else it is bork)
+
+  FastObjectMember*    next;               //!< the next stored FastObjectMember. (or NULL if this is the last one stored in either the deadList or the unusedContainers)
+};
+
+//! The FastFactory is a fast loadable object creator, and Dynamic List of dead object handler.
+/**
+ * The ObjectManager (FastFactory) is designed, to automatically generate and remove
+ * (without to much overhead) many instances of different classes.
+ *
+ * FastFactory is needed to glue all the tFastFactories together.
+ * It is also the general class that implements the necessary functions
+ * to generate, resurrect kill and stuff...
+ */
+class FastFactory : public BaseObject
+{
+  ObjectListDeclaration(FastFactory);
+
+public:
+  virtual ~FastFactory ();
+  static void deleteAll();
+
+  // functions to push and pop elements of this class
+  BaseObject* resurrect();
+  static BaseObject* resurrect(const ClassID& classID);
+  void kill(BaseObject* object);
+  static void kill(BaseObject* object, bool searchForFastFactory);
+
+  void prepare(unsigned int count);
+
+  static void flushAll(bool hardFLUSH = false);
+  void flush(bool hardFLUSH = false);
+
+  /** @returns the first FastFactory */
+  inline static FastFactory* getFirst() { return FastFactory::first; };
+
+  static FastFactory* searchFastFactory(const ClassID& classID);
+  static FastFactory* searchFastFactory(const std::string& fastFactoryName);
+
+  const ClassID& getStoredID() const { return this->storedClassID; };
+
+protected:
+  FastFactory (const ClassID& classID, const std::string& fastFactoryName = "");
+
+  /** sets the Next factory in the list @param nextFactory the next factory */
+  inline void setNext( FastFactory* nextFastFactory) { this->next = nextFastFactory; };
+  /** @returns the next FastFactory */
+  FastFactory* getNext() const { return this->next; };
+
+  /** generates a new Object of the Class T */
+  virtual void fabricate() = 0;
+
+private:
+  static void registerFastFactory(FastFactory* fastFactory);
+
+protected:
+  ClassID            storedClassID;        //!< The classID of the specified class.
+  unsigned int          storedDeadObjects;    //!< How many dead objects are stored in this class
+
+  FastObjectMember*     deadList;             //!< A List of all stored dead Objects of this class.
+  FastObjectMember*     unusedContainers;     //!< This is a List of unused containers, that will be reused by kill.
+
+private:
+  static FastFactory*   first;                //!< A pointer to the first FastFactory.
+
+  FastFactory*          next;                 //!< pointer to the next FastFactory.
+};
+
+
+
+/**
+ *  a FastFactory that is able to load any kind of Object from a ClassID
+ * (this is a Functor)
+ */
+template<class T>
+class tFastFactory : public FastFactory
+{
+public:
+  static tFastFactory<T>* getFastFactory(const ClassID& classID, const std::string& fastFactoryName);
+
+private:
+  tFastFactory(const ClassID& classID, const std::string& fastFactoryName);
+
+  virtual void fabricate();
+};
+
+/**
+ * construnts a FastFactory with
+ * @param fastFactoryName the name of the FastFactory
+ * @param fastFactory the ID of the class
+ * @todo (can this be written in another form??)
+ */
+template<class T>
+tFastFactory<T>::tFastFactory(const ClassID& classID, const std::string& fastFactoryName)
+    : FastFactory(classID, fastFactoryName)
+{}
+
+/**
+ * creates (if not existent) a Factory of Class T, and assigns some values to it
+ * @param classID the ClassID to assign to this class
+ * @param fastFactoryName the name to assign
+ * @returns The FastFactory if existent a new Factory if not.
+ */
+template<class T>
+tFastFactory<T>* tFastFactory<T>::getFastFactory(const ClassID& classID, const std::string& fastFactoryName)
+{
+  tFastFactory<T>* tmpFac = NULL;
+  if (FastFactory::getFirst() != NULL)
+    tmpFac = static_cast<tFastFactory<T>*>(FastFactory::getFirst()->searchFastFactory(classID));
+
+  if (tmpFac != NULL)
+    return tmpFac;
+  else
+    return new tFastFactory<T>(classID, fastFactoryName);
+}
+
+/**
+ * fabricates an Object of Class T, that corresponds to classID.
+ */
+template<class T>
+void tFastFactory<T>::fabricate()
+{
+  FastObjectMember* tmpFirstDead = new FastObjectMember;
+  tmpFirstDead->objectPointer = new T();
+  tmpFirstDead->next = this->deadList;
+  ++this->storedDeadObjects;
+
+  this->deadList = tmpFirstDead;
+}
+
+#endif /* _FAST_FACTORY_H */
Index: trunk/src/lib/util/loading/game_loader.cc
===================================================================
--- trunk/src/lib/util/loading/game_loader.cc	(revision 9675)
+++ trunk/src/lib/util/loading/game_loader.cc	(revision 9869)
@@ -20,18 +20,11 @@
 #include "game_loader.h"
 #include "util/loading/load_param.h"
-
-#include "shell_command.h"
+#include "util/loading/resource_manager.h"
+#include "debug.h"
 #include "campaign.h"
 
-#include "util/loading/resource_manager.h"
-
 #include "key_mapper.h"
 
-
-
-SHELL_COMMAND(quit, GameLoader, stop)
-->describe("quits the game")
-->setAlias("orxoquit");
-
+ObjectListDefinition(GameLoader);
 
 GameLoader* GameLoader::singletonRef = NULL;
@@ -43,5 +36,5 @@
 GameLoader::GameLoader ()
 {
-  this->setClassID(CL_GAME_LOADER, "GameLoader");
+  this->registerObject(this, GameLoader::_objectList);
   this->setName("GameLoader");
   this->bRun = true;
@@ -57,5 +50,5 @@
     delete this->currentCampaign;
   this->currentCampaign = NULL;
-  
+
   GameLoader::singletonRef = NULL;
 }
@@ -90,5 +83,5 @@
 {
   ErrorMessage errorCode;
-  std::string campaignName = ResourceManager::getFullName(fileName);
+  std::string campaignName = Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(fileName);
   if (!campaignName.empty())
   {
@@ -110,5 +103,5 @@
 {
   ErrorMessage errorCode;
-  std::string campaignName = ResourceManager::getFullName(fileName);
+  std::string campaignName = Resources::ResourceManager::getInstance()->prependAbsoluteMainPath(fileName);
   if (!campaignName.empty())
   {
Index: trunk/src/lib/util/loading/game_loader.h
===================================================================
--- trunk/src/lib/util/loading/game_loader.h	(revision 9675)
+++ trunk/src/lib/util/loading/game_loader.h	(revision 9869)
@@ -38,5 +38,6 @@
 class GameLoader : public EventListener
 {
- public:
+  ObjectListDeclaration(GameLoader);
+  public:
   virtual ~GameLoader ();
   /**  this class is a singleton class @returns an instance of itself  */
Index: trunk/src/lib/util/loading/load_param.cc
===================================================================
--- trunk/src/lib/util/loading/load_param.cc	(revision 9675)
+++ trunk/src/lib/util/loading/load_param.cc	(revision 9869)
@@ -16,21 +16,17 @@
 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_LOADING
 
-#include "util/loading/load_param.h"
-#include "load_param_description.h"
-
-#include <stdarg.h>
-
+#include "load_param.h"
+#include "load_param_class_description.h"
+#include "compiler.h"
+#include "debug.h"
 /**
- * Constructs a new LoadParameter
+ * @brief Constructs a new LoadParameter
  * @param root the XML-element to load this Parameter from
  * @param paramName the Parameter to load
- * @param object the BaseObject, to load this parameter on to (will be cast to executor's Parameter)
- * @param executor the Executor, that executes the loading procedure.
+ * @param inLoadCycle If we are in a LoadCycle (loading differs.).
  */
-CLoadParam::CLoadParam(const TiXmlElement* root, const std::string& paramName, BaseObject* object, Executor* executor, bool inLoadCycle)
-  :  object(object), paramName(paramName)
+LoadParamBase::LoadParamBase(const TiXmlElement* root, const std::string& paramName, bool inLoadCycle)
+    :  paramName(paramName), inLoadCycle(inLoadCycle)
 {
-  this->inLoadCycle = inLoadCycle;
-
   // determin the LoadString.
   if (likely(!inLoadCycle))
@@ -40,181 +36,29 @@
   else
     this->loadElem = NULL;
+}
 
-  // set the Executor.
-  this->executor = executor;
 
-  //if (this->executor)
-  //  this->executor->setName(paramName);
+/**
+ * @param classID the ID of the class. This is needed to identify into what class this Parameter belongs.
+ * @param descriptionText The text to set as a description for this Parameter
+ * @returns a pointer to itself.
+ */
+void LoadParamBase::describe(const ClassID& classID, const std::string& descriptionText)
+{
+  PRINTF(5)("Describing Class '%s'(id:%d) Parameter '%s': description '%s'\n",
+            classID.name().c_str(), classID.id(), paramName.c_str(), descriptionText.c_str());
+
+  if (LoadParamClassDescription::descriptionsCaptured())
+    LoadParamClassDescription::describeClass(classID, paramName, descriptionText);
 }
 
 /**
- * This is a VERY SPECIAL deconsrtuctor.
- * It is made, so that it loads the Parameters on destruction.
- * meaning, if an Executor a valid Object exist, and all
- * Execution-Conditions are met, they are executed here.
+ * @brief sets the Values of the Description to a usefull text.
  */
-CLoadParam::~CLoadParam()
+void LoadParamBase::setDescriptionValues(const ClassID& classID, unsigned int paramCount, const MultiType* const defaultValues, bool retVal)
 {
-  if (likely(this->executor != NULL))
-  {
-    std::string loadString = "";
-    if (this->loadElem != NULL &&  this->loadElem->ToText())
-      loadString = this->loadElem->Value();
-    if (likely(this->object != NULL) &&
-        ( !loadString.empty() ||
-          ((this->executor->getType() & Executor_NoLoadString) == Executor_NoLoadString)))
-    {
-      PRINTF(4)("Loading value '%s' with Parameters '%s' onto: %s::%s\n", this->paramName.c_str(), loadString.c_str(), this->object->getClassCName(), this->object->getCName());
-      (*this->executor)(this->object, SubString(loadString, ",", SubString::WhiteSpaces, false, '\\'));
-    }
-    delete this->executor;
-  }
+  if(LoadParamClassDescription::descriptionsCaptured())
+    LoadParamClassDescription::setValuesOf(classID, paramName, paramCount, defaultValues, retVal);
 }
-
-/**
- * @brief set the default values of the executor
- * @param value0 the first default value
- * @param value1 the second default value
- * @param value2 the third default value
- * @param value3 the fourth default value
- * @param value4 the fifth default value
- */
-CLoadParam& CLoadParam::defaultValues(const MultiType& value0, const MultiType& value1,
-                                      const MultiType& value2, const MultiType& value3,
-                                      const MultiType& value4)
-{
-  assert(this->executor != NULL);
-  this->executor->defaultValues(value0, value1, value2, value3, value4);
-
-  return *this;
-}
-
-
-
-/**
- * @param descriptionText The text to set as a description for this Parameter
- * @returns a pointer to itself.
-*/
-CLoadParam& CLoadParam::describe(const std::string& descriptionText)
-{
-  if (LoadClassDescription::parametersDescription && this->paramDesc && this->paramDesc->getDescription().empty())
-  {
-    this->paramDesc->setDescription(descriptionText);
-  }
-  return *this;
-}
-
-// const LoadParamDescription* LoadParamDescription::getClass(const char* className)
-// {
-//   tIterator<LoadClassDescription>* iterator = LoadClassDescription::classList->getIterator();
-//   LoadClassDescription* enumClassDesc = iterator->firstElement();
-//   while (enumClassDesc)
-//   {
-//     if (!strcmp(enumClassDesc->className, classNameBegin, className))
-//     {
-//       delete iterator;
-//       return enumClassDesc;
-//     }
-//     enumClassDesc = iterator->nextElement();
-//   }
-//   delete iterator;
-//
-//   return NULL;
-// }
-
-
-
-
-/*
- * @param object The object this Parameter is loaded too.
- * @param root: the XML-element to load this option from.
- * @param paramName: The name of the parameter loaded.
- * @param paramCount: how many parameters this loading-function takes
- * @param multi: if false LoadParam assumes only one occurence of this parameter in root, if true it assumes multiple occurences.
- * @param ...: the parameter information (1. Parameter, 2. Default Value for the Parameter, ...)
-*/
-/*LoadParam::LoadParam(const TiXmlElement* root, BaseObject* object, const char* paramName,
-                             int paramCount, bool multi, const void* pointerToParam, ...)
-{
-  this->setClassID(CL_LOAD_PARAM, "LoadParam");
-  this->executor = NULL;
-
-  this->loadString = NULL;
-  this->pointerToParam = pointerToParam;
-
-  if (paramCount == 0 || this->pointerToParam != NULL)
-    this->loadString = "none";
-  else
-{
-      if (likely(!multi))
-        this->loadString = grabParameter(root, paramName);
-      else
-{
-          if (!strcmp(root->Value(), paramName))
-{
-              const TiXmlNode* val = root->FirstChild();
-              if( val->ToText())
-                this->loadString = val->Value();
-}
-}
-}
-
-  this->paramDesc = NULL;
-  if (LoadClassDescription::parametersDescription)
-{
-    // locating the class
-    this->classDesc = LoadClassDescription::addClass(object->getClassCName());
-
-    if ((this->paramDesc = this->classDesc->addParam(paramName)) != NULL)
-{
-
-      this->paramDesc->paramCount = paramCount;
-      this->paramDesc->types = new int[paramCount];
-      this->paramDesc->defaultValues = new char*[paramCount];
-
-      va_list types;
-      va_start (types, pointerToParam);
-      char defaultVal[512];
-      for(int i = 0; i < paramCount; i++)
-{
-        defaultVal[0] = '\0';
-          // parameters parsed
-        int tmpType = va_arg (types, int);
-        this->paramDesc->types[i] = tmpType;
-        switch (tmpType)
-{
-  case MT_INT:
-            sprintf(defaultVal, "%d", va_arg(types, int));
-            break;
-//          case MT_LONG:
-//            sprintf(defaultVal, "%0.3f", va_arg(types, l_LONG_TYPE));
-//            break;
-  case MT_FLOAT:
-            sprintf(defaultVal, "%0.3f", va_arg(types, double));
-            break;
-  case MT_STRING:
-            sprintf(defaultVal, "%s", va_arg(types, l_STRING_TYPE));
-            break;
-  case MT_EXT1:
-            sprintf(defaultVal, "");
-            break;
-}
-        this->paramDesc->defaultValues[i] = new char[strlen(defaultVal)+1];
-        strcpy(this->paramDesc->defaultValues[i], defaultVal);
-}
-      va_end(types);
-
-      int argCount = 0;
-}
-}
-}*/
-
-
-
-
-
-
-
-
 
 
@@ -227,22 +71,14 @@
  * @returns the Value of the parameter if found, NULL otherwise
 */
-std::string grabParameter(const TiXmlElement* root, const std::string& parameterName)
+std::string LoadParamBase::grabParameter(const TiXmlElement* root, const std::string& parameterName)
 {
-  const TiXmlElement* element;
-  const TiXmlNode* node;
-
-  if (root == NULL)
-    return "";
-
-  element = root->FirstChildElement( parameterName);
-  if( element == NULL) return "";
-
-  node = element->FirstChild();
-  while( node != NULL)
+  const TiXmlElement* const element = grabParameterElement(root, parameterName);
+  if (element != NULL)
+    return element->Value();
+  else
   {
-    if( node->ToText()) return node->Value();
-    node = node->NextSibling();
+    static std::string empty("");
+    return empty;
   }
-  return "";
 }
 
@@ -252,5 +88,5 @@
  * @returns the Element of the parameter if found, NULL otherwise
  */
-const TiXmlElement* grabParameterElement(const TiXmlElement* root, const std::string& parameterName)
+const TiXmlElement* LoadParamBase::grabParameterElement(const TiXmlElement* root, const std::string& parameterName)
 {
   const TiXmlElement* element;
@@ -271,5 +107,2 @@
   return NULL;
 }
-
-
-
Index: trunk/src/lib/util/loading/load_param.h
===================================================================
--- trunk/src/lib/util/loading/load_param.h	(revision 9675)
+++ trunk/src/lib/util/loading/load_param.h	(revision 9869)
@@ -22,18 +22,18 @@
 #define _LOAD_PARAM_H
 
-#include "base_object.h"
+#include "util/executor/executor_substring.h"
+#include "util/executor/executor_member.h"
+#include "util/executor/functor_member.h"
 
-#include "executor/executor.h"
-#include "executor/executor_xml.h"
+#include "parser/tinyxml/tinyxml.h"
 
 // Forward Declaration //
 class LoadClassDescription;
 class LoadParamDescription;
-class MultiType;
-
+class TiXmlElement;
 
 /**
  * Loads a Parameter from ROOT named PARAMETER_NAME
- * onto OBJECT of CLASS, trough the FUNCTION
+ * onto OBJECT of CLASS, trough FUNCTION
  * @param ROOT the TiXmlElement to load the Parameter from
  * @param PARAMETER_NAME the Name of the Parameter to load
@@ -43,15 +43,16 @@
  */
 #define LoadParam(ROOT, PARAMETER_NAME, OBJECT, CLASS, FUNCTION) \
-         CLoadParam(ROOT, PARAMETER_NAME, OBJECT, createExecutor<CLASS>(&CLASS::FUNCTION), false)
+         CLoadParam<CLASS>(ROOT, PARAMETER_NAME, OBJECT, createExecutor<CLASS, CLASS>(&CLASS::FUNCTION), false)
 
+/**
+ * @brief Does essentially the same as LoadParam, but within a Cycle in an ordered fashion.
+ *
+ * This Function looks in each Element, if the PARAMETER_NAME matches, and loads onto OBJECT
+ * of CLASS the ROOT through FUNCTION
+ *
+ * @see LoadParam(ROOT, PARAMETER_NAME, OBJECT, CLASS, FUNCTION)
+ */
 #define LoadParam_CYCLE(ROOT, PARAMETER_NAME, OBJECT, CLASS, FUNCTION) \
-         CLoadParam(ROOT, PARAMETER_NAME, OBJECT, createExecutor<CLASS>(&CLASS::FUNCTION), true)
-
-#define LoadParamXML(ROOT, PARAMETER_NAME, OBJECT, CLASS, FUNCTION) \
-         CLoadParam(ROOT, PARAMETER_NAME, OBJECT, new ExecutorXML<CLASS>(&CLASS::FUNCTION, ROOT, PARAMETER_NAME), false)
-
-#define LoadParamXML_CYCLE(ROOT, PARAMETER_NAME, OBJECT, CLASS, FUNCTION) \
-         CLoadParam(ROOT, PARAMETER_NAME, OBJECT, new ExecutorXML<CLASS>(&CLASS::FUNCTION, ROOT, PARAMETER_NAME), true)
-
+         CLoadParam<CLASS>(ROOT, PARAMETER_NAME, OBJECT, createExecutor<CLASS, CLASS>(&CLASS::FUNCTION), true)
 
 /**
@@ -78,39 +79,81 @@
 }
 
+
 /**************************
 **** REAL DECLARATIONS ****
 **************************/
-//! abstract Base class for a Loadable parameter
-class CLoadParam : public BaseObject
+//!< A BaseClass for all LoadParam's.
+class LoadParamBase
 {
-  public:
-    CLoadParam(const TiXmlElement* root, const std::string& paramName, BaseObject* object, Executor* executor, bool inLoadCycle = false);
-    virtual ~CLoadParam();
+protected:
+  LoadParamBase(const TiXmlElement* root, const std::string& paramName, bool inLoadCycle = false);
 
-    CLoadParam& describe(const std::string& descriptionText);
-    CLoadParam& defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL,
-                              const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL,
-                              const MultiType& value4 = MT_NULL);
-    CLoadParam& attribute(const std::string& attributeName, const Executor& executor);
+protected:
+  void describe(const ClassID& classID, const std::string& descriptionText);
+  void setDescriptionValues(const ClassID& classID, unsigned int paramCount, const MultiType* const defaultValues, bool retVal = false);
+
+public:
+  static std::string grabParameter(const TiXmlElement* root, const std::string& parameterName);
+  static const TiXmlElement* grabParameterElement(const TiXmlElement* root, const std::string& parameterName);
+
+protected:
+  const std::string        paramName;            //!< The Name of the Parameter this LoadParams applies to.
+  bool                     inLoadCycle;          //!< If the Parameter is in a LoadCycle.
+
+  const TiXmlElement*      loadElem;             //!< The Element to load.
+};
 
 
-  private:
-    bool                     inLoadCycle;
-    Executor*                executor;
-    BaseObject*              object;
-    const std::string        paramName;
+//! The Loading Class of the LoadParam, that acctually executes the loading process.
+template <class OperateClass> class CLoadParam : public LoadParamBase
+{
+public:
+  /**
+   * @brief generates a LoadParam based on:
+   * @param root the Root Element to load onto the object. @param paramName the Parameter name that is loaded.
+   * @param object the Object to apply the changes on. @param executor the Functional Object, that actually executes the function Call.
+   * @param inLoadCycle If we are inside of a loading cycle. (Loading will be different here)
+   */
+  CLoadParam(const TiXmlElement* root, const std::string& paramName, OperateClass* object, Executor<const SubString, OperateClass>* executor, bool inLoadCycle = false)
+      : LoadParamBase(root, paramName, inLoadCycle)
+  {
+    assert (executor != NULL);
+    this->object = object;
+    this->executor = executor;
+  }
+  virtual ~CLoadParam()
+  {
+    std::string loadString;
+    if (this->loadElem != NULL &&  this->loadElem->ToText())
+    {
+      loadString = this->loadElem->Value();
+      if (!loadString.empty())
+      {
+        /*	PRINTF(4)("Loading value '%s' with Parameters '%s' onto: %s::%s\n",
+        	this->paramName.c_str(), loadString.c_str(), this->object->getClassCName(), this->object->getCName());*/
+        (*this->executor)(this->object, SubString(loadString, ",", SubString::WhiteSpaces, false, '\\'));
+      }
+    }
+    this->setDescriptionValues(OperateClass::staticClassID(), executor->getParamCount(), executor->getDefaultValues(), executor->hasRetVal());
+    delete this->executor;
+  }
+  /**
+   * @brief set the default values of the executor
+   * @param value0 the first default value   @param value1 the second default value
+   * @param value2 the third default value   @param value3 the fourth default value
+   * @param value4 the fifth default value
+   */
+  CLoadParam& defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL,
+                            const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL,
+                            const MultiType& value4 = MT_NULL)
+  { this->executor->defaultValues(value0, value1, value2, value3, value4); return *this;  };
+  //! Describes a LoadParam
+  CLoadParam& describe(const std::string& descriptionText) { LoadParamBase::describe(OperateClass::staticClassID(), descriptionText); return *this; };
+  //     CLoadParam& attribute(const std::string& attributeName, const Executor<SubString>& executor);
 
-    LoadClassDescription*    classDesc;            //!< The LoadClassDescription of this CLoadParameter
-    LoadParamDescription*    paramDesc;            //!< The LoadParameterDescription of this LoadParameter
-    const TiXmlElement*      loadElem;             //!< The Element to load.
-    const void*              pointerToParam;       //!< A Pointer to a Parameter.
-
-    MultiType*               defaultValue;
+private:
+  Executor<const SubString, OperateClass>*         executor;            //!< The Executor, that actually executes the Loading process.
+  OperateClass*                                    object;              //!< The Object this LoadParam operates on.
 };
 
-// helper function
-
-std::string grabParameter(const TiXmlElement* root, const std::string& parameterName);
-const TiXmlElement* grabParameterElement(const TiXmlElement* root, const std::string& parameterName);
-
 #endif /* _LOAD_PARAM_H */
Index: trunk/src/lib/util/loading/load_param_class_description.cc
===================================================================
--- trunk/src/lib/util/loading/load_param_class_description.cc	(revision 9869)
+++ trunk/src/lib/util/loading/load_param_class_description.cc	(revision 9869)
@@ -0,0 +1,171 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: Benjamin Grauer
+   co-programmer: ...
+*/
+
+#include "load_param_class_description.h"
+
+#include "multi_type.h"
+#include "debug.h"
+#include <cassert>
+
+/**
+ * @brief A list, that holds all the classes that are loadable (classes not objects!!)
+ */
+LoadParamClassDescription::ClassDescriptionMap LoadParamClassDescription::_classList;
+
+/**
+ * @brief if the description of Parameters should be executed
+ */
+bool LoadParamClassDescription::_captureDescriptions = false;
+
+/**
+ * @param className the name of the class to be loadable
+ */
+LoadParamClassDescription::LoadParamClassDescription(const std::string& className)
+    : _className(className)
+{ }
+
+
+/**
+ * @brief clears all LoadParamDescriptions.
+ */
+void LoadParamClassDescription::deleteAllDescriptions()
+{
+  LoadParamClassDescription::_classList.clear();
+}
+
+
+/**
+ * @brief describes a LoadParam-parameter.
+ * @param classID the ID of the class.
+ * @param paramName the Name of the Parameter.
+ * @param descriptionText the Test to set.
+ */
+void LoadParamClassDescription::describeClass(const ClassID& classID,
+    const std::string& paramName,
+    const std::string& descriptionText)
+{
+  ParamDescriptionMap::iterator it = LoadParamClassDescription::getParamDescription(classID, paramName);
+
+  (*it).second.setDescription(descriptionText);
+}
+
+/**
+ * @brief sets Values of the specified LoadParam-parameter.
+ * @param classID the ID of the class.
+ * @param paramName the name of the Parameter.
+ * @param paramCount the count of Parameters this LoadParam takes.
+ * @param defaultValues the default Values.
+ * @param retVal if the Parameter takes return Values.
+ */
+void LoadParamClassDescription::setValuesOf(const ClassID& classID,
+    const std::string& paramName,
+    unsigned int paramCount,
+    const MultiType* const defaultValues,
+    bool retVal)
+{
+  ParamDescriptionMap::iterator it = LoadParamClassDescription::getParamDescription(classID, paramName);
+  (*it).second.setValues(paramCount, defaultValues, retVal);
+}
+
+
+/**
+ * @brief finds the Iterator to the ParameterDescription paramName matching classID
+ * @param classID the ClassID to match.
+ * @param paramName the name of the parameter in the Class.
+ * @returns the iterator on match.
+ *
+ * @note this function creates the Element classID.name()::paramName on the go if it does not exist.
+ */
+LoadParamClassDescription::ParamDescriptionMap::iterator
+LoadParamClassDescription::getParamDescription(const ClassID& classID, const std::string& paramName)
+{
+  /// Locate the ClassDescription first
+  ClassDescriptionMap::iterator classIt = LoadParamClassDescription::_classList.find(classID);
+  if (classIt == LoadParamClassDescription::_classList.end())
+  {
+    LoadParamClassDescription::_classList[classID] = LoadParamClassDescription(classID.name());
+    classIt = LoadParamClassDescription::_classList.find(classID);
+  }
+  // At this position the class-iterator should point to a valid usefull position.
+  assert(classIt != LoadParamClassDescription::_classList.end());
+
+  /// Now locate the description with paramName.
+  ParamDescriptionMap::iterator paramIt = (*classIt).second._parameters.find(paramName);
+  if (paramIt == (*classIt).second._parameters.end())
+  {
+    (*classIt).second._parameters[paramName] = LoadParamDescription(paramName);
+    paramIt = (*classIt).second._parameters.find(paramName);
+  }
+  // at this position the param-iterator should
+  assert (paramIt != (*classIt).second._parameters.end());
+
+  return (paramIt);
+}
+
+/**
+ * @brief prints out a nice output about this Classes Loading, and their parameters
+ * @param stream the stream to write to.
+ * @param withComments if Comments should be included.
+ */
+void LoadParamClassDescription::print(FILE* stream, bool withComments) const
+{
+  fprintf(stream, "<%s>\n", this->_className.c_str());
+  for (ParamDescriptionMap::const_iterator param = this->_parameters.begin();
+       param != this->_parameters.end();
+       ++param)
+  {
+    (*param).second.print(stream, withComments);
+  }
+  fprintf(stream, "</%s>\n\n", this->_className.c_str());
+}
+
+
+/**
+ * @brief prints out all loadable Classes, and their parameters
+ * @param fileName prints the output to a File
+ * @param withComments if Comments should be included.
+ */
+void LoadParamClassDescription::printAll(const std::string& fileName, bool withComments)
+{
+  FILE* stream;
+  if( (stream = fopen (fileName.c_str(), "w")) == NULL)
+  {
+    PRINTF(2)("File '%s' could not be opened for writing\n Printing to stdout\n", fileName.c_str());
+    LoadParamClassDescription::printAllTo(stdout, withComments);
+    return;
+  }
+  else
+    LoadParamClassDescription::printAllTo(stream, withComments);
+
+  fclose (stream);
+}
+
+/**
+ * @brief prints out all loadable Classes, and their parameters to a stream
+ * @param stream the stream to print to.
+ * @param withComments if Comments should be included.
+ */
+void LoadParamClassDescription::printAllTo(FILE* stream, bool withComments)
+{
+  fprintf(stream, "===============================================================\n");
+  fprintf(stream, " Listing all the Loadable Options (loaded since Game started).\n\n");
+  for (ClassDescriptionMap::const_iterator classIt = LoadParamClassDescription::_classList.begin();
+       classIt != LoadParamClassDescription::_classList.end();
+       classIt ++)
+  {
+    (*classIt).second.print(stream, withComments);
+  }
+  fprintf(stream, "===============================================================\n");
+}
Index: trunk/src/lib/util/loading/load_param_class_description.h
===================================================================
--- trunk/src/lib/util/loading/load_param_class_description.h	(revision 9869)
+++ trunk/src/lib/util/loading/load_param_class_description.h	(revision 9869)
@@ -0,0 +1,84 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: Benjamin Grauer
+   co-programmer: ...
+*/
+
+/*!
+ * @file load_param_class_description.h
+ * A Class and macro-functions, that makes our lives easy to load-in parameters
+ */
+
+#ifndef _LOAD_PARAM_CLASS_DESCRIPTION_H
+#define _LOAD_PARAM_CLASS_DESCRIPTION_H
+
+#include "load_param_description.h"
+#include "class_id.h"
+#include <map>
+// Forward Declaration //
+class MultiType;
+
+//! A class for descriptions of a loadable module
+class LoadParamClassDescription
+{
+public:
+  LoadParamClassDescription(const std::string& className = "");
+
+  //! Compares a LoadParamClassDescription with a String.
+  bool operator==(const std::string& className) const { return this->_className == className; };
+  //! Compares two LoadParamClassDescription with each other
+  bool operator==(const LoadParamClassDescription& classDescr) const { return this->_className == classDescr._className; };
+  //! Compares two LoadParamClassDescription with each other, using the less operator
+  bool operator<(const LoadParamClassDescription& classDescr) const { return this->_className < classDescr._className; }
+
+
+  static void describeClass(const ClassID& classID,
+                            const std::string& paramName,
+                            const std::string& descriptionText);
+  static void setValuesOf(const ClassID& classID,
+                          const std::string& paramName,
+                          unsigned int paramCount,
+                          const MultiType* const defaultValues,
+                          bool retVal = false);
+
+  /** @param createThem: if the Parameters should be created/stored. */
+  static void captureDescriptions(bool createThem) { _captureDescriptions = createThem; };
+  /** @returns if the Parameters are created/stored. */
+  static bool descriptionsCaptured() { return _captureDescriptions; };
+
+  static void deleteAllDescriptions();
+
+  void print(FILE* stream = stdout, bool withComments = true) const;
+  static void printAll(const std::string& fileName = "", bool withComments = true);
+  static void printAllTo(FILE* stream = stdout, bool withComments = true);
+
+private:
+  //! A Type definition for the Map of Class Descriptions
+  typedef std::map<ClassID, LoadParamClassDescription>  ClassDescriptionMap;
+  //! A type definition for the Map of Parameter Descriptions inside of Class-descriptions.
+  typedef std::map<std::string, LoadParamDescription>   ParamDescriptionMap;
+
+private:
+  static ParamDescriptionMap::iterator getParamDescription(const ClassID& classID, const std::string& paramName);
+
+private:
+
+  static bool                                  _captureDescriptions;    //!< if parameter-description should be enabled globally.
+
+  static ClassDescriptionMap                   _classList;              //!< a list, that stores all the loadable classes. (after one instance has been loaded)
+
+private:
+  std::string                                  _className;              //!< name of the class
+  ParamDescriptionMap                          _parameters;             //!< List of parameters this class knows.
+};
+
+#endif /* _LOAD_PARAM_CLASS_DESCRIPTION_H */
Index: trunk/src/lib/util/loading/load_param_description.cc
===================================================================
--- trunk/src/lib/util/loading/load_param_description.cc	(revision 9675)
+++ trunk/src/lib/util/loading/load_param_description.cc	(revision 9869)
@@ -17,33 +17,13 @@
 
 #include "multi_type.h"
-#include <stdarg.h>
 #include "debug.h"
 
 /**
+ * @brief Creates a Description of a LoadParam
  * @param paramName the name of the parameter to load
  */
 LoadParamDescription::LoadParamDescription(const std::string& paramName)
-{
-  this->types = NULL;
-  this->defaultValues = NULL;
-  this->paramName = paramName;
-}
-
-/**
- *  removes all the alocated memory
- */
-LoadParamDescription::~LoadParamDescription()
-{
-  if (this->defaultValues != NULL)
-  {
-    for(int i = 0; i < this->paramCount; i++)
-    {
-      delete[] this->defaultValues[i];
-    }
-  }
-
-  delete[] this->types;
-  delete[] this->defaultValues;
-}
+    : _name(paramName), _parameterCount(0)
+{ }
 
 /**
@@ -52,229 +32,71 @@
 void LoadParamDescription::setDescription(const std::string& descriptionText)
 {
-  this->description = descriptionText;
+  this->_description = descriptionText;
 }
 
 /**
- *  prints out this parameter, its input method and the description (if availiable)
+ * @brief sets the Values of the LoadParam in the Description.
+ * @param paramCount the count of arguments the underlying paramDescription takes.
+ * @param defaultValues the default Values the underlying parameter takes.
+ * @param retVal if the underlying parameter has a return value
  */
-void LoadParamDescription::print() const
+void LoadParamDescription::setValues(unsigned int paramCount,
+                                     const MultiType* const defaultValues,
+                                     bool retVal)
 {
-  PRINT(3)(" <%s>", this->paramName.c_str());
-  for (int i = 0; i < this->paramCount; i++)
+  this->_parameterCount = paramCount;
+  for (unsigned int i = 0; i < paramCount; ++i)
   {
-    if (i > 0)
-      PRINT(3)(",");
-    // FIXME
-    //     switch (this->types[i])
-//     {
-//       default:
-//         PRINTF(3)("none");
-//         break;
-//       case ParameterBool:
-//         PRINT(3)("bool");
-//         break;
-//       case ParameterChar:
-//         PRINT(3)("char");
-//         break;
-//       case ParameterString:
-//         PRINT(3)("string");
-//         break;
-//       case ParameterInt:
-//         PRINT(3)("int");
-//         break;
-//       case ParameterUInt:
-//         PRINT(3)("Uint");
-//         break;
-//       case ParameterFloat:
-//         PRINT(3)("float");
-//         break;
-//       case ParameterLong:
-//         PRINT(3)("long");
-//         break;
-//       case ParameterXML:
-//         PRINT(3)("XML");
-//         break;
-//     }
+    this->_defaultValues.push_back(defaultValues[i].getString());
+    this->_types.push_back(MultiType::MultiTypeToString(defaultValues[i].getType()));
   }
-  PRINT(3)("</%s>", this->paramName.c_str());
-  if (!this->description.empty())
-    PRINT(3)(" -- %s", this->description.c_str());
-  // default values
-  if (this->paramCount > 0)
-  {
-    PRINT(3)(" (Default: ");
-    for (int i = 0; i < this->paramCount; i++)
-    {
-      if (i > 0)
-        PRINT(3)(", ");
-      if (this->types[i] & MT_STRING)
-      { // leave brackets !!
-        PRINT(3)("\"%s\"", this->defaultValues[i]);
-      }
-      else
-      {
-        PRINT(3)("%s", this->defaultValues[i]);
-      }
-    }
-    PRINT(3)(")");
-  }
-  PRINT(3)("\n");
-}
 
-/**
- *  A list, that holds all the classes that are loadable (classes not objects!!)
- */
-std::list<LoadClassDescription*>* LoadClassDescription::classList = NULL;
-
-/**
- *  if the description of Parameters should be executed
- */
-bool LoadClassDescription::parametersDescription = false;
-
-/**
- * @param className the name of the class to be loadable
- */
-LoadClassDescription::LoadClassDescription(const std::string& className)
-{
-  this->className = className;
-
-  if (LoadClassDescription::classList == NULL)
-    LoadClassDescription::classList = new std::list<LoadClassDescription*>;
-
-  LoadClassDescription::classList->push_back(this);
-}
-
-/**
- *  deletes a classDescription (deletes all the parameterDescriptions as well
- */
-LoadClassDescription::~LoadClassDescription()
-{
-  std::list<LoadParamDescription*>::iterator it = this->paramList.begin();
-  while (!this->paramList.empty())
-  {
-    delete this->paramList.front();
-    this->paramList.pop_front();
-  }
-}
-
-void LoadClassDescription::deleteAllDescriptions()
-{
-  if (LoadClassDescription::classList != NULL)
-  {
-    while (!LoadClassDescription::classList->empty())
-    {
-      delete LoadClassDescription::classList->front();
-      LoadClassDescription::classList->pop_front();
-    }
-    delete LoadClassDescription::classList;
-  }
-  LoadClassDescription::classList = NULL;
 }
 
 
 /**
- *  adds a class to the list of loadable classes
- * @param className The name of the class to add
-
-   this function searches for the className string, and if found just returns the appropriate Class.
-   Otherwise it returns a new classDescription
+ * @brief prints out this parameter, its input method and the description (if availiable)
+ * @param stream the stream to print to.
+ * @param withComments if the comments should be appended.
  */
-LoadClassDescription* LoadClassDescription::addClass(const std::string& className)
+void LoadParamDescription::print(FILE* stream, bool withComments) const
 {
-  if (LoadClassDescription::classList != NULL)
+  fprintf(stream, " <%s>", this->_name.c_str());
+  for (unsigned int i = 0; i < this->_parameterCount; i++)
   {
-    std::list<LoadClassDescription*>::iterator it = LoadClassDescription::classList->begin();
-    while (it != LoadClassDescription::classList->end())
+    if (i > 0)
+      fprintf(stream, ",");
+    fprintf(stream, "%s", this->_types[i].c_str());
+  }
+  fprintf(stream, "</%s>", this->_name.c_str());
+  // here the comments are printed out.
+  if (withComments)
+  {
+    if (!this->_description.empty())
+      fprintf(stream, " <!-- %s", this->_description.c_str());
+    // default values
+    if (this->_parameterCount > 0)
     {
-      if ((*it)->className == className)
+      fprintf(stream, " (Default: ");
+      for (unsigned int i = 0; i < this->_parameterCount; i++)
       {
-        return (*it);
+        if (i > 0)
+          fprintf(stream, ", ");
+        if (this->_types[i] == "string")
+        { // leave brackets !!
+          fprintf(stream, "\"%s\"", this->_defaultValues[i].c_str());
+        }
+        else
+        {
+          fprintf(stream, "%s", this->_defaultValues[i].c_str());
+        }
       }
-      it++;
+      fprintf(stream, ")");
     }
+    if (!this->_description.empty() || this->_parameterCount > 0)
+      fprintf(stream, " -->");
   }
-  return new LoadClassDescription(className);
+  fprintf(stream, "\n");
 }
 
-/**
- *  does the same as addClass(const std::string& className), but with params
- * @param paramName the name of the parameter to add.
- */
-LoadParamDescription* LoadClassDescription::addParam(const std::string& paramName)
-{
-  std::list<LoadParamDescription*>::iterator it = this->paramList.begin();
-  while (it != this->paramList.end())
-  {
-    if ((*it)->paramName == paramName)
-    {
-      return NULL;
-    }
-    it++;
-  }
 
-  LoadParamDescription* newParam = new LoadParamDescription(paramName);
-
-  this->paramList.push_back(newParam);
-  return newParam;
-}
-
-/**
- *  prints out all loadable Classes, and their parameters
- * @param fileName prints the output to a File
- * @todo implement it
- */
-void LoadClassDescription::printAll(const std::string& fileName)
-{
-  PRINT(3)("===============================================================\n");
-  PRINT(3)(" Listing all the Loadable Options (loaded since Game started).\n\n");
-  if (LoadClassDescription::classList != NULL)
-  {
-    std::list<LoadClassDescription*>::iterator classDesc = LoadClassDescription::classList->begin();
-    while (classDesc != LoadClassDescription::classList->end())
-    {
-      PRINT(3)("<%s>\n", (*classDesc)->className.c_str());
-      std::list<LoadParamDescription*>::iterator param = (*classDesc)->paramList.begin();
-      while (param != (*classDesc)->paramList.end())
-      {
-        (*param)->print();
-        param++;
-      }
-      PRINT(3)("</%s>\n\n", (*classDesc)->className.c_str());
-      classDesc++;
-    }
-  }
-  else
-    PRINT(3)("no Classes defined so far\n");
-  PRINT(3)("===============================================================\n");
-}
-
-/**
- * searches for classes, which beginn with classNameBegin
- * @param classNameBegin the beginning string of a Class
- * @return a NEW char-array with ClassNames. The LIST should be deleted afterwards,
- * !! The strings MUST NOT be deleted !!
- */
-std::list<std::string> LoadClassDescription::searchClassWithShort(const std::string& classNameBegin)
-{
-  /// FIXME
-  // NOT USED
-/*  unsigned int searchLength = strlen(classNameBegin);
-  std::list<const std::string&> retVal;
-
-  tIterator<LoadClassDescription>* iterator = LoadClassDescription::classList->getIterator();
-  LoadClassDescription* enumClassDesc = iterator->firstElement();
-  while (enumClassDesc)
-  {
-    if (strlen(enumClassDesc->className)>searchLength+1 &&
-        !strncasecmp(enumClassDesc->className, classNameBegin, searchLength))
-    {
-      retVal->add(enumClassDesc->className);
-    }
-    enumClassDesc = iterator->nextElement();
-  }
-  delete iterator;
-
-  return retVal;*/
-  std::list<std::string> a;
-  return a;
-}
Index: trunk/src/lib/util/loading/load_param_description.h
===================================================================
--- trunk/src/lib/util/loading/load_param_description.h	(revision 9675)
+++ trunk/src/lib/util/loading/load_param_description.h	(revision 9869)
@@ -15,5 +15,5 @@
 
 /*!
- * @file load_param.h
+ * @file load_param_description.h
  * A Class and macro-functions, that makes our lives easy to load-in parameters
  */
@@ -22,6 +22,6 @@
 #define _LOAD_PARAM_DESCRIPTION_H
 
-#include "base_object.h"
-#include <list>
+#include <vector>
+#include <string>
 
 // Forward Declaration //
@@ -34,47 +34,31 @@
 class LoadParamDescription
 {
-  friend class LoadParam;
-  friend class LoadClassDescription;
 public:
-  LoadParamDescription(const std::string& paramName);
-  ~LoadParamDescription();
+  LoadParamDescription(const std::string& paramName = "");
+
+  //! Compares a LoadParamDescription with a String.
+  bool operator==(const std::string& paramName) const { return this->_name == paramName; };
+  //! Compares two LoadParamDescription
+  bool operator==(const LoadParamDescription& paramDescr) const { return this->_name == paramDescr._name; };
+  //! Compares two LoadParamDescription with the less operator
+  bool operator<(const LoadParamDescription& paramDescr) const { return this->_name < paramDescr._name; };
 
   void setDescription(const std::string& descriptionText);
+  void setValues(unsigned int paramCount,
+                 const MultiType* const defaultValues,
+                 bool retVal = false);
+
   /** @returns the descriptionString */
-  const std::string& getDescription() { return this->description; };
+  const std::string& description() { return this->_description; };
 
-  void print() const;
+  void print(FILE* stream = stdout, bool withComments = true) const;
 
 private:
-  std::string   paramName;             //!< The name of the parameter.
-  int           paramCount;            //!< The count of parameters.
-  int*          types;                 //!< What kind of parameters does this function take ??
-  std::string   description;           //!< A longer description about this function.
-  char**        defaultValues;         //!< The 'Default Values'. @TODO MAKE THIS A MULTITYPE
-};
+  std::string                _name;                  //!< The Name of the Parameter.
+  unsigned int               _parameterCount;        //!< The Count of parameters.
+  std::string                _description;           //!< A longer description about this function.
 
-//! A class for descriptions of a loadable module
-class LoadClassDescription
-{
-  friend class CLoadParam;
-public:
-  LoadClassDescription(const std::string& className);
-  ~LoadClassDescription();
-
-  static LoadClassDescription* addClass(const std::string& className);
-  LoadParamDescription* addParam(const std::string& paramName);
-
-  static void deleteAllDescriptions();
-
-  static void printAll(const std::string& fileName = "");
-  static std::list<std::string> searchClassWithShort(const std::string& classNameBegin);
-  //  static const LoadParamDescription* getClass(const std::string& className);
-
-private:
-  static bool                              parametersDescription;  //!< if parameter-description should be enabled.
-  static std::list<LoadClassDescription*>* classList;              //!< a list, that stores all the loadable classes. (after one instance has been loaded)
-  std::string                              className;              //!< name of the class
-
-  std::list<LoadParamDescription*>         paramList;              //!< List of parameters this class knows.
+  std::vector<std::string>   _types;                 //!< A Vector of types of this Parameter.
+  std::vector<std::string>   _defaultValues;         //!< A Vector of defaultValues of this Parameter.
 };
 
Index: trunk/src/lib/util/loading/load_param_xml.h
===================================================================
--- trunk/src/lib/util/loading/load_param_xml.h	(revision 9869)
+++ trunk/src/lib/util/loading/load_param_xml.h	(revision 9869)
@@ -0,0 +1,86 @@
+/*
+   orxonox - the future of 3D-vertical-scrollers
+
+   Copyright (C) 2004 orx
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   ### File Specific:
+   main-programmer: Benjamin Grauer
+   co-programmer: ...
+*/
+
+/*!
+ * @file load_param_xml.h
+ * A Class and macro-functions, that makes our lives easy to load-in parameters from XML
+ */
+
+#ifndef _LOAD_PARAM_XML_H
+#define _LOAD_PARAM_XML_H
+
+#include "load_param.h"
+#include "executor/executor_xml.h"
+
+/**
+ * @brief Loads a Parameter from ROOT named PARAMETER_NAME
+ * onto OBJECT of CLASS, trough FUNCTION
+ * @param ROOT the TiXmlElement to load the Parameter from
+ * @param PARAMETER_NAME the Name of the Parameter to load
+ * @param OBJECT The BaseObject to load the new setting to.
+ * @param CLASS What Class the BaseObejct is of (this is for identifying the Functuon)
+ * @param FUNCTION The function of Class to Load (if you want to call &CLASS::FUNCTION write FUNCTION here).
+ */
+#define LoadParamXML(ROOT, PARAMETER_NAME, OBJECT, CLASS, FUNCTION) \
+         XmlLoadParam<CLASS>(ROOT, PARAMETER_NAME, OBJECT, new ExecutorXML<CLASS, CLASS>(&CLASS::FUNCTION, ROOT, PARAMETER_NAME), false)
+
+
+/**
+ * @brief Does essentially the same as LoadParamXML, but within a Cycle in an ordered fashion.
+ *
+ * This Function looks in each Element, if the PARAMETER_NAME matches, and loads onto OBJECT
+ * of CLASS the ROOT through FUNCTION
+ *
+ * @see LoadParamXML(ROOT, PARAMETER_NAME, OBJECT, CLASS, FUNCTION)
+ */
+#define LoadParamXML_CYCLE(ROOT, PARAMETER_NAME, OBJECT, CLASS, FUNCTION) \
+         XmlLoadParam<CLASS>(ROOT, PARAMETER_NAME, OBJECT, new ExecutorXML<CLASS, CLASS>(&CLASS::FUNCTION, ROOT, PARAMETER_NAME), true)
+
+//! A Class that can load XML tags onto an Object.
+template <class OperateClass = BaseObject> class XmlLoadParam : public LoadParamBase
+{
+public:
+  /**
+   * @brief generates a LoadParam based on
+   * @param root the Root Element to load onto the object.
+   * @param paramName the Parameter name that is loaded.
+   * @param object the Object to apply the changes on.
+   * @param executor the Functional Object, that actually executes the function Call.
+   * @param inLoadCycle If we are inside of a loading cycle. (Loading will be different here)
+   */
+  XmlLoadParam(const TiXmlElement* root, const std::string& paramName, OperateClass* object, Executor<const TiXmlElement*>* executor, bool inLoadCycle = false)
+      : LoadParamBase(root, paramName, inLoadCycle), object(object) , executor(executor)
+  {
+    assert(this->object != NULL);
+    assert(this->executor != NULL);
+  }
+
+  /** @brief executes and destroys the executor */
+  virtual ~XmlLoadParam()
+  {
+    this->setDescriptionValues(OperateClass::staticClassID(), executor->getParamCount(), executor->getDefaultValues(), executor->hasRetVal());
+    (*this->executor)(this->object, this->loadElem);
+    delete this->executor;
+  }
+
+  /** @param descriptionText the description @returns self @brief describes the Loading parameter. */
+  XmlLoadParam& describe(const std::string& descriptionText) { LoadParamBase::describe(OperateClass::staticClassID(), descriptionText); return *this; };
+
+private:
+  OperateClass*                        object;         //!< The Object to apply this to.
+  Executor<const TiXmlElement*>*    executor;       //!< The Executor, that does the actual loading process.
+};
+
+#endif /* _LOAD_PARAM_XML_H */
Index: trunk/src/lib/util/loading/resource.cc
===================================================================
--- trunk/src/lib/util/loading/resource.cc	(revision 9675)
+++ trunk/src/lib/util/loading/resource.cc	(revision 9869)
@@ -14,25 +14,279 @@
 */
 
-#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_LOADING
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_LOAD
 
 #include "resource.h"
-
-
-
-
-/**
- * standard constructor
-*/
-Resource::Resource (const std::string& fileName)
+#include "resource_manager.h"
+
+#include "debug.h"
+
+
+namespace Resources
 {
-//   this->setClassID(CL_RESOURCE, "Resource");
-
+  //! Define an ObjectList for the Resources
+  ObjectListDefinition(Resource);
+
+
+  /**
+   * @brief standard constructor
+   * @param type the Type this resource belongs to.
+   */
+  Resource::Resource (Type* type)
+      : _pointer(NULL), _type(type)
+  {
+    this->registerObject(this, Resource::_objectList);
+  }
+
+  /**
+   * @brief standard deconstructor
+   */
+  Resource::~Resource ()
+  {
+    // delete what has to be deleted here
+  }
+
+  /**
+   * @brief Locates a File inside of the Resources Paths and returns the appended path.
+   *
+   * @param fileName the Name of the file to look for.
+   * @returns the Name of the File prepended with the PAth it is in, if found, empty String ("") otherwise.
+   *
+   * This Function searches in (ordered):
+   * 1. mainGlobalPath (from ResourceManger)
+   * 2. all of the global Paths (from ResourceManger)
+   * 3. all of the Resources Paths (from Resources::Type)
+   *
+   * in each of these directory, first "./" is searched, and afterwards all of the subDirs (from Resources::Type) are searched.
+   *
+   * @todo finish it!!
+   */
+  std::string Resource::locateFile(const std::string& fileName) const
+  {
+    if ((ResourceManager::getInstance()->mainGlobalPath() + File(fileName)).exists() )
+      return (ResourceManager::getInstance()->mainGlobalPath() + File(fileName)).name();
+
+    std::string locatedFile;
+    locatedFile = locateFileInSubDir(ResourceManager::getInstance()->mainGlobalPath(), fileName);
+    if (!locatedFile.empty())
+    {
+      return locatedFile;
+    }
+
+    if (File(fileName).exists())
+      return fileName;
+
+    return (ResourceManager::getInstance()->mainGlobalPath() + File(fileName)).name();
+  }
+
+  /**
+   * @brief tests in all the SubDirectories defined in Resource under Directory if the fileName exists.
+   * @param directory the directory to in what to search for all subdirectories for.
+   * @param fileName the Name of the File to query for
+   * @return true on success.
+   */
+  std::string Resource::locateFileInSubDir(const Directory& directory, const std::string& fileName) const
+  {
+    std::vector<Directory>::const_iterator it;
+    for (it = this->_type->resourceSubPaths().begin(); it != this->_type->resourceSubPaths().end(); ++it)
+    {
+      Directory dir = directory + (*it);
+      File file = dir + File(fileName);
+      if ((dir+ File(fileName)).exists())
+        return (dir+File(fileName)).name();
+    }
+    return "";
+  }
+
+
+  /**
+   * @param loadString the Identifier of the Resource.
+   * @returns a Store-Pointer to the Resource if found, NULL otherwise
+   */
+  StorePointer* Resource::acquireResource(const std::string& loadString)
+  {
+    //const Type* const type = _resourceTypes[this->_type->id()];
+
+    for (unsigned int i = 0; i < _type->storedResources().size(); ++i)
+    {
+      if (_type->storedResources()[i]->loadString() == loadString)
+        return _type->storedResources()[i];
+    }
+
+    return NULL;
+  }
+
+  /**
+   * @brief registers a StorePointer to a Resource's Type.
+   * @param pointer the StorePointer to register.
+   */
+  void Resource::addResource(StorePointer* pointer)
+  {
+    assert(pointer != NULL);
+    this->_type->addResource(pointer);
+  }
+
+
+
+
+
+
+  ///////////////////
+  //// KEEPLEVEL ////
+  ///////////////////
+
+  //! Constructs a default KeepLevel as Set in the ResourceManager via setDefaultKeepLevel.
+  KeepLevel::KeepLevel()
+  {
+    this->_keepLevel = ResourceManager::getInstance()->defaultKeepLevel().keepLevel();
+  }
+  /**
+   * @param keepLevel the level to set.
+   */
+  KeepLevel::KeepLevel(unsigned int keepLevel)
+  {
+    _keepLevel = keepLevel;
+  }
+
+  /**
+   * @brief constructor of a KeepLevel.
+   * @param keepLevelName the Name of the KeepLevel. Must be one Name of the defined Names in the ResourceManager.
+   *
+   * @note the Name is transformed into an Integer for fast interpretation.
+   */
+  KeepLevel::KeepLevel(const std::string& keepLevelName)
+  {
+    this->_keepLevel = ResourceManager::getInstance()->getKeepLevelID(keepLevelName);
+  }
+
+  /**
+   * @returns the name of the KeepLevel.
+   */
+  const std::string& KeepLevel::name() const
+  {
+    return ResourceManager::getInstance()->getKeepLevelName(this->_keepLevel);
+  }
+
+
+
+  ///////////////////////
+  //// STORE POINTER ////
+  ///////////////////////
+  /**
+   * @brief allocates a StorePointer.
+   * @param loadString An identifier String that is unique between all resources of this type.
+   * @param keepLevel the KeepLevel at wich to keep this resource.
+   */
+  StorePointer::StorePointer(const std::string& loadString, const KeepLevel& keeplevel)
+      : _loadString(loadString), _keepLevel(keeplevel)
+  {
+    PRINTF(4)("Acquired a Resource with LoadString '%s' and KeepLevel '%s'\n", _loadString.c_str(), _keepLevel.name().c_str());
+  }
+
+  StorePointer::~StorePointer()
+  {
+    PRINTF(4)("Deleting Stored Resource '%s' from KeepLevel '%s'\n", _loadString.c_str(), _keepLevel.name().c_str());
+  };
+
+
+
+  //////////////
+  //// TYPE ////
+  //////////////
+  /**
+   * @brief allocates a Type.
+   * @param typeName the Name of the Type to be stored in this Container.
+   */
+  Type::Type(const std::string& typeName)
+      : _typeName(typeName)
+  {
+    ResourceManager::getInstance()->registerType(this);
+    PRINTF(4)("Created ResourceType '%s'\n", typeName.c_str());
+  }
+
+  //! Destructs a Type.
+  Type::~Type()
+  {
+    ResourceManager::getInstance()->unregisterType(this);
+  }
+
+  /**
+   * @brief adds a Resource to this Resource's type.
+   * @param resource the Resource to add.
+   */
+  void Type::addResource(StorePointer* resource)
+  {
+    this->_storedResources.push_back(resource);
+  }
+
+  /**
+   * @brief adds a Path to the Type's resource-paths.
+   * @param path the path-name to add.
+   */
+  bool Type::addResourcePath(const std::string& path)
+  {
+    std::vector<Directory>::const_iterator it;
+    for (it = this->_resourcePaths.begin(); it != this->_resourcePaths.end(); ++it)
+      if ((*it) == path)
+        return false;
+    this->_resourcePaths.push_back(path);
+    return true;
+
+  }
+
+  /**
+   * @brief Adds a SubPath to the Type's resource-subpaths.
+   * @param subPath the subpath to add.
+   */
+  bool Type::addResourceSubPath(const std::string& subPath)
+  {
+    std::vector<Directory>::const_iterator it;
+    for (it = this->_resourceSubPaths.begin(); it != this->_resourceSubPaths.end(); ++it)
+      if ((*it) == subPath)
+        return false;
+    this->_resourceSubPaths.push_back(subPath);
+    return true;
+  }
+
+  /**
+   * @brief Unloads all Resources below a certain Level.
+   * @param keepLevel the KeepLevel at what to remove the Resources from.
+   */
+  void Type::unloadAllBelowKeepLevel(const Resources::KeepLevel& keepLevel)
+  {
+    std::vector<Resources::StorePointer*>::iterator it, it2;
+    bool finished = false;
+
+    while (!finished)
+    {
+      finished = true;
+      for (it = this->_storedResources.begin(); it != this->_storedResources.end();++it)
+        if((*it)->keepLevel() < keepLevel && (*it)->last())
+        {
+          delete (*it);
+          this->_storedResources.erase(it);
+          finished = false;
+          break;
+        }
+    }
+  }
+
+  /**
+   * @brief print out some nice Debug information in a beatifully designed style
+   */
+  void Type::debug() const
+  {
+    PRINT(0)(" ResourceType '%s' stores %d Resources\n", this->_typeName.c_str(), this->_storedResources.size());
+    PRINT(0)("  Paths:\n");
+    for (unsigned int i = 0; i < this->_resourcePaths.size(); ++i)
+      PRINT(0)("    %s\n", this->_resourcePaths[i].name().c_str());
+    PRINT(0)("  Sub-Paths:");
+    for (unsigned int i = 0; i < this->_resourceSubPaths.size(); ++i)
+      PRINT(0)(" '%s'", this->_resourceSubPaths[i].name().c_str());
+    PRINT(0)("\n");
+
+    PRINT(0)("  Loaded Resources:\n");
+    std::vector<Resources::StorePointer*>::const_iterator it;
+    for (it = this->_storedResources.begin(); it != this->_storedResources.end(); ++it)
+      PRINT(0)("    '%s' : KeepLevel '%s'\n", (*it)->loadString().c_str(), (*it)->keepLevel().name().c_str());
+  }
 }
-
-/**
- * standard deconstructor
- */
-Resource::~Resource ()
-{
-  // delete what has to be deleted here
-}
Index: trunk/src/lib/util/loading/resource.h
===================================================================
--- trunk/src/lib/util/loading/resource.h	(revision 9675)
+++ trunk/src/lib/util/loading/resource.h	(revision 9869)
@@ -8,51 +8,188 @@
 
 #include "base_object.h"
-#include "multi_type.h"
 #include <string>
+#include <vector>
+#include <set>
 
-// FORWARD DECLARATION
+#include "filesys/directory.h"
+
+//! A Namespace Resources and ResourceHandling is defined in.
+namespace Resources
+{
+  //! The KeepLevel handles the unloading of Resources.
+  /**
+   * Allocating a Resource also appends a KeepLevel to the Resource.
+   * When the Resource is not used anymore it is decided on the grounds of the KeepLevel,
+   * if the Resource should be deleted. (e.g. at the end of a Level, Campaign, or something like this).
+   */
+  class KeepLevel
+  {
+  public:
+    KeepLevel();
+    KeepLevel(unsigned int keepLevel);
+    KeepLevel(const std::string& keepLevelName);
+
+    //! Compare equality
+    inline bool operator==(const KeepLevel& keepLevel) const { return this->_keepLevel == keepLevel._keepLevel; };
+    //! Compares inequality
+    inline bool operator!=(const KeepLevel& keepLevel) const { return this->_keepLevel != keepLevel._keepLevel; };
+    //! Compares less/equal than
+    inline bool operator<=(const KeepLevel& keepLevel) const { return this->_keepLevel <= keepLevel._keepLevel; };
+    //! Compares less than
+    inline bool operator<(const KeepLevel& keepLevel) const { return this->_keepLevel < keepLevel._keepLevel; };
+
+    /** @returns the KeepLevel as a number */
+    inline unsigned int keepLevel() const { return _keepLevel; };
+    const std::string& name() const;
+  private:
+    unsigned int                _keepLevel;              //!< The KeepLevel a Resource is in.
+  };
+
+
+  ///////////////////
+  // STORE POINTER //
+  ///////////////////
+  //! Stores a Resource-Pointer, the LoadString and it's keepLevel.
+  class StorePointer
+  {
+  public:
+    //! Virtual Destructor, that removes the Stored information-pointer.
+    virtual ~StorePointer();
+
+    /** @returns the LoadString this resource was loaded with */
+    const std::string& loadString() const { return _loadString; };
+    /** @returns the KeepLevel of this resource */
+    const Resources::KeepLevel& keepLevel() const { return _keepLevel; };
+
+    virtual bool last() const = 0;
+
+    protected:
+      StorePointer(const std::string& loadString, const Resources::KeepLevel& keeplevel);
+
+    private:
+      StorePointer(const StorePointer&) : _keepLevel(0) {};
+
+  private:
+    std::string                 _loadString;             //!< An identifier, to match when loading a File.
+    Resources::KeepLevel        _keepLevel;              //!< The Priority of this resource. (can only be increased, so none else will delete this)
+  };
 
 
 
-//! An enumerator for different (UN)LOAD-types.
-/**
- * RP_NO:        will be unloaded on request
- * RP_LEVEL:     will be unloaded at the end of a Level
- * RP_CAMPAIGN:  will be unloaded at the end of a Campaign
- * RP_GAME:      will be unloaded at the end of the whole Game (when closing orxonox)
- */
-typedef enum ResourcePriority
-{
-  RP_NO        =   0,
-  RP_LEVEL     =   1,
-  RP_CAMPAIGN  =   2,
-  RP_GAME      =   3
-};
+  ///////////////////
+  // RESOURCE TYPE //
+  ///////////////////
+  //! A Type of Resources.
+  /**
+   * The Type is used to store the Pointers to already loaded Resources,
+   * and also to store type-specific properties.
+   * These are the Loading Paths, the subpaths and so on.
+   */
+  class Type
+  {
+  public:
+    virtual ~Type();
+    /** @returns true if the names match @param typeName the Name to compare. @brief compare the Type with a Name */
+    bool operator==(const std::string& typeName) const { return this->_typeName == typeName; };
+
+    ////////////////////
+    //// EXTENSIONS ////
+    void addExtension(const std::string& extension);
+
+    ///////////////
+    //// PATHS ////
+    bool addResourcePath(const std::string& path);
+    bool addResourceSubPath(const std::string& subPath);
+
+    /// Retrieve Functions
+    /** @returns the name of the stored Class this Type loads Resources for */
+    const std::string& storedClassName() const { return _typeName; };
+    /** @returns the ID of the Type != ClassID */
+    /** @returns the type-specific paths this Resource searches in. */
+    const std::vector<Directory>& resourcePaths() const { return _resourcePaths; };
+    /** @returns the Type specific SubPaths this Resource Searches in @see std::vector<std::string>  _resourceSubPaths */
+    const std::vector<Directory>& resourceSubPaths() const { return _resourceSubPaths; };
+    /** @returns the Pointers to the Stored resources. @note do not use this, for more than some lookup */
+    const std::vector<Resources::StorePointer*>& storedResources() const { return _storedResources; };
+
+    ///////////////////////////////
+    //// LOADING AND UNLOADING ////
+    virtual void createFromString(const std::string& loadString, const KeepLevel& keepLevel = KeepLevel()) = 0;
+    void unloadAllBelowKeepLevel(const Resources::KeepLevel& keepLevel);
+
+    ///////////////////
+    //// INTERNALS ////
+    void addResource(Resources::StorePointer* resource);
+
+    ///////////////
+    //// DEBUG ////
+    void debug() const;
+
+  protected:
+    Type(const std::string& typeName);
+
+  private:
+    Type(const Type& type) {};
+  private:
+    const std::string                     _typeName;          //!< Name of the Type. (Name of the Resource this loads.)
+    std::vector<Directory>                _resourcePaths;     //!< The Paths to search for files in this type
+    std::vector<Directory>                _resourceSubPaths;  //!< The subpaths that will be searched under all the _resourcePaths.
+    std::vector<std::string>              _fileExtensions;    //!< File Extensions, this Resource supports.
+
+    std::vector<Resources::StorePointer*> _storedResources;   //!< An array of all the stored Resources.
+  };
+
+  /**
+   * @brief A Type Definition Class for any Object that is resourceable.
+   *
+   * This Class's main reason of Existence is, that resources can be dynamically
+   * created over a loadString. For this the Type of Resource is required, and the Resource must
+   * itself support the 'void createFromString(const std::string&)' function.
+   */
+  template<class T> class tType : public Type
+  {
+  public:
+    /** Create the ResourceType @see Type(const std::string&) */
+    tType(const std::string& typeName) : Type(typeName) {};
+    /** @param loadString the String to load a Resource with @brief tries to create a Resource of Type T with a loadString */
+    virtual void createFromString(const std::string& loadString, const KeepLevel& keepLevel = KeepLevel()) { T::createFromString(loadString, keepLevel); }
+  };
 
 
 
-//! A Resource is an Object, that can be loaded from Disk
-/**
- *
- */
-class Resource : virtual public BaseObject {
+  /////////////////////
+  // RESOURCE ITSELF //
+  /////////////////////
+  //! A Resource is an Object, that can be loaded from Disk
+  /**
+   * The Resource Hanldes the location and stores pointers to data that can be retrieved.
+   */
+  class Resource : virtual public BaseObject
+  {
+    ObjectListDeclaration(Resource);
 
- public:
-   Resource(const std::string& fileName);
-  virtual ~Resource();
+  public:
+    Resource(Resources::Type* type);
+    virtual ~Resource();
 
-  virtual bool load(std::string& fileName, const MultiType& param1, const MultiType& param2);
-  virtual bool reload();
-  virtual bool unload();
+    /** @brief reloads the underlying resource */
+    virtual bool reload() { return false; };
+    /** @brief unloads the underlying Resource */
+    virtual bool unload() { return false; };
 
- private:
-   std::string       fileName;
+    std::string locateFile(const std::string& fileName) const;
 
-   unsigned int      referenceCount;    //!< How many times this Resource has been loaded.
-/// TODO REMOVE THIS:   ResourceType      type;              //!< ResourceType of this Resource.
-   ResourcePriority  prio;              //!< The Priority of this resource. (can only be increased, so noone else will delete this)
+  protected:
+    Resources::StorePointer* acquireResource(const std::string& loadString);
+    void addResource(Resources::StorePointer* pointer);
 
-   MultiType         param[3];          //!< The Parameters given to this Resource.
-};
+  private:
+    std::string locateFileInSubDir(const Directory& directory, const std::string& fileName) const;
+
+  private:
+    Resources::StorePointer*       _pointer;                         //!< Virtual Pointer to the ResourceData.
+    Resources::Type*               _type;                            //!< Type of the Resource.
+  };
+}
 
 #endif /* _RESOURCE_H */
Index: trunk/src/lib/util/loading/resource_manager.cc
===================================================================
--- trunk/src/lib/util/loading/resource_manager.cc	(revision 9675)
+++ trunk/src/lib/util/loading/resource_manager.cc	(revision 9869)
@@ -16,903 +16,241 @@
 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_LOAD
 
-#include "util/loading/resource_manager.h"
-#include "substring.h"
+#include "resource_manager.h"
 #include "debug.h"
 
 #include <algorithm>
-#include <assert.h>
-
-// different resource Types
-#ifndef NO_MODEL
-#include "objModel.h"
-#include "primitive_model.h"
-#include "md2/md2Model.h"
-#include "md3/md3_data.h"
-#include "md3/md3_animation_cfg.h"
-#endif /* NO_MODEL */
-#ifndef NO_TEXTURES
-#include "texture.h"
-#endif /* NO_TEXTURES */
-#ifndef NO_TEXT
-#include "font.h"
-#endif /* NO_TEXT */
-#ifndef NO_AUDIO
-#include "sound_buffer.h"
-#include "ogg_player.h"
-#endif /* NO_AUDIO */
-#ifndef NO_SHADERS
-#include "shader.h"
-#endif /* NO_SHADERS */
-
-// File Handling Includes
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-
-
-
-/**
- * @brief standard constructor
-*/
-ResourceManager::ResourceManager ()
+#include <cassert>
+
+
+namespace Resources
 {
-  this->setClassID(CL_RESOURCE_MANAGER, "ResourceManager");
-  this->setName("ResourceManager");
-
-  this->dataDir = "./";
-  this->tryDataDir("./data");
+  /// Definition of the ResourceManager's ObjectList.
+  ObjectListDefinition(ResourceManager);
+  //! Singleton Reference to the ResourceManager
+  ResourceManager* ResourceManager::_singletonRef = NULL;
+
+
+  /**
+   * @brief standard constructor
+  */
+  ResourceManager::ResourceManager ()
+  : _defaultKeepLevel(0)
+  {
+    this->registerObject(this, ResourceManager::_objectList);
+    this->setName("ResourceManager");
+    this->_mainGlobalPath = Directory("./");
+  }
+
+
+  /**
+   * @brief standard destructor
+  */
+  ResourceManager::~ResourceManager ()
+  {
+    this->unloadAllBelowKeepLevel(this->_keepLevelNames.size());
+    ResourceManager::_singletonRef = NULL;
+  }
+
+  /**
+   * @brief Registers a new Type to the ResourceManager.
+   * @param type the Type to register.
+   */
+  void ResourceManager::registerType(Resources::Type* type)
+  {
+    this->_resourceTypes.push_back(type);
+    PRINTF(5)("ResourceType '%s' added\n", type->storedClassName().c_str());
+  }
+
+  /**
+   * @brief Unregisters a new Type to the ResourceManager.
+   * @param type the Type to unregister.
+   */
+  void ResourceManager::unregisterType(Resources::Type* type)
+  {
+    std::vector<Resources::Type*>::iterator it = std::find (this->_resourceTypes.begin(), this->_resourceTypes.end(), type);
+    if (it != this->_resourceTypes.end())
+    {
+      this->_resourceTypes.erase(it);
+      PRINTF(5)("ResourceType '%s' removed\n", type->storedClassName().c_str());
+    }
+  }
+
+  /**
+   * @brief Sets the main Global path (the main path Resources are searched for)
+   * @param directory the directory to set.
+   * @see Resource::locateFile
+   */
+  void ResourceManager::setMainGlobalPath(const Directory& directory)
+  {
+    this->_mainGlobalPath = directory;
+    this->_mainGlobalPath.open();
+  }
+
+  /**
+   * @brief add a Global search path. (global paths besided the main path.)
+   * @param directory a directory to add.
+   */
+  void ResourceManager::addGlobalPath(const Directory& directory)
+  {
+    std::vector<Directory>::const_iterator it = std::find(this->_globalPaths.begin(), this->_globalPaths.end(), directory);
+    if (it == this->_globalPaths.end())
+      this->_globalPaths.push_back(directory);
+  }
+
+  /**
+   * @brief add a ResourcePath to a Type's Paths.
+   * @param resourceName the Type's name of Resource to add the path to.
+   * @param pathName pathName the Name of the path to add.
+   * @return true on success. (if a path was added (no duplicate, and resourceName existed).
+   */
+  bool ResourceManager::addResourcePath(const std::string& resourceName, const std::string& pathName)
+  {
+    std::vector<Resources::Type*>::iterator it;
+    for (it = this->_resourceTypes.begin(); it != this->_resourceTypes.end(); ++it)
+      if (*(*it) == resourceName)
+        return (*it)->addResourcePath(pathName);
+    PRINTF(2)("ResourcePath %s could not be added to the ResourceType %s\n", pathName.c_str(), resourceName.c_str());
+    return false;
+  }
+
+  /**
+   * @brief add a ResourcePath to a Type's SubPaths.
+   * @param resourceName the Type's name of Resource to add the subpath to.
+   * @param pathName pathName the Name of the path to add.
+   * @return true on success. (if a path was added (no duplicate, and resourceName existed).
+   */
+  bool ResourceManager::addResourceSubPath(const std::string& resourceName, const std::string& pathName)
+  {
+    std::vector<Resources::Type*>::iterator it;
+    for (it = this->_resourceTypes.begin(); it != this->_resourceTypes.end(); ++it)
+      if (*(*it) == resourceName)
+        return (*it)->addResourceSubPath(pathName);
+    PRINTF(2)("ResourceSubPath %s could not be added to the ResourceType %s\n", pathName.c_str(), resourceName.c_str());
+    return false;
+  }
+
+  /**
+   * @brief checks wether a File is inside of the MainPath.
+   * @param fileInside the file to check
+   * @return true if the file is inside.
+   */
+  bool ResourceManager::checkFileInMainPath(const File& fileInside)
+  {
+    return (this->_mainGlobalPath + fileInside).exists();
+  }
+
+  /**
+   * @brief prepends the fileName by the MainGlobalPath (same as mainGlobalPath + '/' + fileName).
+   * @param fileName The FileName to prepend
+   * @returns the prepended file-name
+   */
+  std::string ResourceManager::prependAbsoluteMainPath(const std::string& fileName)
+  {
+    return (this->_mainGlobalPath + File(fileName)).name();
+  }
+
+  /**
+   * @brief add a KeepLevelName (this function just counts upwards).
+   * @param keepLevelName the Name of the KeepLevel to set.
+   * @returns the Level the Name was set to.
+   */
+  unsigned int ResourceManager::addKeepLevelName(const std::string& keepLevelName)
+  {
+    this->_keepLevelNames.push_back(keepLevelName);
+    return _keepLevelNames.size()-1;
+  }
+
+  /**
+   * @param keepLevelName the Name of the KeepLevel.
+   * @returns the ID of the KeepLevel named keepLevelName
+   */
+  unsigned int ResourceManager::getKeepLevelID(const std::string& keepLevelName) const
+  {
+    for (unsigned int i = 0; i < this->_keepLevelNames.size(); ++i)
+      if (this->_keepLevelNames[i] == keepLevelName)
+        return i;
+
+    PRINTF(2)("KeepLevel '%s' not found. Using 0 instead\n", keepLevelName.c_str());
+    return 0;
+  }
+
+  /**
+   * @param keepLevelID the ID to check.
+   * @return the name of the KeepLevel.
+   */
+  const std::string& ResourceManager::getKeepLevelName(unsigned int keepLevelID) const
+  {
+    assert(keepLevelID < this->_keepLevelNames.size());
+    return this->_keepLevelNames[keepLevelID];
+  }
+
+
+  /**
+   * @brief loads a Resource from a TypeName and a loadString.
+   * @param resourceTypeName The Name of the Type to what to load a Resource from.
+   * @param loadString the loadString to load in the Type.
+   */
+  void ResourceManager::loadFromLoadString(const std::string& resourceTypeName, const std::string& loadString, const KeepLevel& keepLevel)
+  {
+    std::vector<Resources::Type*>::const_iterator it;
+    for (it = this->_resourceTypes.begin(); it != this->_resourceTypes.end(); ++it)
+    {
+      if (*(*it) == resourceTypeName)
+      {
+	(*it)->createFromString(loadString, keepLevel);
+	/// TODO check if the resource was allocated!!
+	return ;
+      }
+    }
+    return ;
+  }
+
+  /**
+   * @brief unloads all Resources below a certain threshhold.
+   * @param keepLevel the KeepLevel below which to erase.
+   *
+   * @not Resources will only be erased, if th keepLevel is below, and the resources are not
+   * referenced anymore.
+   */
+  void ResourceManager::unloadAllBelowKeepLevel(const Resources::KeepLevel& keepLevel)
+  {
+    std::vector<Resources::Type*>::const_iterator it;
+    for (it = this->_resourceTypes.begin(); it != this->_resourceTypes.end(); ++it)
+    {
+      (*it)->unloadAllBelowKeepLevel(keepLevel);
+    }
+  }
+
+
+  /**
+   * @brief outputs debug information about the ResourceManager
+   */
+  void ResourceManager::debug() const
+  {
+    PRINT(0)("/==RM================================\\\n");
+    PRINT(0)("| RESOURCE-MANAGER DEBUG INFORMATION |\n");
+    PRINT(0)("\\====================================/\n");
+    PRINT(0)(" MainGlobal search path is %s\n", this->_mainGlobalPath.name().c_str());
+    if(!this->_globalPaths.empty())
+    {
+      PRINT(0)(" Additional Global search Paths are: ");
+      for (unsigned int i = 0; i < this->_globalPaths.size(); ++i)
+        PRINT(0)("'%s' ", this->_globalPaths[i].name().c_str());
+      PRINT(0)("\n");
+    }
+    PRINT(0)(" Listing %d Types: \n", this->_resourceTypes.size());
+    std::vector<Resources::Type*>::const_iterator it;
+    for (it = this->_resourceTypes.begin(); it != this->_resourceTypes.end(); ++it)
+    {
+      (*it)->debug();
+      if (it != --this->_resourceTypes.end())
+        PRINT(0)(" ------------------------------------\n ");
+    }
+
+    PRINT(0)("KeepLevels are: ");
+    for (unsigned int i = 0; i < this->_keepLevelNames.size(); ++i)
+      PRINT(0)("%d:'%s'  ", i, this->_keepLevelNames[i].c_str());
+    PRINT(0)("\n");
+    PRINT(0)("=================================RM==/\n");
+  }
 }
-
-//! Singleton Reference to the ResourceManager
-ResourceManager* ResourceManager::singletonRef = NULL;
-
-/**
- * @brief standard destructor
-*/
-ResourceManager::~ResourceManager ()
-{
-  // deleting the Resources-List
-  this->unloadAllByPriority(RP_GAME);
-
-  if (!this->resourceList.empty())
-    PRINTF(1)("Not removed all Resources, since there are still %d resources registered\n", this->resourceList.size());
-
-  ResourceManager::singletonRef = NULL;
-}
-
-/**
- * @brief sets the data main directory
- * @param dataDir the DataDirectory.
- */
-bool ResourceManager::setDataDir(const std::string& dataDir)
-{
-  File dataDirectory(dataDir);
-  if (dataDirectory.isDirectory())
-  {
-    this->dataDir = dataDirectory.name();
-
-    if (dataDir[dataDir.size()-1] != '/' && dataDir[dataDir.size()-1] != '\\')
-    {
-      this->dataDir += '/';
-    }
-    return true;
-  }
-  else
-  {
-    PRINTF(1)("%s is not a Directory, and can not be the Data Directory, leaving as %s \n", dataDir.c_str(), this->dataDir.c_str());
-    return false;
-  }
-}
-
-/**
- * @brief sets the data main directory
- * @param dataDir the DataDirectory.
- *
- * this is essentially the same as setDataDir, but it ommits the error-message
- */
-bool ResourceManager::tryDataDir(const std::string& dataDir)
-{
-  File dataDirectory(dataDir);
-  if (dataDirectory.isDirectory())
-  {
-    this->dataDir = dataDirectory.name();
-
-    if (dataDir[dataDir.size()-1] != '/' && dataDir[dataDir.size()-1] != '\\')
-    {
-      this->dataDir += '/';
-    }
-    return true;
-  }
-  return false;
-}
-
-
-/**
- * @brief checks for the DataDirectory, by looking if
- * @param fileInside is iniside of the given directory.
-*/
-bool ResourceManager::verifyDataDir(const std::string& fileInside)
-{
-  File dataDirectory(this->dataDir);
-  if (!dataDirectory.isDirectory())
-  {
-    PRINTF(1)("'%s' is not a directory\n", this->dataDir.c_str());
-    return false;
-  }
-
-  File testFile(this->dataDir + fileInside);
-  return testFile.isFile();
-}
-
-#ifndef NO_TEXTURES
-/**
- * @brief adds a new Path for Images
- * @param imageDir The path to insert
- * @returns true, if the Path was well and injected (or already existent within the list)
-   false otherwise
-*/
-bool ResourceManager::addImageDir(const std::string& imageDir)
-{
-  std::string newDir = imageDir;
-  if (imageDir[imageDir.size()-1] != '/' && imageDir[imageDir.size()-1] != '\\')
-  {
-    newDir += '/';
-  }
-  // check if the param is a Directory
-  if (File(newDir).isDirectory())
-  {
-    // check if the Directory has been added before
-    std::vector<std::string>::const_iterator imageDir;
-    for (imageDir = this->imageDirs.begin(); imageDir != this->imageDirs.end(); imageDir++)
-    {
-      if (*imageDir == newDir)
-      {
-        PRINTF(3)("Path %s already loaded\n", newDir.c_str());
-        return true;
-      }
-    }
-    // adding the directory to the List
-    this->imageDirs.push_back(newDir);
-    return true;
-  }
-  else
-  {
-    PRINTF(1)("%s is not a Directory, and can not be added to the Paths of Images\n", newDir.c_str());
-    return false;
-  }
-}
-#endif /* NO_TEXTURES */
-
-/**
- * @brief loads resources
- * @param fileName: The fileName of the resource to load
- * @param prio: The ResourcePriority of this resource (will only be increased)
- * @param param0: an additional option to parse (see the constuctors for more help)
- * @param param1: an additional option to parse (see the constuctors for more help)
- * @param param2: an additional option to parse (see the constuctors for more help)
- * @returns a pointer to a desired Resource.
-*/
-BaseObject* ResourceManager::load(const std::string& fileName, ResourcePriority prio,
-                                  const MultiType& param0, const MultiType& param1, const MultiType& param2)
-{
-  ResourceType tmpType;
-#ifndef NO_MODEL
-#define __IF_OK
-  if (!strncasecmp(fileName.c_str()+(fileName.size()-4), ".obj", 4))
-    tmpType = OBJ;
-  else if (!strncmp(fileName.c_str()+(fileName.size()-4), ".md2", 4))
-    tmpType = MD2;
-  else if (!strncmp(fileName.c_str()+(fileName.size()-4), ".md3", 4))
-    tmpType = MD3;
-  else if (!strncmp(fileName.c_str()+(fileName.size()-4), ".cfg", 4))
-    tmpType = MD3_CONFIG;
-  else if (!strcasecmp(fileName.c_str(), "cube") ||
-            !strcasecmp(fileName.c_str(), "sphere") ||
-            !strcasecmp(fileName.c_str(), "plane") ||
-            !strcasecmp(fileName.c_str(), "cylinder") ||
-            !strcasecmp(fileName.c_str(), "cone"))
-    tmpType = PRIM;
-#endif /* NO_MODEL */
-#ifndef NO_AUDIO
-#ifdef __IF_OK
-  else
-#endif
-#define __IF_OK
-    if (!strncasecmp(fileName.c_str()+(fileName.size()-4), ".wav", 4))
-      tmpType = WAV;
-    else if (!strncasecmp(fileName.c_str()+(fileName.size()-4), ".mp3", 4))
-      tmpType = MP3;
-    else if (!strncasecmp(fileName.c_str()+(fileName.size()-4), ".ogg", 4))
-      tmpType = OGG;
-#endif /* NO_AUDIO */
-#ifndef NO_TEXT
-#ifdef __IF_OK
-    else
-#endif
-#define __IF_OK
-      if (!strncasecmp(fileName.c_str()+(fileName.size()-4), ".ttf", 4))
-        tmpType = TTF;
-#endif /* NO_TEXT */
-#ifndef NO_SHADERS
-#ifdef __IF_OK
-      else
-#endif
-#define __IF_OK
-        if (!strncasecmp(fileName.c_str()+(fileName.size()-5), ".vert", 5))
-          tmpType = SHADER;
-#endif /* NO_SHADERS */
-#ifndef NO_TEXTURES
-#ifdef __IF_OK
-        else
-#else
-  if
-#endif
-          tmpType = IMAGE;
-#endif /* NO_TEXTURES */
-#undef __IF_OK
-  return this->load(fileName, tmpType, prio, param0, param1, param2);
-}
-
-/**
- * @brief caches a Resource
- *
- * @see load;
- *
- * @brief returns true if ok, false otherwise.
- * This function loads a Resource without applying it to an Object.
- * This is for loading purposes, e.g, when the user is loading a Resource
- * during the initialisation instead of at Runtime.
- */
-bool ResourceManager::cache(const std::string& fileName, ResourceType type, ResourcePriority prio,
-                            const MultiType& param0, const MultiType& param1, const MultiType& param2)
-{
-  // searching if the resource was loaded before.
-  Resource* tmpResource;
-  // check if we already loaded this Resource
-  tmpResource = this->locateResourceByInfo(fileName, type, param0, param1, param2);
-  // otherwise load it
-  if (tmpResource == NULL)
-    tmpResource = this->loadResource(fileName, type, prio, param0, param1, param2);
-  // return cached pointer.
-  if (tmpResource != NULL) // if the resource was loaded before.
-  {
-    if(tmpResource->prio < prio)
-      tmpResource->prio = prio;
-    return true;
-  }
-  else
-    return false;
-}
-
-/**
- * tells the ResourceManager to generate a Copy of the Resource.
- * @brief resourcePointer: The Pointer to the resource to copy
- * @returns the Resource pointed to resourcePointer.
- */
-BaseObject* ResourceManager::copy(BaseObject* resourcePointer)
-{
-  Resource* tmp = locateResourceByPointer(resourcePointer);
-  if (tmp!=NULL)
-  {
-    tmp->count++;
-    return tmp->pointer;
-  }
-  else
-    return NULL;
-}
-
-
-/**
- * @brief loads resources
- * @param fileName: The fileName of the resource to load
- * @param type: The Type of Resource to load.
- * @param prio: The ResourcePriority of this resource (will only be increased)
- * @param param0: an additional option to parse (see the constuctors for more help)
- * @param param1: an additional option to parse (see the constuctors for more help)
- * @param param2: an additional option to parse (see the constuctors for more help)
- * @returns a pointer to a desired Resource.
-*/
-BaseObject* ResourceManager::load(const std::string& fileName, ResourceType type, ResourcePriority prio,
-                                  const MultiType& param0, const MultiType& param1, const MultiType& param2)
-{
-
-  // searching if the resource was loaded before.
-  Resource* tmpResource;
-  // check if we already loaded this Resource
-  tmpResource = this->locateResourceByInfo(fileName, type, param0, param1, param2);
-  // otherwise load it
-  if (tmpResource == NULL)
-  {
-    tmpResource = this->loadResource(fileName, type, prio, param0, param1, param2);
-  }
-  // return cached pointer.
-  if (tmpResource != NULL) // if the resource was loaded before.
-  {
-    tmpResource->count++;
-    if(tmpResource->prio < prio)
-      tmpResource->prio = prio;
-
-    return tmpResource->pointer;
-  }
-  else
-    return NULL;
-}
-
-
-/**
- * @brief loads resources for internal purposes
- * @param fileName: The fileName of the resource to load
- * @param type: The Type of Resource to load.
- * @param prio: The ResourcePriority of this resource (will only be increased)
- * @param param0: an additional option to parse (see the constuctors for more help)
- * @param param1: an additional option to parse (see the constuctors for more help)
- * @param param2: an additional option to parse (see the constuctors for more help)
- * @returns a pointer to a desired Resource.
- */
-Resource* ResourceManager::loadResource(const std::string& fileName, ResourceType type, ResourcePriority prio,
-                                        const MultiType& param0, const MultiType& param1, const MultiType& param2)
-{
-  // Setting up the new Resource
-  Resource* tmpResource = new Resource;
-  tmpResource->count = 0;
-  tmpResource->type = type;
-  tmpResource->prio = prio;
-  tmpResource->pointer = NULL;
-  tmpResource->name = fileName;
-
-  // creating the full name. (directoryName + FileName)
-  std::string fullName = ResourceManager::getFullName(fileName);
-  // Checking for the type of resource \see ResourceType
-  switch(type)
-  {
-#ifndef NO_MODEL
-    case OBJ:
-      if (param0.getType() != MT_NULL)
-        tmpResource->param[0] = param0;
-      else
-        tmpResource->param[0] = 1.0f;
-
-      if(File(fullName).isFile())
-        tmpResource->pointer = new OBJModel(fullName, tmpResource->param[0].getFloat());
-      else
-      {
-        PRINTF(2)("File %s in %s does not exist. Loading a cube-Model instead\n", fileName.c_str(), dataDir.c_str());
-        tmpResource->pointer = ResourceManager::load("cube", PRIM, prio, tmpResource->param[0].getFloat());
-      }
-      break;
-    case PRIM:
-      if (param0 != MT_NULL)
-        tmpResource->param[0] = param0;
-      else
-        tmpResource->param[0] = 1.0f;
-
-      if (tmpResource->name == "cube")
-        tmpResource->pointer = new PrimitiveModel(PRIM_CUBE, tmpResource->param[0].getFloat());
-      else if (tmpResource->name == "sphere")
-        tmpResource->pointer = new PrimitiveModel(PRIM_SPHERE, tmpResource->param[0].getFloat());
-      else if (tmpResource->name == "plane")
-        tmpResource->pointer = new PrimitiveModel(PRIM_PLANE, tmpResource->param[0].getFloat());
-      else if (tmpResource->name == "cylinder")
-        tmpResource->pointer = new PrimitiveModel(PRIM_CYLINDER, tmpResource->param[0].getFloat());
-      else if (tmpResource->name == "cone")
-        tmpResource->pointer = new PrimitiveModel(PRIM_CONE, tmpResource->param[0].getFloat());
-      break;
-    case MD2:
-      if(File(fullName).isFile())
-      {
-        tmpResource->param[0] = param0;
-        tmpResource->param[1] = param1;
-        tmpResource->pointer = new MD2Data(fullName, tmpResource->param[0].getCString(), tmpResource->param[1].getFloat());
-      }
-      break;
-    case MD3:
-      if(File(fullName).isFile())
-      {
-        tmpResource->param[0] = param0;
-        tmpResource->param[1] = param1;
-        tmpResource->pointer = new md3::MD3Data(fullName, tmpResource->param[0].getCString(), tmpResource->param[1].getFloat());
-      }
-      break;
-    case MD3_CONFIG:
-      if(File(fullName).isFile())
-      {
-        tmpResource->param[0] = param0;
-        tmpResource->param[1] = param1;
-        tmpResource->pointer = new md3::MD3AnimationCfg(fullName);
-      }
-      break;
-#endif /* NO_MODEL */
-#ifndef NO_TEXT
-    case TTF:
-      if (param0 != MT_NULL)
-      {
-        assert(param0.getInt() >= 0);
-        tmpResource->param[0] = param0;
-      }
-      else
-        tmpResource->param[0] = FONT_DEFAULT_RENDER_SIZE;
-
-      if(File(fullName).isFile())
-        tmpResource->pointer = new Font(fullName, (unsigned int) tmpResource->param[0].getInt());
-      else
-        PRINTF(2)("%s does not exist in %s. Not loading Font\n", fileName.c_str(), this->dataDir.c_str());
-      break;
-#endif /* NO_TEXT */
-#ifndef NO_AUDIO
-    case WAV:
-      if(File(fullName).isFile())
-        tmpResource->pointer = new OrxSound::SoundBuffer(fullName);
-      break;
-    case OGG:
-      if (File(fullName).isFile())
-        tmpResource->pointer = new OrxSound::OggPlayer(fullName);
-      break;
-#endif /* NO_AUDIO */
-#ifndef NO_TEXTURES
-    case IMAGE:
-      if (param0 != MT_NULL)
-        tmpResource->param[0] = param0;
-      else
-        tmpResource->param[0] = GL_TEXTURE_2D;
-      if(File(fullName).isFile())
-      {
-        PRINTF(4)("Image %s resides to %s\n", fileName.c_str(), fullName.c_str());
-        tmpResource->pointer = new Texture(fullName, tmpResource->param[0].getInt());
-      }
-      else
-      {
-        std::vector<std::string>::iterator imageDir;
-        for (imageDir = this->imageDirs.begin(); imageDir != this->imageDirs.end(); imageDir++)
-        {
-          std::string imgName = *imageDir + fileName;
-          if(File(imgName).isFile())
-          {
-            PRINTF(4)("Image %s resides to %s\n", fileName.c_str(), imgName.c_str());
-            tmpResource->pointer = new Texture(imgName, tmpResource->param[0].getInt());
-            break;
-          }
-        }
-      }
-      if(!tmpResource)
-        PRINTF(2)("!!Image %s not Found!!\n", fileName.c_str());
-      break;
-#endif /* NO_TEXTURES */
-#ifndef NO_SHADERS
-    case SHADER:
-      if(File(fullName).isFile())
-      {
-        if (param0 != MT_NULL)
-        {
-          MultiType param = param0; /// HACK
-          std::string secFullName = ResourceManager::getFullName(param.getCString());
-          if (File(secFullName).isFile())
-          {
-            tmpResource->param[0] = secFullName;
-            tmpResource->pointer = new Shader(fullName, secFullName);
-          }
-        }
-        else
-        {
-          tmpResource->param[0] = param0;
-          tmpResource->pointer = new Shader(fullName, "");
-        }
-      }
-      break;
-#endif /* NO_SHADERS */
-    default:
-      tmpResource->pointer = NULL;
-      PRINTF(1)("No type found for %s.\n   !!This should not happen unless the Type is not supported yet. JUST DO IT!!\n", tmpResource->name.c_str());
-      break;
-  }
-  if (tmpResource->pointer != NULL)
-    this->resourceList.push_back(tmpResource);
-
-  if (tmpResource->pointer != NULL)
-    return tmpResource;
-  else
-  {
-    PRINTF(2)("Resource %s could not be loaded\n", fileName.c_str());
-    delete tmpResource;
-    return NULL;
-  }
-}
-
-/**
- * @brief unloads a Resource
- * @param pointer: The pointer to free
- * @param prio: the PriorityLevel to unload this resource
- * @returns true if successful (pointer found, and deleted), false otherwise
-*/
-bool ResourceManager::unload(BaseObject* pointer, ResourcePriority prio)
-{
-  if (pointer == NULL)
-    return false;
-  // if pointer is existent. and only one resource of this type exists.
-  Resource* tmpResource = this->locateResourceByPointer(pointer);
-  if (tmpResource != NULL)
-    return unload(tmpResource, prio);
-  else
-  {
-    PRINTF(2)("Resource not Found %p\n", pointer);
-    return false;
-  }
-}
-
-/**
- * @brief unloads a Resource
- * @param resource: The resource to unloade
- * @param prio the PriorityLevel to unload this resource
- * @returns true on success, false otherwise.
-*/
-bool ResourceManager::unload(Resource* resource, ResourcePriority prio)
-{
-  if (resource == NULL)
-    return false;
-  if (resource->count > 0)
-    resource->count--;
-
-  if (resource->prio <= prio)
-  {
-    if (resource->count == 0)
-    {
-      delete resource->pointer;
-      // deleting the List Entry:
-      PRINTF(4)("Resource %s safely removed.\n", resource->name.c_str());
-      std::vector<Resource*>::iterator resourceIT = std::find(this->resourceList.begin(), this->resourceList.end(), resource);
-      this->resourceList.erase(resourceIT);
-      delete resource;
-    }
-    else
-      PRINTF(4)("Resource %s not removed, because there are still %d References to it.\n", resource->name.c_str(), resource->count);
-  }
-  else
-    PRINTF(4)("not deleting resource %s because DeleteLevel to high\n", resource->name.c_str());
-  return true;
-}
-
-
-/**
- * @brief unloads all alocated Memory of Resources with a pririty lower than prio
- * @param prio The priority to delete
-*/
-bool ResourceManager::unloadAllByPriority(ResourcePriority prio)
-{
-  bool removedAll = true;
-  unsigned int removeCount;
-  for (unsigned int round = 0; round < 3; round++)
-  {
-    int index = this->resourceList.size() - 1;
-    removeCount = 0;
-    while (index >= 0)
-    {
-      if (this->resourceList[index]->prio <= prio)
-      {
-        if (this->resourceList[index]->count == 0)
-          unload(this->resourceList[index], prio);
-        else
-        {
-          if (round == 3)
-          {
-            PRINTF(2)("unable to unload %s because there are still %d references to it\n",
-                      this->resourceList[index]->name.c_str(), this->resourceList[index]->count);
-            removedAll = false;
-          }
-          removeCount++;
-        }
-      }
-      index--;
-    }
-    if (removeCount == 0) break;
-  }
-  return removedAll;
-}
-
-
-/**
- * @brief Searches for a Resource by some information
- * @param fileName: The name to look for
- * @param type the Type of resource to locate.
- * @param param0: an additional option to parse (see the constuctors for more help)
- * @param param1: an additional option to parse (see the constuctors for more help)
- * @param param2: an additional option to parse (see the constuctors for more help)
- * @returns a Pointer to the Resource if found, NULL otherwise.
-*/
-Resource* ResourceManager::locateResourceByInfo(const std::string& fileName, ResourceType type,
-    const MultiType& param0, const MultiType& param1, const MultiType& param2) const
-{
-  std::vector<Resource*>::const_iterator resource;
-  for (resource = this->resourceList.begin(); resource != this->resourceList.end(); resource++)
-  {
-    if ((*resource)->type == type && fileName == (*resource)->name)
-    {
-      bool match = false;
-      switch (type)
-      {
-#ifndef NO_MODEL
-        case PRIM:
-        case OBJ:
-          if (param0 == MT_NULL)
-          {
-            if ((*resource)->param[0] == 1.0f)
-              match = true;
-          }
-          else if ((*resource)->param[0] == param0.getFloat())
-            match = true;
-          break;
-        case MD2:
-          if (param0 == MT_NULL && ((*resource)->param[0] == "") && param1 == MT_NULL && ((*resource)->param[0] == 1.0f))
-              match = true;
-          else if ((*resource)->param[0] == ((MultiType)param0).getString() && (*resource)->param[1] == ((MultiType)param1).getFloat())
-            match = true;
-          break;
-        case MD3:
-          if (param0 == MT_NULL && ((*resource)->param[0] == "") && param1 == MT_NULL && ((*resource)->param[0] == 1.0f))
-            match = true;
-          else if ((*resource)->param[0] == ((MultiType)param0).getString() && (*resource)->param[1] == ((MultiType)param1).getFloat())
-            match = true;
-          break;
-        case MD3_CONFIG:
-          if (param0 == MT_NULL && ((*resource)->param[0] == ""))
-            match = true;
-          else if ((*resource)->param[0] == ((MultiType)param0).getString())
-            match = true;
-          break;
-
-#endif /* NO_MODEL */
-#ifndef NO_TEXT
-        case TTF:
-          if (param0 == MT_NULL)
-          {
-            if ((*resource)->param[0] == FONT_DEFAULT_RENDER_SIZE)
-              match = true;
-          }
-          else if ((*resource)->param[0] == param0.getInt())
-            match = true;
-          break;
-#endif /* NO_TEXT */
-#ifndef NO_SHADERS
-        case SHADER:
-          if (param0 == MT_NULL)
-          {
-            if ((*resource)->param[0] == "")
-              match = true;
-          }
-          else if ((*resource)->param[0] == ((MultiType)param0).getString())
-            match = true;
-          break;
-#endif /* NO_SHADERS */
-#ifndef NO_TEXTURES
-        case IMAGE:
-          if (param0 == MT_NULL)
-          {
-            if ((*resource)->param[0] == GL_TEXTURE_2D)
-              match = true;
-          }
-          else if ((*resource)->param[0] ==  param0.getInt())
-            match = true;
-          break;
-#endif /* NO_TEXTURES */
-        default:
-          match = true;
-          break;
-      }
-      if (match)
-      {
-        return (*resource);
-      }
-    }
-  }
-  return NULL;
-}
-
-/**
- * @brief Searches for a Resource by Pointer
- * @param pointer the Pointer to search for
- * @returns a Pointer to the Resource if found, NULL otherwise.
- */
-Resource* ResourceManager::locateResourceByPointer(const void* pointer) const
-{
-  //  Resource* enumRes = resourceList->enumerate();
-  std::vector<Resource*>::const_iterator resource;
-  for (resource = this->resourceList.begin(); resource != this->resourceList.end(); resource++)
-    if (pointer == (*resource)->pointer)
-      return (*resource);
-  return NULL;
-}
-
-std::string ResourceManager::toResourcableString(unsigned int i)
-{
-/*  int len = strlen(ResourceManager::ResourceTypeToChar(this->resourceList[i]->type));
-  len += this->resourceList[i]->name.size();
-  if (this->resourceList[i]->param[0].getCString()) len += strlen(this->resourceList[i]->param[0].getCString()) +1;
-  if (this->resourceList[i]->param[1].getCString()) len += strlen(this->resourceList[i]->param[1].getCString()) +1;
-  if (this->resourceList[i]->param[2].getCString()) len += strlen(this->resourceList[i]->param[2].getCString()) +1;
-  len += 10;
-  std::string tmp = new char[len];
-  tmp[0] = '\0';
-  strcat(tmp, ResourceManager::ResourceTypeToChar(this->resourceList[i]->type));
-  strcat(tmp,",");
-  strcat (tmp, this->resourceList[i]->name);
-  if (this->resourceList[i]->param[0].getCString() && this->resourceList[i]->param[0].getCString() != '\0')
-  {
-    strcat(tmp,",");
-    strcat( tmp, this->resourceList[i]->param[0].getCString());
-  }
-  if (this->resourceList[i]->param[1].getCString() && this->resourceList[i]->param[1].getCString() != '\0')
-  {
-    strcat(tmp,",");
-    strcat( tmp, this->resourceList[i]->param[1].getCString());
-  }
-  if (this->resourceList[i]->param[2].getCString() && this->resourceList[i]->param[2].getCString() != '\0')
-  {
-    strcat(tmp,",");
-    strcat( tmp, this->resourceList[i]->param[2].getCString());
-  }
-  return tmp;*/
-  return "";
-}
-
-/**
- * @brief caches a Resource from a ResourceableString created with the toResourcableString-function
- * @param resourceableString the String to cache the resource from.
- */
-bool ResourceManager::fromResourceableString(const std::string& resourceableString)
-{
-/*  SubString splits(resourceableString, ',');
-  splits.debug();
-  if (splits.getCount() == 2)
-    this->cache(splits[1], ResourceManager::stringToResourceType(splits[0]),
-                RP_LEVEL);
-  else if (splits.getCount() == 3)
-    return this->cache(splits[1], ResourceManager::stringToResourceType(splits[0]),
-                RP_LEVEL, splits[2]);
-  else if (splits.getCount() == 4)
-    return this->cache(splits[1], ResourceManager::stringToResourceType(splits[0]),
-                RP_LEVEL, splits[2], splits[3]);
-  else if (splits.getCount() == 5)
-    return this->cache(splits[1], ResourceManager::stringToResourceType(splits[0]),
-                RP_LEVEL, splits[2], splits[3], splits[4]);*/
-  return false;
-}
-
-
-/**
- * @param fileName the Name of the File to check
- * @returns The full name of the file, including the DataDir, and NULL if the file does not exist
- * !!IMPORTANT: this has to be deleted from the outside!!
-*/
-std::string ResourceManager::getFullName(const std::string& fileName)
-{
-  if (fileName.empty() || ResourceManager::getInstance()->getDataDir().empty())
-    return "";
-
-  std::string retName = ResourceManager::getInstance()->getDataDir() +fileName;
-  if (File(retName).isFile() || File(retName).isDirectory())
-    return retName;
-  else
-    return "";
-}
-
-
-/**
- * @brief checks wether a file is in the DataDir.
- * @param fileName the File to check if it is in the Data-Dir structure.
- * @returns true if the file exists, false otherwise
- */
-bool ResourceManager::isInDataDir(const std::string& fileName)
-{
-  if (fileName.empty() || ResourceManager::getInstance()->getDataDir().empty())
-    return false;
-
-  bool retVal = false;
-  std::string checkFile = ResourceManager::getInstance()->getDataDir() + fileName;
-
-  if (File(checkFile).exists())
-    retVal = true;
-  else
-    retVal = false;
-  return retVal;
-}
-
-
-/**
- * @brief outputs debug information about the ResourceManager
- */
-void ResourceManager::debug() const
-{
-  PRINT(0)("=RM===================================\n");
-  PRINT(0)("= RESOURCE-MANAGER DEBUG INFORMATION =\n");
-  PRINT(0)("======================================\n");
-  // if it is not initialized
-  PRINT(0)(" Reference is: %p\n", ResourceManager::singletonRef);
-  PRINT(0)(" Data-Directory is: %s\n", this->dataDir.c_str());
-  PRINT(0)(" List of Image-Directories: ");
-  std::vector<std::string>::const_iterator imageDir;
-  for (imageDir = this->imageDirs.begin(); imageDir != this->imageDirs.end(); imageDir++)
-    PRINT(0)("%s ", (*imageDir).c_str());
-  PRINT(0)("\n");
-
-  PRINT(0)("List of all stored Resources:\n");
-  std::vector<Resource*>::const_iterator resource;
-  for (resource = this->resourceList.begin(); resource != this->resourceList.end(); resource++)
-
-  {
-    PRINT(0)("-----------------------------------------\n");
-    PRINT(0)("Name: %s; References: %d; Type: %s ", (*resource)->name.c_str(), (*resource)->count, ResourceManager::ResourceTypeToChar((*resource)->type));
-
-    PRINT(0)("gets deleted at ");
-    switch((*resource)->prio)
-    {
-      default:
-      case RP_NO:
-        PRINT(0)("first posibility (0)\n");
-        break;
-      case RP_LEVEL:
-        PRINT(0)("the end of the Level (1)\n");
-        break;
-      case RP_CAMPAIGN:
-        PRINT(0)("the end of the campaign (2)\n");
-        break;
-      case RP_GAME:
-        PRINT(0)("when leaving the game (3)\n");
-        break;
-    }
-  }
-
-
-
-  PRINT(0)("==================================RM==\n");
-}
-
-
-/**
- * @brief converts a ResourceType into the corresponding String
- * @param type the ResourceType to translate
- * @returns the converted String.
- */
-const char* ResourceManager::ResourceTypeToChar(ResourceType type)
-{
-  return ResourceManager::resourceNames[type];
-}
-
-/**
- * @brief converts a String into a ResourceType (good for loading)
- * @param resourceType the name of the Type
- * @returns the Number of the Type, or 0 (defautl) if not found.
- */
-ResourceType ResourceManager::stringToResourceType(const std::string& resourceType)
-{
-  for (unsigned int i = 0; i < RESOURCE_TYPE_SIZE; i++)
-    if (resourceType == ResourceManager::resourceNames[i])
-      return (ResourceType)i;
-  return (ResourceType)0;
-}
-
-/**
- * The Names of the ResourceTypes
- */
-const char* ResourceManager::resourceNames[] =
-  {
-#ifndef NO_MODEL
-    "ObjectModel",
-    "PrimitiveModel",
-    "MD2-Data",
-    "MD3-Data",
-    "MD3-Config"
-#endif
-#ifndef NO_TEXT
-    "Font",
-#endif
-#ifndef NO_AUDIO
-    "Wav",
-    "mp3",
-    "ogg",
-#endif
-#ifndef NO_TEXTURES
-    "Texture",
-#endif
-#ifndef NO_SHADERS
-    "Shader",
-#endif
-
-  };
Index: trunk/src/lib/util/loading/resource_manager.h
===================================================================
--- trunk/src/lib/util/loading/resource_manager.h	(revision 9675)
+++ trunk/src/lib/util/loading/resource_manager.h	(revision 9869)
@@ -1,157 +1,87 @@
 /*!
  * @file resource_manager.h
-  *  The Resource Manager checks if a file/resource is loaded.
-
-    If a file/resource was already loaded the resourceManager will
-    return a void pointer to the desired resource.
-    Otherwise it will instruct the coresponding resource-loader to load,
-    and receive a pointer to it.
-
-    it is possible to compile the resource Manager without some modules by
-    just adding the compile flag -D....
-    (NO_MODEL)
-    (NO_AUDIO)
-    (NO_TEXT)
-    (NO_TEXTURES)
-    (NO_SHADERS)
-*/
+ */
 
 #ifndef _RESOURCE_MANAGER_H
 #define _RESOURCE_MANAGER_H
 
-#include "base_object.h"
+#include "resource.h"
 #include "filesys/file.h"
+#include "filesys/directory.h"
 
-#include "multi_type.h"
-#include <vector>
+namespace Resources
+{
 
-//! An eumerator for different fileTypes the resourceManager supports
-typedef enum ResourceType
-{
-#ifndef NO_MODEL
-  OBJ,                  //!< loading .obj file
-  PRIM,                 //!< loading primitive model
-  MD2,                  //!< loading md2-file
-  MD3,                  //!< loading md3-file
-  MD3_CONFIG,           //!< the md3 config file
-#endif /* NO_MODEL */
-#ifndef NO_TEXT
-  TTF,                  //!< loading a TrueTypeFont
-#endif /* NO_TEXT */
-#ifndef NO_AUDIO
-  WAV,                  //!< loading wav
-  MP3,                  //!< loading mp3
-  OGG,                  //!< loading ogg
-#endif /* NO_AUDIO */
-#ifndef NO_TEXTURES
-  IMAGE,                //!< loading an image
-#endif /* NO_TEXTURES */
-#ifndef NO_SHADERS
-  SHADER,               //!< openGL-shader program
-#endif /* NO_SHADERS */
-  RESOURCE_TYPE_SIZE
-};
+  class ResourceManager : public BaseObject
+  {
+    ObjectListDeclaration(ResourceManager);
+  public:
+    ///////////////////////
+    //// INSTANZIATION ////
+    /** @returns a Pointer to the only object of this Class */
+    inline static ResourceManager* getInstance() { if (!_singletonRef) _singletonRef = new ResourceManager();  return _singletonRef; };
+    /** @brief deletes the Instance if it exists. */
+    inline static void deleteInstance() { if (_singletonRef) delete _singletonRef; };
 
-//! An enumerator for different UNLOAD-types.
-/**
-   RP_NO:        will be unloaded on request
-   RP_LEVEL:     will be unloaded at the end of a Level
-   RP_CAMPAIGN:  will be unloaded at the end of a Campaign
-   RP_GAME:      will be unloaded at the end of the whole Game (when closing orxonox)
-*/
-typedef enum ResourcePriority
-{
-  RP_NO        =   0,
-  RP_LEVEL     =   1,
-  RP_CAMPAIGN  =   2,
-  RP_GAME      =   4
-};
+    ////////////////////////
+    //// RESOURCE PATHS ////
+    void setMainGlobalPath(const Directory& directory);
+    void addGlobalPath(const Directory& directory);
 
-//! A Struct that keeps track about a resource its name its Type, and so on
-struct Resource
-{
-  BaseObject*       pointer;           //!< Pointer to the Resource.
-  unsigned int      count;             //!< How many times this Resource has been loaded.
+    bool addResourcePath(const std::string& resourceName, const std::string& pathName);
+    bool addResourceSubPath(const std::string& resourceName, const std::string& pathName);
+    void registerType(Resources::Type* type);
+    void unregisterType(Resources::Type* type);
 
-  std::string       name;              //!< Name of the Resource.
-  ResourceType      type;              //!< ResourceType of this Resource.
-  ResourcePriority  prio;              //!< The Priority of this resource. (This will only be increased)
+    /** @returns the main global search Path */
+    const Directory& mainGlobalPath() const { return _mainGlobalPath; };
+    /** @returns all global paths without mainGlobalPath */
+    const std::vector<Directory>& globalPaths() const { return _globalPaths; };
 
-  MultiType         param[3];          //!< The Parameters given to this Resource.
-};
+    ////////////////////
+    //// KEEPLEVELS ////
+    unsigned int addKeepLevelName(const std::string& keepLevelName);
+    unsigned int getKeepLevelID(const std::string& keepLevelName) const;
+    const std::string& getKeepLevelName(unsigned int keepLevelID) const;
+    void setDefaultKeepLevel(const KeepLevel& keepLevel) { this->_defaultKeepLevel = keepLevel; };
+    const KeepLevel& defaultKeepLevel() const { return this->_defaultKeepLevel; };
 
+    //////////////////////////
+    //// GENERAL QUERIES ////
+    /** @returns the Types of Resources */
+    const std::vector<Resources::Type*> resourceTypes() const { return _resourceTypes; };
 
-//! The ResourceManager is a class, that decides if a file/resource should be loaded
-/**
- * If a file/resource was already loaded the resourceManager will
- * return a pointer to the desired resource.
- * Otherwise it will instruct the corresponding resource-loader to load,
- * and receive the pointer to it.
- *
- * It does it by looking, if a desired file has already been loaded.
- * There is also the possibility to check for some variables
- */
-class ResourceManager : public BaseObject
-{
- public:
-  virtual ~ResourceManager();
-  /** @returns a Pointer to the only object of this Class */
-  inline static ResourceManager* getInstance() { if (!singletonRef) singletonRef = new ResourceManager();  return singletonRef; };
+    bool checkFileInMainPath(const File& fileInside);
+    std::string prependAbsoluteMainPath(const std::string& fileName);
 
-  bool setDataDir(const std::string& dataDir);
-  /** @returns the Name of the data directory */
-  inline const std::string& getDataDir() const { return this->dataDir; };
+    ////////////////////////////////////////
+    //// RESOURCE LOADING AND UNLOADING ////
+    void loadFromLoadString(const std::string& resourceTypeName, const std::string& loadString, const KeepLevel& keepLevel = KeepLevel());
+    void loadFromLoadStringHACK(const std::string& resourceTypeName, const std::string& loadString) { this->loadFromLoadString(resourceTypeName, loadString); };
 
+    void unloadAllBelowKeepLevel(const Resources::KeepLevel& keepLevel);
+    void unloadAllBelowKeepLevelINT(unsigned int level) { unloadAllBelowKeepLevel(level); };
 
-  bool tryDataDir(const std::string& dataDir);
-  bool verifyDataDir(const std::string& fileInside);
-  bool addImageDir(const std::string& imageDir);
+    ///////////////
+    //// DEBUG ////
+    void debug() const;
 
-  bool cache(const std::string& fileName, ResourceType type, ResourcePriority prio = RP_NO,
-             const MultiType& param0 = MultiType(), const MultiType& param1 = MultiType(), const MultiType& param2 = MultiType());
-  BaseObject* copy(BaseObject* resourcePointer);
+  private:
+    ResourceManager();
+    virtual ~ResourceManager();
 
-  BaseObject* load(const std::string& fileName, ResourcePriority prio = RP_NO,
-                   const MultiType& param0 = MultiType(), const MultiType& param1 = MultiType(), const MultiType& param2 = MultiType());
-  BaseObject* load(const std::string& fileName, ResourceType type, ResourcePriority prio = RP_NO,
-                   const MultiType& param0 = MultiType(), const MultiType& param1 = MultiType(), const MultiType& param2 = MultiType());
-  bool unload(BaseObject* pointer, ResourcePriority prio = RP_NO);
-  bool unload(Resource* resource, ResourcePriority = RP_NO);
-  bool unloadAllByPriority(ResourcePriority prio);
+  private:
+    static ResourceManager*            _singletonRef;       //!< singleton Reference
 
-  Resource* locateResourceByInfo(const std::string& fileName, ResourceType type,
-                                 const MultiType& param0 = MultiType(), const MultiType& param1 = MultiType(), const MultiType& param2 = MultiType()) const;
-  Resource* locateResourceByPointer(const void* pointer) const;
+    Directory                          _mainGlobalPath;     //!< The main include directory (default at "./")
+    std::vector<Directory>             _globalPaths;        //!< Additional Global include directories.
 
-  std::string toResourcableString(unsigned int i);
-  bool fromResourceableString(const std::string& resourceableString);
-  /** @returns the Count of Resources the ResourceManager handles */
-  unsigned int resourceCount() const { return this->resourceList.size(); }
+    std::vector<Resources::Type*>      _resourceTypes;      //!< A Vector of all the stored ResourceTypes @see Resources::Type
 
-  void debug() const;
+    std::vector<std::string>           _keepLevelNames;     //!< Names of KeepLevels @see Resources::KeepLevel
+    KeepLevel                          _defaultKeepLevel;   //!< The default KeepLevel.
+  };
 
-
-  // utility functions for handling files in and around the data-directory
-  static std::string getFullName(const std::string& fileName);
-  static bool isInDataDir(const std::string& fileName);
-
-  static const char* ResourceTypeToChar(ResourceType type);
-  static ResourceType stringToResourceType(const std::string& resourceType);
-
- private:
-  ResourceManager();
-  Resource* loadResource(const std::string& fileName, ResourceType type, ResourcePriority prio,
-                         const MultiType& param0, const MultiType& param1, const MultiType& param2);
-
- private:
-  static ResourceManager*    singletonRef;       //!< singleton Reference
-
-  std::string                dataDir;            //!< The Data Directory, where all relevant Data is stored.
-  std::vector<std::string>   imageDirs;          //!< A list of directories in which images are stored.
-
-  std::vector<Resource*>     resourceList;       //!< The List of Resources, that has already been loaded.
-
-  static const char*         resourceNames[RESOURCE_TYPE_SIZE];
-};
+}
 
 #endif /* _RESOURCE_MANAGER_H */
