2012-07-22 15:02:13 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* ISimpleResourceLoader.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "CInputStream.h"
|
2012-08-07 11:28:52 +00:00
|
|
|
#include "CResourceLoader.h" //FIXME: move ResourceID + EResType in separate file?
|
2012-07-22 15:02:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A class which knows the files containing in the archive or system and how to load them.
|
|
|
|
*/
|
|
|
|
class DLL_LINKAGE ISimpleResourceLoader
|
|
|
|
{
|
2012-08-01 12:02:54 +00:00
|
|
|
public:
|
2012-07-22 15:02:13 +00:00
|
|
|
/**
|
|
|
|
* Dtor.
|
|
|
|
*/
|
|
|
|
virtual ~ISimpleResourceLoader() { };
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Loads a resource with the given resource name.
|
|
|
|
*
|
|
|
|
* @param resourceName The unqiue resource name in space of the archive.
|
|
|
|
* @return a input stream object
|
|
|
|
*/
|
|
|
|
virtual std::unique_ptr<CInputStream> load(const std::string & resourceName) const =0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if the entry exists.
|
|
|
|
*
|
|
|
|
* @return Returns true if the entry exists, false if not.
|
|
|
|
*/
|
|
|
|
virtual bool existsEntry(const std::string & resourceName) const =0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets all entries in the archive or (file) system.
|
|
|
|
*
|
|
|
|
* @return Returns a list of all entries in the archive or (file) system.
|
|
|
|
*/
|
2013-06-29 13:05:48 +00:00
|
|
|
virtual std::unordered_map<ResourceID, std::string> getEntries() const =0;
|
2012-08-01 12:02:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the origin of the loader.
|
|
|
|
*
|
|
|
|
* @return the file path to source of this loader
|
|
|
|
*/
|
|
|
|
virtual std::string getOrigin() const =0;
|
2012-08-07 11:28:52 +00:00
|
|
|
|
2013-05-04 13:14:23 +00:00
|
|
|
/**
|
|
|
|
* Gets full name of resource, e.g. name of file in filesystem.
|
|
|
|
*/
|
|
|
|
virtual std::string getFullName(const std::string & resourceName) const
|
|
|
|
{
|
|
|
|
return getOrigin() + '/' + resourceName;
|
|
|
|
}
|
|
|
|
|
2012-08-07 11:28:52 +00:00
|
|
|
/**
|
|
|
|
* Creates new resource with specified filename.
|
|
|
|
*
|
|
|
|
* @returns true if new file was created, false on error or if file already exists
|
|
|
|
*/
|
2013-05-30 16:25:00 +00:00
|
|
|
virtual bool createEntry(std::string filename, bool update = false)
|
2012-08-07 11:28:52 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2012-07-22 15:02:13 +00:00
|
|
|
};
|