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:
parent
2a1a94e72b
commit
31c9cdfb3e
67
includes/pipeline/importer.hpp
Normal file
67
includes/pipeline/importer.hpp
Normal 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
|
10
includes/pipeline/logger.hpp
Normal file
10
includes/pipeline/logger.hpp
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef XNA_PIPELINE_LOGGER_HPP
|
||||
#define XNA_PIPELINE_LOGGER_HPP
|
||||
|
||||
namespace xna {
|
||||
class ContentBuilderLogger {
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -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)
|
||||
|
1
sources/pipeline/importer.cpp
Normal file
1
sources/pipeline/importer.cpp
Normal file
@ -0,0 +1 @@
|
||||
#include "pipeline/importer.hpp"
|
Loading…
x
Reference in New Issue
Block a user