CmImporter.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #pragma once
  2. #include "CmPrerequisites.h"
  3. #include "CmModule.h"
  4. namespace CamelotEngine
  5. {
  6. /**
  7. * @brief Module responsible for importing various asset types and converting
  8. * them to types usable by the engine.
  9. */
  10. class CM_EXPORT Importer : public Module<Importer>
  11. {
  12. public:
  13. /**
  14. * @brief Constructor.
  15. */
  16. Importer();
  17. ~Importer();
  18. /**
  19. * @brief Imports a resource at the specified location, and returns the loaded data.
  20. *
  21. * @param inputFilePath Pathname of the input file.
  22. */
  23. ResourcePtr import(const String& inputFilePath);
  24. /**
  25. * @brief Checks if we can import a file with the specified extension.
  26. *
  27. * @param extension The extension without leading dot.
  28. */
  29. bool supportsFileType(const std::string& extension) const;
  30. /**
  31. * @brief Checks if we can import a file with the specified magic number.
  32. *
  33. * @param magicNumber The buffer containing the magic number.
  34. * @param magicNumSize Size of the magic number buffer.
  35. */
  36. bool supportsFileType(const UINT8* magicNumber, UINT32 magicNumSize) const;
  37. /**
  38. * @brief Adds a new asset importer for the specified file extension. If an asset importer for that extension
  39. * already exists, it is removed and replaced with the current one.
  40. *
  41. * @note This method should only be called by asset importers themselves on startup.
  42. *
  43. * @param [in] importer The importer that is able to handle files with the specified extension. nullptr if you
  44. * want to remove an asset importer for the extension.
  45. */
  46. void registerAssetImporter(SpecificImporter* importer);
  47. private:
  48. vector<SpecificImporter*>::type mAssetImporters;
  49. };
  50. }