summaryrefslogtreecommitdiff
path: root/lib/persistence.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/persistence.cpp')
-rw-r--r--lib/persistence.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/persistence.cpp b/lib/persistence.cpp
index 06e40c7..e22d74d 100644
--- a/lib/persistence.cpp
+++ b/lib/persistence.cpp
@@ -48,10 +48,15 @@ namespace Persistence {
PersistenceSelect::PersistenceSelect(const std::string & n) : name {n} { }
- PersistenceStore::NameAction
- PersistenceSelect::setName(const std::string_view key, const Selection &)
+ PersistenceStore::NameActionSelection
+ PersistenceSelect::setName(const std::string_view key, SelectionFactory && factory)
{
- return (key == name) ? NameAction::Push : NameAction::Ignore;
+ if (key == name) {
+ return {NameAction::Push, factory()};
+ }
+ else {
+ return {NameAction::Ignore, nullptr};
+ }
}
void
@@ -61,10 +66,11 @@ namespace Persistence {
PersistenceWrite::PersistenceWrite(const Writer & o, bool sh) : out {o}, shared {sh} { }
- PersistenceStore::NameAction
- PersistenceWrite::setName(const std::string_view key, const Selection & s)
+ PersistenceStore::NameActionSelection
+ PersistenceWrite::setName(const std::string_view key, SelectionFactory && factory)
{
- if (s.needsWrite()) {
+ auto s = factory();
+ if (s->needsWrite()) {
if (!first) {
out.nextValue();
}
@@ -72,9 +78,9 @@ namespace Persistence {
first = false;
}
out.pushKey(key);
- return NameAction::HandleAndContinue;
+ return {NameAction::HandleAndContinue, std::move(s)};
}
- return NameAction::Ignore;
+ return {NameAction::Ignore, nullptr};
}
void