summaryrefslogtreecommitdiff
path: root/assetFactory/assetFactory.cpp
diff options
context:
space:
mode:
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);
+}