Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/new_class_id/src/lib/util/loading/new_resource_manager.cc @ 9792

Last change on this file since 9792 was 9792, checked in by bensch, 18 years ago

removed dependency from ClassID

File size: 3.3 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: Benjamin Grauer
13   co-programmer: Patrick Boenzli
14*/
15
16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_LOAD
17
18#include "new_resource_manager.h"
19#include "debug.h"
20
21#include <algorithm>
22#include <assert.h>
23
24//ObjectListDefinition(NewResourceManager);
25
26
27//! Singleton Reference to the NewResourceManager
28NewResourceManager* NewResourceManager::_singletonRef = NULL;
29
30
31/**
32 * @brief standard constructor
33*/
34NewResourceManager::NewResourceManager ()
35{
36//  this->registerObject(this, NewResourceManager::_objectList);
37  this->setName("NewResourceManager");
38
39  //this->dataDir = "./";
40}
41
42
43/**
44 * @brief standard destructor
45*/
46NewResourceManager::~NewResourceManager ()
47{
48  // deleting the Resources-List
49  //this->unloadAllByPriority(RP_GAME);
50
51//   if (!this->resourceList.empty())
52//     PRINTF(1)("Not removed all Resources, since there are still %d resources registered\n", this->resourceList.size());
53
54  NewResourceManager::_singletonRef = NULL;
55}
56
57
58
59
60void NewResourceManager::registerType(Resources::Type* type)
61{
62  if(type->id() == -1)
63  {
64    type->setID(this->_resourceTypes.size());
65    this->_resourceTypes.push_back(type);
66  }
67}
68
69void NewResourceManager::setMainGlobalPath(const Directory& directory)
70{
71  this->_mainGlobalPath = directory;
72  this->_mainGlobalPath.open();
73}
74
75void NewResourceManager::addGlobalPath(const Directory& directory)
76{
77  std::vector<Directory>::const_iterator it = std::find(this->_globalPaths.begin(), this->_globalPaths.end(), directory);
78  if (it == this->_globalPaths.end())
79    this->_globalPaths.push_back(directory);
80}
81
82
83bool NewResourceManager::addResourcePath(const std::string& resourceName, const std::string& pathName)
84{
85  std::vector<Resources::Type*>::iterator it;
86  for (it = this->_resourceTypes.begin(); it != this->_resourceTypes.end(); ++it)
87    if (*(*it) == resourceName)
88      return (*it)->addResourcePath(pathName);
89  PRINTF(2)("ResourcePath %s could not be added to the ResourceType %s\n", pathName.c_str(), resourceName.c_str());
90  return false;
91}
92
93bool NewResourceManager::addResourceSubPath(const std::string& resourceName, const std::string& pathName)
94{
95  std::vector<Resources::Type*>::iterator it;
96  for (it = this->_resourceTypes.begin(); it != this->_resourceTypes.end(); ++it)
97    if (*(*it) == resourceName)
98      return (*it)->addResourceSubPath(pathName);
99  PRINTF(2)("ResourceSubPath %s could not be added to the ResourceType %s\n", pathName.c_str(), resourceName.c_str());
100  return false;
101}
102
103
104/**
105 * @brief outputs debug information about the NewResourceManager
106 */
107void NewResourceManager::debug() const
108{
109  PRINT(0)("=RM===================================\n");
110  PRINT(0)("= RESOURCE-MANAGER DEBUG INFORMATION =\n");
111  PRINT(0)("======================================\n");
112  PRINT(0)("Listing %d Types: \n", this->_resourceTypes.size());
113  std::vector<Resources::Type*>::const_iterator it;
114  for (it = this->_resourceTypes.begin(); it != this->_resourceTypes.end(); ++it)
115    PRINT(0)("ResourceType '%s'\n", (*it)->storedClassName().c_str());
116
117  PRINT(0)("==================================RM==\n");
118}
Note: See TracBrowser for help on using the repository browser.