Преглед на файлове

ResourceManager maintains its own allocators and that should be the rule for all high-level systems

Daniele Bartolini преди 12 години
родител
ревизия
55bd23509c
променени са 4 файла, в които са добавени 8 реда и са изтрити 10 реда
  1. 1 1
      src/Device.cpp
  2. 0 1
      src/Device.h
  3. 3 4
      src/ResourceManager.cpp
  4. 4 4
      src/ResourceManager.h

+ 1 - 1
src/Device.cpp

@@ -396,7 +396,7 @@ void Device::create_resource_manager()
 	}
 
 	// Create resource manager
-	m_resource_manager = new ResourceManager(*m_resource_archive, m_resource_allocator);
+	m_resource_manager = new ResourceManager(*m_resource_archive);
 
 	Log::d("Resource manager created.");
 	Log::d("Resource seed: %d", m_resource_manager->seed());

+ 0 - 1
src/Device.h

@@ -146,7 +146,6 @@ private:
 	// Private subsystems
 	ResourceManager*		m_resource_manager;
 	ResourceArchive*		m_resource_archive;
-	MallocAllocator			m_resource_allocator;
 
 	// The game currently running
 	void*					m_game_library;

+ 3 - 4
src/ResourceManager.cpp

@@ -44,9 +44,8 @@ namespace crown
 {
 
 //-----------------------------------------------------------------------------
-ResourceManager::ResourceManager(ResourceArchive& archive, Allocator& allocator) :
+ResourceManager::ResourceManager(ResourceArchive& archive) :
 	m_resource_archive(archive),
-	m_resource_allocator(allocator),
 	m_resources(m_allocator),
 	m_loading_queue(m_allocator),
 	m_loaded_queue(m_allocator),
@@ -337,7 +336,7 @@ void ResourceManager::background_load()
 }
 
 //-----------------------------------------------------------------------------
-void* ResourceManager::load_by_type(ResourceId name) const
+void* ResourceManager::load_by_type(ResourceId name)
 {
 	if (name.type == TEXTURE_TYPE)
 	{
@@ -356,7 +355,7 @@ void* ResourceManager::load_by_type(ResourceId name) const
 }
 
 //-----------------------------------------------------------------------------
-void ResourceManager::unload_by_type(ResourceId name, void* resource) const
+void ResourceManager::unload_by_type(ResourceId name, void* resource)
 {
 	if (name.type == TEXTURE_TYPE)
 	{

+ 4 - 4
src/ResourceManager.h

@@ -71,7 +71,7 @@ class ResourceManager
 public:
 
 	/// Read resources from @archive and store resource data using @allocator.
-							ResourceManager(ResourceArchive& archive, Allocator& allocator);
+							ResourceManager(ResourceArchive& archive);
 							~ResourceManager();
 
 	/// Loads the resource by @name and returns its ResourceId.
@@ -136,8 +136,8 @@ private:
 
 	void					background_load();
 
-	void*					load_by_type(ResourceId name) const;
-	void					unload_by_type(ResourceId name, void* resource) const;
+	void*					load_by_type(ResourceId name);
+	void					unload_by_type(ResourceId name, void* resource);
 	void					online(ResourceId name, void* resource);
 
 private:
@@ -149,7 +149,7 @@ private:
 	// Archive whether to look for resources
 	ResourceArchive&		m_resource_archive;
 	// Used to strore resource memory
-	Allocator&				m_resource_allocator;
+	MallocAllocator			m_resource_allocator;
 
 	MallocAllocator			m_allocator;
 	// The master lookup table