Index: trunk/src/util/loading/factory.h
===================================================================
--- trunk/src/util/loading/factory.h	(revision 5944)
+++ trunk/src/util/loading/factory.h	(revision 5982)
@@ -28,4 +28,5 @@
 #include "base_object.h"
 #include "debug.h"
+#include <vector>
 
 /**
@@ -40,29 +41,23 @@
 
  public:
-  Factory (const char* factoryName = NULL, ClassID classID = CL_NULL);
+  Factory (const char* factoryName, ClassID classID);
   virtual ~Factory ();
 
-  void fabricate(const char* className, const char* entityName);
-  virtual BaseObject* fabricate(ClassID classID) = NULL;
-  virtual BaseObject* fabricate(const TiXmlElement* root) = NULL;
-  virtual BaseObject* fabricateDirect() = NULL;
+  static void deleteFactories();
 
-  static void registerFactory( Factory* factory);
-  /** @returns the first factory */
-  static Factory* getFirst() { return Factory::first; };
+  static  BaseObject* fabricate(const char* className);
+  static  BaseObject* fabricate(ClassID classID);
+  static  BaseObject* fabricate(const TiXmlElement* root = NULL);
+
+  bool operator==(ClassID classID) const { return (this->classID == classID); };
+  bool operator==(const char* className) const;
 
   protected:
-    /** sets the Next factory in the list @param nextFactory the next factory */
-    inline void setNext( Factory* nextFactory) { this->next = nextFactory; };
-    /** @returns the next factory */
-    Factory* getNext() const { return this->next; };
-
+    virtual BaseObject* fabricateObject(const TiXmlElement* root = NULL) const = 0;
 
   protected:
-    ClassID           classID;              //!< The CLass-Identifyer of the Factory.
-
-  private:
-    Factory*          next;                 //!< pointer to the next factory.
-    static Factory*   first;                //!< A pointer to the first factory.
+    ClassID                       classID;              //!< The Class-Identifyer of the Factory.
+    const char*                   className;            //!< The name of the Class.
+    static std::list<Factory*>*   factoryList;          //!< List of Registered Factories
 };
 
@@ -73,75 +68,21 @@
 template<class T> class tFactory : public Factory
 {
-  public:
-    tFactory(const char* factoryName, ClassID classID);
-    virtual ~tFactory();
+ public:
+  tFactory (const char* factoryName, ClassID classID)
+   : Factory(factoryName, classID)
+  {
+  }
 
   private:
-    virtual BaseObject* fabricate(ClassID classID);
-    virtual BaseObject* fabricate(const TiXmlElement* root);
-    virtual BaseObject* fabricateDirect();
+   /**
+    * 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);
+    }
 };
-
-/**
- *  construnts a factory with
- * @param factoryName the name of the factory
-*/
-template<class T>
-    tFactory<T>::tFactory(const char* factoryName, ClassID classID) : Factory(factoryName, classID)
-{
-  PRINTF(4)("Class: %s loadable\n", this->getName());
-}
-
-/**
- * destructs the type-Factory
- */
-template<class T>
-    tFactory<T>::~tFactory()
-{}
-
-/**
- * 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, NULL otherwise.
- */
-template<class T>
-    BaseObject* tFactory<T>::fabricate(const TiXmlElement* root)
-{
-  if (root == NULL)
-    return NULL;
-
-  if(!strcmp(root->Value(), this->getName()))
-    return new T ( root);
-  else if( getNext() != NULL)
-    return getNext()->fabricate( root);
-  else
-    return NULL;
-}
-
-
-/**
- * fabricates an Object of type T, with the constructor T::T(const TiXmlElemnt*)
- * @param classID the ClassID of T that should be created.
- * @return the newly fabricated T if fabricated NULL otherwise.
- */
-template<class T>
-    BaseObject* tFactory<T>::fabricate(ClassID classID)
-{
-  if(classID == this->classID)
-    return this->fabricateDirect();
-  else if( getNext() != NULL)
-    return getNext()->fabricate( classID);
-  else
-    return NULL;
-}
-
-/**
- * directly fabricate an Entity of this factory.
- */
-template<class T>
-    BaseObject* tFactory<T>::fabricateDirect()
-{
-  return new T((const TiXmlElement*)NULL);
-}
 
 #endif /* _FACTORY_H */
