Răsfoiți Sursa

Rename ResourceArchive to Bundle and *ResourceArchive to *Bundle

Daniele Bartolini 12 ani în urmă
părinte
comite
0c6af63661

+ 1 - 1
samples/lua/lua.cpp

@@ -21,7 +21,7 @@ int main(int argc, char** argv)
 
   Filesystem fs("/home/mikymod/test/res_compiled");
 
-  FileResourceArchive archive(fs);
+  FileBundle archive(fs);
 
   ResourceManager res_manager(archive);
 

+ 5 - 5
src/ArchiveResourceArchive.cpp → src/ArchiveBundle.cpp

@@ -23,7 +23,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
-#include "ArchiveResourceArchive.h"
+#include "ArchiveBundle.h"
 #include "Filesystem.h"
 #include "Resource.h"
 #include "DiskFile.h"
@@ -34,7 +34,7 @@ namespace crown
 {
 
 //-----------------------------------------------------------------------------
-ArchiveResourceArchive::ArchiveResourceArchive(Filesystem& fs) :
+ArchiveBundle::ArchiveBundle(Filesystem& fs) :
 	m_filesystem(fs),
 	m_archive_file(NULL),
 	m_entries_count(0),
@@ -62,7 +62,7 @@ ArchiveResourceArchive::ArchiveResourceArchive(Filesystem& fs) :
 }
 
 //-----------------------------------------------------------------------------
