Index: branches/new_class_id/src/lib/util/loading/resource.cc
===================================================================
--- branches/new_class_id/src/lib/util/loading/resource.cc	(revision 9789)
+++ branches/new_class_id/src/lib/util/loading/resource.cc	(revision 9790)
@@ -14,12 +14,11 @@
 */
 
-#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_LOADING
+#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_LOAD
 
 #include "resource.h"
 #include "filesys/file.h"
+#include "debug.h"
 
 ObjectListDefinition(NewResource);
-
-
 std::vector<NewResource::Type*>    NewResource::_resourceTypes;
 
@@ -36,10 +35,4 @@
 {
   this->registerObject(this, NewResource::_objectList);
-
-  if(this->_type->id() == -1)
-  {
-    NewResource::_resourceTypes.push_back(this->_type);
-    this->_type->setID(NewResource::_resourceTypes.size()-1);
-  }
 }
 
@@ -53,14 +46,36 @@
 
 
-std::string NewResource::locateFile(const std::string& fileName)
+std::string NewResource::locateFile(const std::string& fileName) const
 {
   if (File(fileName).exists())
     return fileName;
-  else if ((NewResource::_mainGlobalPath+File(fileName)) . exists() )
+  else if ((NewResource::_mainGlobalPath + File(fileName)).exists() )
     return (NewResource::_mainGlobalPath + File(fileName)).name();
 
+  printf("LOCATED %s\n", locateFileInSubDir(Directory("/home/bensch/svn/orxonox/data/"), fileName).c_str());
+
   return std::string("/home/bensch/svn/orxonox/data/") + fileName;
-
-}
+}
+
+/**
+ * @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 NewResource::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);
+    printf("Testing %s (from %s in directory %s)\n", file.name().c_str(), fileName.c_str(), dir.name().c_str());
+    if ((dir+ File(fileName)).exists())
+      return (dir+File(fileName)).name();
+  }
+  return "";
+}
+
 
 
@@ -99,12 +114,57 @@
 
 
-
-
-
-
-
-
-
-std::vector<std::string>  NewResource::KeepLevel::_keepLevelNames;
+void NewResource::registerType(NewResource::Type* type)
+{
+  NewResource::debug();
+  if(type->id() == -1)
+  {
+    NewResource::_resourceTypes.push_back(type);
+    type->setID(NewResource::_resourceTypes.size()-1);
+  }
+  NewResource::debug();
+}
+
+bool NewResource::addResourcePath(const std::string& resourceName, const std::string& pathName)
+{
+  std::vector<NewResource::Type*>::iterator it;
+  for (it = NewResource::_resourceTypes.begin(); it != NewResource::_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;
+}
+
+bool NewResource::addResourceSubPath(const std::string& resourceName, const std::string& pathName)
+{
+  std::vector<NewResource::Type*>::iterator it;
+  for (it = NewResource::_resourceTypes.begin(); it != NewResource::_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;
+}
+
+
+
+void NewResource::debug()
+{
+  PRINT(0)("==================================\n");
+  PRINT(0)("DEBUG output for all Resources\n");
+  PRINT(0)("==================================\n");
+
+  PRINT(0)("Listing %d Types: \n", NewResource::_resourceTypes.size());
+  std::vector<NewResource::Type*>::iterator it;
+  for (it = NewResource::_resourceTypes.begin(); it != NewResource::_resourceTypes.end(); ++it)
+    PRINT(0)("ResourceType '%s'\n", (*it)->storedClassID().name().c_str());
+
+  PRINT(0)("==================================\n");
+
+}
+
+
+
+
+
+std::vector<std::string> NewResource::KeepLevel::_keepLevelNames;
 void NewResource::KeepLevel::defineKeepLevelName(unsigned int level, const std::string& name)
 {
@@ -115,4 +175,9 @@
 
 
+NewResource::Type::Type(const ClassID& classID)
+    : _id(-1), _classID(classID)
+{
+  NewResource::registerType(this);
+}
 
 void NewResource::Type::addResource(NewResource::StorePointer* resource)
@@ -121,4 +186,26 @@
 
 }
+
+bool NewResource::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;
+
+}
+
+bool NewResource::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;
+}
+
 
 
