1
0
mirror of https://github.com/borgesdan/xn65 synced 2024-12-29 21:54:47 +01:00

Implementações em importer.hpp

This commit is contained in:
Danilo 2024-11-16 17:05:24 -03:00
parent 2a1a94e72b
commit 31c9cdfb3e
4 changed files with 79 additions and 1 deletions

View File

@ -0,0 +1,67 @@
#ifndef XNA_PIPELINE_IMPORTER_HPP
#define XNA_PIPELINE_IMPORTER_HPP
#include <any>
#include <string>
#include <memory>
#include <vector>
#include <map>
#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<ContentBuilderLogger> 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 <typename T>
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<T>(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<std::string> const& fileExtensions) {
this->fileExtensions = fileExtensions;
//TODO: check extensions
}
const std::vector<std::string>& FileExtensions() const {
return fileExtensions;
}
private:
std::vector<std::string> fileExtensions;
};
}
#endif

View File

@ -0,0 +1,10 @@
#ifndef XNA_PIPELINE_LOGGER_HPP
#define XNA_PIPELINE_LOGGER_HPP
namespace xna {
class ContentBuilderLogger {
};
}
#endif

View File

@ -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)

View File

@ -0,0 +1 @@
#include "pipeline/importer.hpp"