mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Implementa ContentCompiler
This commit is contained in:
parent
0e89ee381b
commit
b42a9f60b4
@ -1,5 +1,38 @@
|
|||||||
#include "xna/pipeline/compiler.hpp"
|
#include "xna/pipeline/compiler.hpp"
|
||||||
|
#include "xna/pipeline/writer.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
|
ContentCompiler::ContentCompiler() {
|
||||||
|
const auto writers = typeWriterFactory->Initialize();
|
||||||
|
|
||||||
|
for (auto& writer : writers)
|
||||||
|
AddTypeWriter(writer);
|
||||||
|
|
||||||
|
for (auto& dic : writerInstances) {
|
||||||
|
auto& writer = dic.second;
|
||||||
|
AddTypeWriter(writer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ContentCompiler::Compile(
|
||||||
|
P_Stream const& output,
|
||||||
|
Object& value,
|
||||||
|
TargetPlatform targetPlatform,
|
||||||
|
GraphicsProfile targetProfile,
|
||||||
|
bool compressContent,
|
||||||
|
String const& rootDirectory,
|
||||||
|
String const& referenceRelocationPath) {
|
||||||
|
if (compressContent)
|
||||||
|
compressContent = ShouldCompressContent(targetPlatform, value);
|
||||||
|
|
||||||
|
auto _this = shared_from_this();
|
||||||
|
|
||||||
|
auto contentWriter = unew<ContentWriter>(
|
||||||
|
_this, output, targetPlatform,
|
||||||
|
targetProfile, compressContent,
|
||||||
|
rootDirectory, referenceRelocationPath);
|
||||||
|
|
||||||
|
contentWriter->WriteObject(value);
|
||||||
|
contentWriter->FlushOutput();
|
||||||
|
}
|
||||||
}
|
}
|
@ -14,6 +14,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
#include <stack>
|
||||||
|
|
||||||
#include "enumerations.hpp"
|
#include "enumerations.hpp"
|
||||||
#include "exception.hpp"
|
#include "exception.hpp"
|
||||||
@ -204,6 +205,7 @@ namespace xna {
|
|||||||
class ContentWriter;
|
class ContentWriter;
|
||||||
class ContentCompiler;
|
class ContentCompiler;
|
||||||
class ContentTypeWriter;
|
class ContentTypeWriter;
|
||||||
|
class ContentTypeWriterFactory;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -230,6 +232,7 @@ namespace xna {
|
|||||||
using P_ContentWriter = sptr<ContentWriter>;
|
using P_ContentWriter = sptr<ContentWriter>;
|
||||||
using P_ContentCompiler = sptr<ContentCompiler>;
|
using P_ContentCompiler = sptr<ContentCompiler>;
|
||||||
using P_ContentTypeWriter = sptr<ContentTypeWriter>;
|
using P_ContentTypeWriter = sptr<ContentTypeWriter>;
|
||||||
|
using P_ContentTypeWriterFactory = sptr<ContentTypeWriterFactory>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,11 +2,41 @@
|
|||||||
#define XNA_PIPELINE_COMPILER_HPP
|
#define XNA_PIPELINE_COMPILER_HPP
|
||||||
|
|
||||||
#include "../default.hpp"
|
#include "../default.hpp"
|
||||||
|
#include "../csharp/stream.hpp"
|
||||||
|
#include "pipeline-enums.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
class ContentCompiler {
|
//Provides methods for writing compiled binary format.
|
||||||
|
class ContentCompiler : public std::enable_shared_from_this<ContentCompiler> {
|
||||||
public:
|
public:
|
||||||
|
ContentCompiler();
|
||||||
|
|
||||||
|
//Retrieves the worker writer for the specified type
|
||||||
P_ContentTypeWriter GetTypeWriter(Type const& type, std::vector<P_Type> dependencies);
|
P_ContentTypeWriter GetTypeWriter(Type const& type, std::vector<P_Type> dependencies);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void Compile(
|
||||||
|
P_Stream const& output,
|
||||||
|
Object& value,
|
||||||
|
TargetPlatform targetPlatform,
|
||||||
|
GraphicsProfile targetProfile,
|
||||||
|
bool compressContent,
|
||||||
|
String const& rootDirectory,
|
||||||
|
String const& referenceRelocationPath);
|
||||||
|
|
||||||
|
void AddTypeWriter(P_ContentTypeWriter const& writer);
|
||||||
|
|
||||||
|
bool ShouldCompressContent(TargetPlatform targetPlatform, Object& value) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
using TypeList = std::vector<P_Type>;
|
||||||
|
|
||||||
|
std::map<HashValue, P_ContentTypeWriter> writerInstances;
|
||||||
|
std::map<HashValue, TypeList> writerDependecies;
|
||||||
|
std::stack<P_ContentTypeWriter> initializeContext;
|
||||||
|
P_ContentTypeWriterFactory typeWriterFactory;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,8 +151,22 @@ namespace xna {
|
|||||||
inline static const String FilenameExt = ".xnb";
|
inline static const String FilenameExt = ".xnb";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
class TypeHandlerFactory {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class ContentTypeWriterFactory : public TypeHandlerFactory<ContentTypeWriter> {
|
||||||
|
public:
|
||||||
|
std::vector<P_ContentTypeWriter> Initialize() const {
|
||||||
|
std::vector<P_ContentTypeWriter> writers;
|
||||||
|
|
||||||
|
return writers;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
// Generics implementations
|
// ContentTypeWriter
|
||||||
//
|
//
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user