Index: /code/branches/objecthierarchy/src/orxonox/CMakeLists.txt
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/CMakeLists.txt	(revision 1969)
+++ /code/branches/objecthierarchy/src/orxonox/CMakeLists.txt	(revision 1970)
@@ -42,4 +42,6 @@
   tools/Timer.cc
   tools/WindowEventListener.cc
+
+  objects/Template.cc
 
   objects/worldentities/WorldEntity.cc
Index: /code/branches/objecthierarchy/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/OrxonoxPrereqs.h	(revision 1969)
+++ /code/branches/objecthierarchy/src/orxonox/OrxonoxPrereqs.h	(revision 1970)
@@ -81,4 +81,6 @@
 
     // objects
+    class Template;
+
     class WorldEntity;
     class PositionableEntity;
Index: /code/branches/objecthierarchy/src/orxonox/objects/Template.cc
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/objects/Template.cc	(revision 1970)
+++ /code/branches/objecthierarchy/src/orxonox/objects/Template.cc	(revision 1970)
@@ -0,0 +1,136 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   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
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Template.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "util/Debug.h"
+
+namespace orxonox
+{
+    CreateFactory(Template);
+
+    Template::Template()
+    {
+        RegisterObject(Template);
+
+        this->bIsLink_ = false;
+        this->bIsReturningXMLElement_ = false;
+        this->baseclassIdentifier_ = 0;
+    }
+
+    Template::~Template()
+    {
+    }
+
+    void Template::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(Template, XMLPort, xmlelement, mode);
+
+        XMLPortParam(Template, "link", setLink, getLink, xmlelement, mode);
+        XMLPortParam(Template, "baseclass", setBaseclass, getBaseclass, xmlelement, mode);
+
+        this->setXMLElement(*xmlelement.FirstChildElement(false));
+    }
+
+    const Element& Template::getXMLElement() const
+    {
+        if (this->bIsLink_)
+        {
+            Template* temp = Template::getTemplate(this->link_);
+            if (temp)
+            {
+                if (!temp->bIsReturningXMLElement_)
+                {
+                    this->bIsReturningXMLElement_ = true;
+                    const Element& element = temp->getXMLElement();
+                    this->bIsReturningXMLElement_ = false;
+                    return element;
+                }
+                else
+                {
+                    COUT(2) << "Warning: Linking from " << this->getName() << " to " << this->link_ << " leads to an infinite loop. Returning own element." << std::endl;
+                }
+            }
+            else
+            {
+                COUT(2) << "Warning: " << this->link_ << " is not an existing Template name. Returning own element." << std::endl;
+            }
+        }
+
+        return this->xmlelement_;
+    }
+
+    void Template::setBaseclass(const std::string& baseclass)
+    {
+        this->baseclassIdentifier_ = ClassByString(baseclass);
+        if (this->baseclassIdentifier_)
+            this->baseclass_ = baseclass;
+    }
+
+    void Template::applyOn(BaseObject* object)
+    {
+        if (this->baseclassIdentifier_)
+        {
+            if (!object->isA(this->baseclassIdentifier_))
+            {
+                COUT(1) << "Error: Can't apply template (name: " << this->getName() << "), object (name: " << object->getName() << ", class: " << object->getIdentifier()->getName() << ") is not a " << this->baseclassIdentifier_->getName() << std::endl;
+                return;
+            }
+        }
+
+        COUT(4) << object->getLoaderIndentation() << " aplying Template \"" << this->getName() << "\"..." << std::endl;
+
+        Element temp = this->getXMLElement();
+        object->XMLPort(temp, XMLPort::LoadObject);
+    }
+
+    std::map<std::string, Template*>& Template::getTemplateMap()
+    {
+        static std::map<std::string, Template*> templateMap;
+        return templateMap;
+    }
+
+    Template* Template::getTemplate(const std::string& name)
+    {
+        std::map<std::string, Template*>::iterator it = Template::getTemplateMap().find(name);
+        if (it != Template::getTemplateMap().end())
+            return it->second;
+        else
+            return 0;
+    }
+
+    void Template::apply(const std::string& name, BaseObject* object)
+    {
+        std::map<std::string, Template*>::iterator it = Template::getTemplateMap().find(name);
+        if (it != Template::getTemplateMap().end())
+            it->second->applyOn(object);
+    }
+}
Index: /code/branches/objecthierarchy/src/orxonox/objects/Template.h
===================================================================
--- /code/branches/objecthierarchy/src/orxonox/objects/Template.h	(revision 1970)
+++ /code/branches/objecthierarchy/src/orxonox/objects/Template.h	(revision 1970)
@@ -0,0 +1,79 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   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
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Template_H__
+#define _Template_H__
+
+#include <map>
+
+#include "OrxonoxPrereqs.h"
+#include "core/BaseObject.h"
+#include "tinyxml/ticpp.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport Template : public BaseObject
+    {
+        public:
+            Template();
+            virtual ~Template();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+            inline void setLink(const std::string& link)
+                { this->link_ = link; this->bIsLink_ = (link != ""); }
+            inline const std::string& getLink() const
+                { return this->link_; }
+
+            inline void setXMLElement(const Element& xmlelement)
+                { this->xmlelement_ = xmlelement; }
+            const Element& getXMLElement() const;
+
+            void setBaseclass(const std::string& baseclass);
+            inline const std::string& getBaseclass() const
+                { return this->baseclass_; }
+            inline Identifier* getBaseclassIdentifier() const
+                { return this->baseclassIdentifier_; }
+
+            void applyOn(BaseObject* object);
+
+            static std::map<std::string, Template*>& getTemplateMap();
+            static Template* getTemplate(const std::string& name);
+            static void apply(const std::string& name, BaseObject* object);
+
+        private:
+            Element xmlelement_;
+            std::string link_;
+            std::string baseclass_;
+            Identifier* baseclassIdentifier_;
+            bool bIsLink_;
+            mutable bool bIsReturningXMLElement_;
+    };
+}
+
+#endif /* _Template_H__ */
