Переглянути джерело

Make load(name, type) private

Daniele Bartolini 12 роки тому
батько
коміт
d9f633b9d9
2 змінених файлів з 40 додано та 41 видалено
  1. 37 37
      src/ResourceManager.cpp
  2. 3 4
      src/ResourceManager.h

+ 37 - 37
src/ResourceManager.cpp

@@ -74,43 +74,6 @@ ResourceId ResourceManager::load(const char* name)
 	return load(name_hash, type_hash);
 }
 
-//-----------------------------------------------------------------------------
-ResourceId ResourceManager::load(uint32_t name, uint32_t type)
-{
-	// Search for an already existent resource
-	ResourceEntry* entry = std::find(m_resources.begin(), m_resources.end(), name);
-
-	// If resource not found, create a new one
-	if (entry == m_resources.end())
-	{
-		ResourceId id;
-
-		id.name = name;
-		id.type = type;
-		id.index = m_resources.size();
-
-		ResourceEntry entry;
-
-		entry.id = id;
-		entry.state = RS_UNLOADED;
-		entry.references = 1;
-		entry.resource = NULL;
-
-		m_resources.push_back(entry);
-
-		m_loading_mutex.lock();
-		m_loading_queue.push_back(id);
-		m_loading_mutex.unlock();
-
-		return id;
-	}
-
-	// Else, increment its reference count
-	entry->references++;
-	
-	return entry->id;
-}
-
 //-----------------------------------------------------------------------------
 void ResourceManager::unload(ResourceId name)
 {
@@ -207,6 +170,43 @@ void ResourceManager::bring_loaded_online()
 	m_loaded_mutex.unlock();
 }
 
+//-----------------------------------------------------------------------------
+ResourceId ResourceManager::load(uint32_t name, uint32_t type)
+{
+	// Search for an already existent resource
+	ResourceEntry* entry = std::find(m_resources.begin(), m_resources.end(), name);
+
+	// If resource not found, create a new one
+	if (entry == m_resources.end())
+	{
+		ResourceId id;
+
+		id.name = name;
+		id.type = type;
+		id.index = m_resources.size();
+
+		ResourceEntry entry;
+
+		entry.id = id;
+		entry.state = RS_UNLOADED;
+		entry.references = 1;
+		entry.resource = NULL;
+
+		m_resources.push_back(entry);
+
+		m_loading_mutex.lock();
+		m_loading_queue.push_back(id);
+		m_loading_mutex.unlock();
+
+		return id;
+	}
+
+	// Else, increment its reference count
+	entry->references++;
+	
+	return entry->id;
+}
+
 //-----------------------------------------------------------------------------
 void ResourceManager::background_load()
 {

+ 3 - 4
src/ResourceManager.h

@@ -80,10 +80,6 @@ public:
 	/// You have to explicitly call is_loaded() method to check if the
 	/// loading process is actually completed.
 	ResourceId				load(const char* name);
-	
-	/// Loads the resource by @name and @type and returns its ResourceId.
-	/// See ResourceManager::load(const char* name) for details.
-	ResourceId				load(uint32_t name, uint32_t type);
 
 	/// Unloads the @resource, freeing up all the memory associated by it
 	/// and eventually any global object associated with it.
@@ -119,6 +115,9 @@ public:
 
 private:
 
+	// Loads the resource by name and type and returns its ResourceId.
+	ResourceId				load(uint32_t name, uint32_t type);
+
 	void					background_load();
 
 	void*					load_by_type(ResourceId name) const;