summaryrefslogtreecommitdiff
path: root/assetFactory/modelFactory.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-02-21 01:25:34 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2023-02-21 01:25:34 +0000
commited7c2a6a73f24f97a0f04c2e6be6862ffe54b585 (patch)
tree810350a653292d54621b7c4e72275bcd48dc6785 /assetFactory/modelFactory.cpp
parentAdd missing override (diff)
downloadilt-ed7c2a6a73f24f97a0f04c2e6be6862ffe54b585.tar.bz2
ilt-ed7c2a6a73f24f97a0f04c2e6be6862ffe54b585.tar.xz
ilt-ed7c2a6a73f24f97a0f04c2e6be6862ffe54b585.zip
Support for loading objects, uses and model factories from an XML resource
Diffstat (limited to 'assetFactory/modelFactory.cpp')
-rw-r--r--assetFactory/modelFactory.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/assetFactory/modelFactory.cpp b/assetFactory/modelFactory.cpp
index 4c25e48..2642900 100644
--- a/assetFactory/modelFactory.cpp
+++ b/assetFactory/modelFactory.cpp
@@ -2,7 +2,10 @@
#include "cuboid.h"
#include "cylinder.h"
#include "modelFactoryMesh_fwd.h"
+#include "object.h"
#include "plane.h"
+#include "saxParse-persistence.h"
+#include <filesystem.h>
ModelFactory::ModelFactory() :
shapes {
@@ -12,3 +15,17 @@ ModelFactory::ModelFactory() :
}
{
}
+
+std::shared_ptr<ModelFactory>
+ModelFactory::loadXML(const std::filesystem::path & filename)
+{
+ filesystem::FileStar file {filename.c_str(), "r"};
+ return Persistence::SAXParsePersistence {}.loadState<std::shared_ptr<ModelFactory>>(file);
+}
+
+bool
+ModelFactory::persist(Persistence::PersistenceStore & store)
+{
+ using MapObjects = Persistence::MapByMember<Shapes, Object>;
+ return STORE_TYPE && STORE_NAME_HELPER("object", shapes, MapObjects);
+}