From 31c9cdfb3ec15f5ffa65a058fd15c675ada1d4b5 Mon Sep 17 00:00:00 2001 From: Danilo Date: Sat, 16 Nov 2024 17:05:24 -0300 Subject: [PATCH] =?UTF-8?q?Implementa=C3=A7=C3=B5es=20em=20importer.hpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- includes/pipeline/importer.hpp | 67 +++++++++++++++++++++++++++++++++ includes/pipeline/logger.hpp | 10 +++++ sources/pipeline/CMakeLists.txt | 2 +- sources/pipeline/importer.cpp | 1 + 4 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 includes/pipeline/importer.hpp create mode 100644 includes/pipeline/logger.hpp create mode 100644 sources/pipeline/importer.cpp diff --git a/includes/pipeline/importer.hpp b/includes/pipeline/importer.hpp new file mode 100644 index 0000000..755e014 --- /dev/null +++ b/includes/pipeline/importer.hpp @@ -0,0 +1,67 @@ +#ifndef XNA_PIPELINE_IMPORTER_HPP +#define XNA_PIPELINE_IMPORTER_HPP + +#include +#include +#include +#include +#include +#include "logger.hpp" + +namespace xna { + //Provides properties that define logging behavior for the importer. + struct ContentImporterContext { + //Gets the logger for an importer. + virtual std::shared_ptr Logger() = 0; + //Name of an asset file. + virtual void AddDependency(std::string filename) = 0; + //The absolute path to the root of the build output (binaries) directory. + virtual std::string OutputDirectory() = 0; + //The absolute path to the root of the build intermediate (object) directory. + virtual std::string IntermediateDirectory() = 0; + }; + + //Accesses a statically typed ContentImporter instance from generic code using dynamic typing. + struct IContentImporter { + //Imports an asset from the specified file. + virtual std::any Import(std::string const& filename, ContentImporterContext& context) = 0; + }; + + //Implements a file format importer for use with game assets. + template + struct ContentImporter_T : public IContentImporter { + //Imports an asset from the specified file. + virtual T Import(std::string const& filename, ContentImporterContext& context) = 0; + + //Imports an asset from the specified file. + std::any Import(std::string const& filename, ContentImporterContext& context) override { + std::any obj = Import(filename, context); + return obj; + } + }; + + //rovides properties that identify and provide metadata about the importer, such as supported file extensions and caching information. + struct ContentImporterAttribute { + bool CacheImportedData; + std::string DisplayName; + std::string DefaultProcessor; + + ContentImporterAttribute(std::string const& fileExtension) { + fileExtensions.push_back(fileExtension); + } + + ContentImporterAttribute(std::vector const& fileExtensions) { + this->fileExtensions = fileExtensions; + //TODO: check extensions + } + + const std::vector& FileExtensions() const { + return fileExtensions; + } + + private: + std::vector fileExtensions; + }; +} + +#endif \ No newline at end of file diff --git a/includes/pipeline/logger.hpp b/includes/pipeline/logger.hpp new file mode 100644 index 0000000..e68bef8 --- /dev/null +++ b/includes/pipeline/logger.hpp @@ -0,0 +1,10 @@ +#ifndef XNA_PIPELINE_LOGGER_HPP +#define XNA_PIPELINE_LOGGER_HPP + +namespace xna { + class ContentBuilderLogger { + + }; +} + +#endif \ No newline at end of file diff --git a/sources/pipeline/CMakeLists.txt b/sources/pipeline/CMakeLists.txt index 78994d4..8bc2ed7 100644 --- a/sources/pipeline/CMakeLists.txt +++ b/sources/pipeline/CMakeLists.txt @@ -6,7 +6,7 @@ add_library (Xn65Pipeline STATIC "writer.cpp" "compiler.cpp" -) + "importer.cpp") if (CMAKE_VERSION VERSION_GREATER 3.12) set_property(TARGET Xn65Pipeline PROPERTY CXX_STANDARD 20) diff --git a/sources/pipeline/importer.cpp b/sources/pipeline/importer.cpp new file mode 100644 index 0000000..77702b4 --- /dev/null +++ b/sources/pipeline/importer.cpp @@ -0,0 +1 @@ +#include "pipeline/importer.hpp" \ No newline at end of file