diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-02-21 01:25:34 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-02-21 01:25:34 +0000 |
commit | ed7c2a6a73f24f97a0f04c2e6be6862ffe54b585 (patch) | |
tree | 810350a653292d54621b7c4e72275bcd48dc6785 /assetFactory/object.cpp | |
parent | Add missing override (diff) | |
download | ilt-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.cpp | 22 |
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); +} |