summaryrefslogtreecommitdiff
path: root/assetFactory/assetFactory.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-02-21 19:34:16 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2023-02-21 19:34:16 +0000
commit5e561d390dc82b08c20532de0952f428e7b14283 (patch)
tree5f213d4eb741e451b913884b6f302470e7b2fc74 /assetFactory/assetFactory.cpp
parentSupport for loading objects, uses and model factories from an XML resource (diff)
downloadilt-5e561d390dc82b08c20532de0952f428e7b14283.tar.bz2
ilt-5e561d390dc82b08c20532de0952f428e7b14283.tar.xz
ilt-5e561d390dc82b08c20532de0952f428e7b14283.zip
Rename ModelFactory to AssetFactory
Diffstat (limited to 'assetFactory/assetFactory.cpp')
-rw-r--r--assetFactory/assetFactory.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/assetFactory/assetFactory.cpp b/assetFactory/assetFactory.cpp
new file mode 100644
index 0000000..0ee1f94
--- /dev/null
+++ b/assetFactory/assetFactory.cpp
@@ -0,0 +1,31 @@
+#include "assetFactory.h"
+#include "cuboid.h"
+#include "cylinder.h"
+#include "modelFactoryMesh_fwd.h"
+#include "object.h"
+#include "plane.h"
+#include "saxParse-persistence.h"
+#include <filesystem.h>
+
+AssetFactory::AssetFactory() :
+ shapes {
+ {"plane", std::make_shared<Plane>()},
+ {"cuboid", std::make_shared<Cuboid>()},
+ {"cylinder", std::make_shared<Cylinder>()},
+ }
+{
+}
+
+std::shared_ptr<AssetFactory>
+AssetFactory::loadXML(const std::filesystem::path & filename)
+{
+ filesystem::FileStar file {filename.c_str(), "r"};
+ return Persistence::SAXParsePersistence {}.loadState<std::shared_ptr<AssetFactory>>(file);
+}
+
+bool
+AssetFactory::persist(Persistence::PersistenceStore & store)
+{
+ using MapObjects = Persistence::MapByMember<Shapes, Object>;
+ return STORE_TYPE && STORE_NAME_HELPER("object", shapes, MapObjects);
+}