-ArchiveResourceArchive::~ArchiveResourceArchive()
+ArchiveBundle::~ArchiveBundle()
 {
 	if (m_archive_file != NULL)
 	{
@@ -79,7 +79,7 @@ ArchiveResourceArchive::~ArchiveResourceArchive()
 }
 
 //-----------------------------------------------------------------------------
-DiskFile* ArchiveResourceArchive::open(ResourceId name)
+DiskFile* ArchiveBundle::open(ResourceId name)
 {
 	// Search the resource in the archive
 	for (uint32_t i = 0; i < m_entries_count; i++)
@@ -97,7 +97,7 @@ DiskFile* ArchiveResourceArchive::open(ResourceId name)
 }
 
 //-----------------------------------------------------------------------------
-void ArchiveResourceArchive::close(DiskFile* resource)
+void ArchiveBundle::close(DiskFile* resource)
 {
 	// Does nothing, the stream is automatically closed at exit.
 	(void)resource;

+ 6 - 6
src/ArchiveResourceArchive.h → src/ArchiveBundle.h

@@ -26,7 +26,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 
 #include "Types.h"
-#include "ResourceArchive.h"
+#include "Bundle.h"
 #include "MallocAllocator.h"
 
 namespace crown
@@ -55,17 +55,17 @@ class DiskFile;
 /// recent version of the engine with older game archives.
 
 /// Source of resources
-class ArchiveResourceArchive : public ResourceArchive
+class ArchiveBundle : public Bundle
 {
 public:
 
-					ArchiveResourceArchive(Filesystem& fs);
-					~ArchiveResourceArchive();
+					ArchiveBundle(Filesystem& fs);
+					~ArchiveBundle();
 
-	/// @copydoc ResourceArchive::open()
+	/// @copydoc Bundle::open()
 	DiskFile*		open(ResourceId name);
 
-	/// @copydoc ResourceArchive::close()
+	/// @copydoc Bundle::close()
 	void			close(DiskFile* resource);
 
 private:

+ 2 - 2
src/ResourceArchive.h → src/Bundle.h

@@ -51,11 +51,11 @@ struct ArchiveEntry
 class Filesystem;
 class DiskFile;
 
-class ResourceArchive
+class Bundle
 {
 public:
 
-	virtual					~ResourceArchive() {}
+	virtual					~Bundle() {}
 
 	/// Opens the resource file containing @name resource
 	/// and returns a stream from which read the data from.

+ 5 - 5
src/CMakeLists.txt

@@ -9,8 +9,8 @@ set (SRC
 	TextResource.cpp
 	ScriptResource.cpp
 	FontResource.cpp
-	ArchiveResourceArchive.cpp
-	FileResourceArchive.cpp
+	ArchiveBundle.cpp
+	FileBundle.cpp
 
 	FPSSystem.cpp
 	JSONParser.cpp
@@ -25,15 +25,15 @@ set (HEADERS
 	MaterialResource.h
 	Resource.h
 	ResourceManager.h
-	ResourceArchive.h
+	Bundle.h
 	Skybox.h
 
 	TextureResource.h
 	TextResource.h
 	ScriptResource.h
 	FontResource.h
-	ArchiveResourceArchive.h
-	FileResourceArchive.h
+	ArchiveBundle.h
+	FileBundle.h
 
 	FPSSystem.h
 	JSONParser.h

+ 3 - 3
src/Crown.h

@@ -99,9 +99,9 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Camera.h"
 #include "Device.h"
 #include "Glyph.h"
-#include "ResourceArchive.h"
-#include "ArchiveResourceArchive.h"
-#include "FileResourceArchive.h"
+#include "Bundle.h"
+#include "ArchiveBundle.h"
+#include "FileBundle.h"
 #include "ResourceManager.h"
 #include "Skybox.h"
 

+ 8 - 8
src/Device.cpp

@@ -38,8 +38,8 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Args.h"
 #include "Game.h"
 #include <cstdlib>
-#include "ArchiveResourceArchive.h"
-#include "FileResourceArchive.h"
+#include "ArchiveBundle.h"
+#include "FileBundle.h"
 #include "ResourceManager.h"
 #include "TextureResource.h"
 #include "Keyboard.h"
@@ -86,7 +86,7 @@ Device::Device() :
 	m_debug_renderer(NULL),
 
 	m_resource_manager(NULL),
-	m_resource_archive(NULL),
+	m_resource_bundle(NULL),
 
 	m_game_library(NULL)
 {
@@ -197,9 +197,9 @@ void Device::shutdown()
 	}
 
 	Log::i("Releasing ResourceManager...");
-	if (m_resource_archive)
+	if (m_resource_bundle)
 	{
-		CE_DELETE(m_allocator, m_resource_archive);
+		CE_DELETE(m_allocator, m_resource_bundle);
 	}
 
 	if (m_resource_manager)
@@ -389,15 +389,15 @@ void Device::create_resource_manager()
 	// Select appropriate resource archive
 	if (m_preferred_mode == MODE_DEVELOPMENT)
 	{
-		m_resource_archive = CE_NEW(m_allocator, FileResourceArchive)(*m_filesystem);
+		m_resource_bundle = CE_NEW(m_allocator, FileBundle)(*m_filesystem);
 	}
 	else
 	{
-		m_resource_archive = CE_NEW(m_allocator, ArchiveResourceArchive)(*m_filesystem);
+		m_resource_bundle = CE_NEW(m_allocator, ArchiveBundle)(*m_filesystem);
 	}
 
 	// Create resource manager
-	m_resource_manager = CE_NEW(m_allocator, ResourceManager)(*m_resource_archive);
+	m_resource_manager = CE_NEW(m_allocator, ResourceManager)(*m_resource_bundle);
 
 	Log::d("Resource manager created.");
 	Log::d("Resource seed: %d", m_resource_manager->seed());

+ 2 - 2
src/Device.h

@@ -36,7 +36,7 @@ namespace crown
 
 class Filesystem;
 class ResourceManager;
-class ResourceArchive;
+class Bundle;
 class Renderer;
 class DebugRenderer;
 class InputManager;
@@ -148,7 +148,7 @@ private:
 
 	// Private subsystems
 	ResourceManager*		m_resource_manager;
-	ResourceArchive*		m_resource_archive;
+	Bundle*					m_resource_bundle;
 
 	// The game currently running
 	void*					m_game_library;

+ 5 - 5
src/FileResourceArchive.cpp → src/FileBundle.cpp

@@ -24,7 +24,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 */
 
 #include <cstdio>
-#include "FileResourceArchive.h"
+#include "FileBundle.h"
 #include "Filesystem.h"
 #include "Resource.h"
 #include "DiskFile.h"
@@ -35,18 +35,18 @@ namespace crown
 {
 
 //-----------------------------------------------------------------------------
-FileResourceArchive::FileResourceArchive(Filesystem& fs) :
+FileBundle::FileBundle(Filesystem& fs) :
 	m_filesystem(fs)
 {
 }
 
 //-----------------------------------------------------------------------------
-FileResourceArchive::~FileResourceArchive()
+FileBundle::~FileBundle()
 {
 }
 
 //-----------------------------------------------------------------------------
-DiskFile* FileResourceArchive::open(ResourceId name)
+DiskFile* FileBundle::open(ResourceId name)
 {
 	// Convert name/type into strings
 	char resource_name[512];
@@ -68,7 +68,7 @@ DiskFile* FileResourceArchive::open(ResourceId name)
 }
 
 //-----------------------------------------------------------------------------
-void FileResourceArchive::close(DiskFile* resource)
+void FileBundle::close(DiskFile* resource)
 {
 	m_filesystem.close(resource);
 }

+ 6 - 6
src/FileResourceArchive.h → src/FileBundle.h

@@ -26,7 +26,7 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 
 #include "Types.h"
-#include "ResourceArchive.h"
+#include "Bundle.h"
 
 namespace crown
 {
@@ -46,17 +46,17 @@ struct ResourceHeader
 };
 
 /// Source of resources
-class FileResourceArchive : public ResourceArchive
+class FileBundle : public Bundle
 {
 public:
 
-					FileResourceArchive(Filesystem& fs);
-					~FileResourceArchive();
+					FileBundle(Filesystem& fs);
+					~FileBundle();
 
-	/// @copydoc ResourceArchive::open()
+	/// @copydoc Bundle::open()
 	DiskFile*		open(ResourceId name);
 
-	/// @copydoc ResourceArchive::close()
+	/// @copydoc Bundle::close()
 	void			close(DiskFile* resource);
 
 

+ 2 - 2
src/FontResource.cpp

@@ -30,10 +30,10 @@ namespace crown
 {
 
 //-----------------------------------------------------------------------------
-void* FontResource::load(Allocator& allocator, ResourceArchive& archive, ResourceId id)
+void* FontResource::load(Allocator& allocator, Bundle& bundle, ResourceId id)
 {
 	(void)allocator;
-	(void)archive;
+	(void)bundle;
 	(void)id;
 
 	return NULL;

+ 2 - 2
src/FontResource.h

@@ -33,13 +33,13 @@ namespace crown
 {
 
 class Allocator;
-class ResourceArchive;
+class Bundle;
 
 class FontResource
 {
 public:
 
-	static void*		load(Allocator& allocator, ResourceArchive& archive, ResourceId id);
+	static void*		load(Allocator& allocator, Bundle& bundle, ResourceId id);
 	static void			online(void* resource);
 	static void			unload(Allocator& allocator, void* resource);
 	static void			offline();

+ 2 - 2
src/MaterialResource.cpp

@@ -30,10 +30,10 @@ namespace crown
 {
 
 //-----------------------------------------------------------------------------
-void* MaterialResource::load(Allocator& allocator, ResourceArchive& archive, ResourceId id)
+void* MaterialResource::load(Allocator& allocator, Bundle& bundle, ResourceId id)
 {
 	(void)allocator;
-	(void)archive;
+	(void)bundle;
 	(void)id;
 	// TODO
 

+ 2 - 2
src/MaterialResource.h

@@ -40,7 +40,7 @@ namespace crown
 /// @note The maximum number of usable layers depends on the graphic card/Renderer config.
 const uint32_t MAX_TEXTURE_LAYERS = 8;
 
-class ResourceArchive;
+class Bundle;
 class Allocator;
 
 /// A material describes the visual properties of a surface.
@@ -50,7 +50,7 @@ class MaterialResource
 {
 public:
 
-	static void*	load(Allocator& allocator, ResourceArchive& archive, ResourceId id);
+	static void*	load(Allocator& allocator, Bundle& bundle, ResourceId id);
 	static void		online(void* resource);
 	static void		unload(Allocator& allocator, void* texture);
 	static void		offline();

+ 5 - 5
src/ResourceManager.cpp

@@ -44,8 +44,8 @@ namespace crown
 {
 
 //-----------------------------------------------------------------------------
-ResourceManager::ResourceManager(ResourceArchive& archive) :
-	m_resource_archive(archive),
+ResourceManager::ResourceManager(Bundle& bundle) :
+	m_resource_bundle(bundle),
 	m_resources(m_allocator),
 	m_loading_queue(m_allocator),
 	m_loaded_queue(m_allocator),
@@ -340,15 +340,15 @@ void* ResourceManager::load_by_type(ResourceId name)
 {
 	if (name.type == TEXTURE_TYPE)
 	{
-		return TextureResource::load(m_resource_allocator, m_resource_archive, name);
+		return TextureResource::load(m_resource_allocator, m_resource_bundle, name);
 	}
 	else if (name.type == TEXT_TYPE)
 	{
-		return TextResource::load(m_resource_allocator, m_resource_archive, name);
+		return TextResource::load(m_resource_allocator, m_resource_bundle, name);
 	}
 	else if (name.type == SCRIPT_TYPE)
 	{
-		return ScriptResource::load(m_resource_allocator, m_resource_archive, name);
+		return ScriptResource::load(m_resource_allocator, m_resource_bundle, name);
 	}
 
 	return NULL;

+ 4 - 4
src/ResourceManager.h

@@ -63,15 +63,15 @@ struct LoadedResource
 	void*		data;
 };
 
-class ResourceArchive;
+class Bundle;
 
 /// Resource manager.
 class ResourceManager
 {
 public:
 
-	/// Read resources from @archive and store resource data using @allocator.
-							ResourceManager(ResourceArchive& archive);
+	/// Read resources from @bundle and store resource data using @allocator.
+							ResourceManager(Bundle& bundle);
 							~ResourceManager();
 
 	/// Loads the resource by @name and returns its ResourceId.
@@ -147,7 +147,7 @@ private:
 private:
 
 	// Archive whether to look for resources
-	ResourceArchive&		m_resource_archive;
+	Bundle&					m_resource_bundle;
 	// Used to strore resource memory
 	MallocAllocator			m_resource_allocator;
 

+ 4 - 4
src/ScriptResource.cpp

@@ -1,7 +1,7 @@
 #include "Assert.h"
 
 #include "ScriptResource.h"
-#include "ResourceArchive.h"
+#include "Bundle.h"
 #include "Log.h"
 #include "DiskFile.h"
 #include "Allocator.h"
@@ -10,9 +10,9 @@ namespace crown
 {
 
 //-----------------------------------------------------------------------------
-void* ScriptResource::load(Allocator& allocator, ResourceArchive& archive, ResourceId id)
+void* ScriptResource::load(Allocator& allocator, Bundle& bundle, ResourceId id)
 {
-	DiskFile* stream = archive.open(id);
+	DiskFile* stream = bundle.open(id);
 
 	if (stream != NULL)
 	{
@@ -24,7 +24,7 @@ void* ScriptResource::load(Allocator& allocator, ResourceArchive& archive, Resou
 
 		stream->read(resource->m_data, size);
 
-		archive.close(stream);
+		bundle.close(stream);
 
 		return resource;
 	}

+ 2 - 2
src/ScriptResource.h

@@ -31,14 +31,14 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 {
 
-class ResourceArchive;
+class Bundle;
 class Allocator;
 
 class ScriptResource
 {
 public:
 
-	static void*		load(Allocator& allocator, ResourceArchive& archive, ResourceId id);
+	static void*		load(Allocator& allocator, Bundle& bundle, ResourceId id);
 	static void			online(void* script);
 	static void			unload(Allocator& allocator, void* resource);
 	static void			offline();

+ 4 - 4
src/TextResource.cpp

@@ -1,6 +1,6 @@
 #include "TextResource.h"
 #include "DiskFile.h"
-#include "ResourceArchive.h"
+#include "Bundle.h"
 #include "Log.h"
 #include "Allocator.h"
 
@@ -8,9 +8,9 @@ namespace crown
 {
 
 //-----------------------------------------------------------------------------
-void* TextResource::load(Allocator& allocator, ResourceArchive& archive, ResourceId id)
+void* TextResource::load(Allocator& allocator, Bundle& bundle, ResourceId id)
 {
-	DiskFile* stream = archive.open(id);
+	DiskFile* stream = bundle.open(id);
 
 	CE_ASSERT(stream != NULL, "Resource does not exist: %.8X%.8X", id.name, id.type);
 
@@ -24,7 +24,7 @@ void* TextResource::load(Allocator& allocator, ResourceArchive& archive, Resourc
 	
 	resource->data[resource->length] = '\0';
 
-	archive.close(stream);
+	bundle.close(stream);
 
 	return resource;
 }

+ 2 - 2
src/TextResource.h

@@ -6,14 +6,14 @@
 namespace crown
 {
 
-class ResourceArchive;
+class Bundle;
 class Allocator;
 
 class TextResource
 {
 public:
 
-	static void*		load(Allocator& allocator, ResourceArchive& archive, ResourceId id);
+	static void*		load(Allocator& allocator, Bundle& bundle, ResourceId id);
 	static void			unload(Allocator& allocator, void* resource);
 
 	uint32_t			length;

+ 4 - 4
src/TextureResource.cpp

@@ -1,5 +1,5 @@
 #include "TextureResource.h"
-#include "ResourceArchive.h"
+#include "Bundle.h"
 #include "Log.h"
 #include "DiskFile.h"
 #include "Assert.h"
@@ -11,9 +11,9 @@ namespace crown
 {
 
 //-----------------------------------------------------------------------------
-void* TextureResource::load(Allocator& allocator, ResourceArchive& archive, ResourceId id)
+void* TextureResource::load(Allocator& allocator, Bundle& bundle, ResourceId id)
 {
-	DiskFile* stream = archive.open(id);
+	DiskFile* stream = bundle.open(id);
 
 	CE_ASSERT(stream != NULL, "Resource does not exist: %.8X%.8X", id.name, id.type);
 
@@ -29,7 +29,7 @@ void* TextureResource::load(Allocator& allocator, ResourceArchive& archive, Reso
 
 	stream->read(resource->m_data, size);
 
-	archive.close(stream);
+	bundle.close(stream);
 
 	return resource;
 }

+ 2 - 2
src/TextureResource.h

@@ -33,14 +33,14 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 {
 
-class ResourceArchive;
+class Bundle;
 class Allocator;
 
 class TextureResource
 {
 public:
 
-	static void*		load(Allocator& allocator, ResourceArchive& archive, ResourceId id);
+	static void*		load(Allocator& allocator, Bundle& bundle, ResourceId id);
 	static void			online(void* resource);
 	static void			unload(Allocator& allocator, void* resource);
 	static void			offline();

+ 1 - 1
tools/compilers/resource-linker.cpp

@@ -5,7 +5,7 @@
 #include "String.h"
 #include "Hash.h"
 #include "Resource.h"
-#include "ResourceArchive.h"
+#include "Bundle.h"
 #include "DiskFile.h"
 #include <cstring>