// Copyright Epic Games, Inc. All Rights Reserved. #include "DatasmithCommands.h" #include "Serialization/Archive.h" #include "Serialization/MemoryWriter.h" #include "Serialization/MemoryReader.h" namespace DatasmithDispatcher { TSharedPtr CreateCommand(ECommandId CommandType) { switch (CommandType) { case ECommandId::Ping: return MakeShared(); case ECommandId::BackPing: return MakeShared(); case ECommandId::RunTask: return MakeShared(); case ECommandId::NotifyEndTask: return MakeShared(); case ECommandId::ImportParams: return MakeShared(); case ECommandId::Terminate: return MakeShared(); } return nullptr; } void SerializeCommand(ICommand& Command, TArray& OutBuffer) { FMemoryWriter ArWriter(OutBuffer); uint8 type = static_cast(Command.GetType()); ArWriter << type; ArWriter << Command; } TSharedPtr DeserializeCommand(const TArray& InBuffer) { FMemoryReader ArReader(InBuffer); uint8 type = 0; ArReader << type; if (TSharedPtr Command = CreateCommand(static_cast(type))) { ArReader << *Command; return ArReader.IsError() ? nullptr : Command; } return nullptr; } void FRunTaskCommand::SerializeImpl(FArchive& Ar) { Ar << JobFileDescription; Ar << Mesher; Ar << JobIndex; } void FCompletedTaskCommand::SerializeImpl(FArchive& Ar) { Ar << ExternalReferences; Ar << ProcessResult; Ar << SceneGraphFileName; Ar << GeomFileName; Ar << Messages; } void FImportParametersCommand::SerializeImpl(FArchive& Ar) { Ar << ImportParameters; } }