Index: trunk/src/lib/util/loading/factory.h
===================================================================
--- trunk/src/lib/util/loading/factory.h	(revision 8148)
+++ 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);
+  }
 };
 
