summaryrefslogtreecommitdiff
path: root/assetFactory/object.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/object.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/object.cpp')
-rw-r--r--assetFactory/object.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/assetFactory/object.cpp b/assetFactory/object.cpp
index 8b70676..faa9a17 100644
--- a/assetFactory/object.cpp
+++ b/assetFactory/object.cpp
@@ -15,3 +15,25 @@ Object::createMesh(ModelFactoryMesh & mesh, const Mutation::Matrix & mutation) c
}
return faces;
}
+
+template<typename Container, typename Type> struct Appender : public Persistence::SelectionT<std::shared_ptr<Type>> {
+ Appender(Container & c) : Persistence::SelectionT<std::shared_ptr<Type>> {s}, container {c} { }
+ using Persistence::SelectionT<std::shared_ptr<Type>>::SelectionT;
+ void
+ endObject(Persistence::Stack & stk) override
+ {
+ container.emplace_back(s);
+ stk.pop();
+ }
+
+private:
+ std::shared_ptr<Type> s;
+ Container & container;
+};
+
+bool
+Object::persist(Persistence::PersistenceStore & store)
+{
+ using UseAppend = Appender<Use::Collection, Use>;
+ return STORE_TYPE && STORE_MEMBER(id) && STORE_NAME_HELPER("use", uses, UseAppend);
+}