ISimpleResourceLoader.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * ISimpleResourceLoader.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "CInputStream.h"
  12. #include "CResourceLoader.h" //FIXME: move ResourceID + EResType in separate file?
  13. /**
  14. * A class which knows the files containing in the archive or system and how to load them.
  15. */
  16. class DLL_LINKAGE ISimpleResourceLoader
  17. {
  18. public:
  19. /**
  20. * Dtor.
  21. */
  22. virtual ~ISimpleResourceLoader() { };
  23. /**
  24. * Loads a resource with the given resource name.
  25. *
  26. * @param resourceName The unqiue resource name in space of the archive.
  27. * @return a input stream object
  28. */
  29. virtual std::unique_ptr<CInputStream> load(const std::string & resourceName) const =0;
  30. /**
  31. * Checks if the entry exists.
  32. *
  33. * @return Returns true if the entry exists, false if not.
  34. */
  35. virtual bool existsEntry(const std::string & resourceName) const =0;
  36. /**
  37. * Gets all entries in the archive or (file) system.
  38. *
  39. * @return Returns a list of all entries in the archive or (file) system.
  40. */
  41. virtual boost::unordered_map<ResourceID, std::string> getEntries() const =0;
  42. /**
  43. * Gets the origin of the loader.
  44. *
  45. * @return the file path to source of this loader
  46. */
  47. virtual std::string getOrigin() const =0;
  48. /**
  49. * Creates new resource with specified filename.
  50. *
  51. * @returns true if new file was created, false on error or if file already exists
  52. */
  53. virtual bool createEntry(std::string filename)
  54. {
  55. return false;
  56. }
  57. };