summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--assetFactory/object.cpp18
-rw-r--r--lib/persistence.h16
2 files changed, 17 insertions, 17 deletions
diff --git a/assetFactory/object.cpp b/assetFactory/object.cpp
index faa9a17..ae5a301 100644
--- a/assetFactory/object.cpp
+++ b/assetFactory/object.cpp
@@ -16,24 +16,8 @@ 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);
+ return STORE_TYPE && STORE_MEMBER(id) && STORE_NAME_HELPER("use", uses, Persistence::Appender<Use::Collection>);
}
diff --git a/lib/persistence.h b/lib/persistence.h
index d55062a..5c8454c 100644
--- a/lib/persistence.h
+++ b/lib/persistence.h
@@ -273,6 +273,22 @@ namespace Persistence {
Map & map;
};
+ template<typename Container, typename Type = typename Container::value_type>
+ struct Appender : public Persistence::SelectionT<Type> {
+ Appender(Container & c) : Persistence::SelectionT<Type> {s}, container {c} { }
+ using Persistence::SelectionT<Type>::SelectionT;
+ void
+ endObject(Persistence::Stack & stk) override
+ {
+ container.emplace_back(std::move(s));
+ stk.pop();
+ }
+
+ private:
+ Type s;
+ Container & container;
+ };
+
struct Persistable {
Persistable() = default;
virtual ~Persistable() = default;