summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-03-14 18:14:54 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2023-03-14 18:14:54 +0000
commit2d6772cb1c592e4bd75be40f1fdfa924bbbc3c07 (patch)
tree751ac31e6a0e38fb5f17040da3937856fad7f111 /lib
parentGlobally enable GLM vector swizzles (diff)
downloadilt-2d6772cb1c592e4bd75be40f1fdfa924bbbc3c07.tar.bz2
ilt-2d6772cb1c592e4bd75be40f1fdfa924bbbc3c07.tar.xz
ilt-2d6772cb1c592e4bd75be40f1fdfa924bbbc3c07.zip
Add postLoad support to persistence
Diffstat (limited to 'lib')
-rw-r--r--lib/persistence.cpp5
-rw-r--r--lib/persistence.h10
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/persistence.cpp b/lib/persistence.cpp
index 8c7c6a4..06e40c7 100644
--- a/lib/persistence.cpp
+++ b/lib/persistence.cpp
@@ -41,6 +41,11 @@ namespace Persistence {
return ss.str();
}
+ void
+ Persistable::postLoad()
+ {
+ }
+
PersistenceSelect::PersistenceSelect(const std::string & n) : name {n} { }
PersistenceStore::NameAction
diff --git a/lib/persistence.h b/lib/persistence.h
index 35d60ca..1cb3af0 100644
--- a/lib/persistence.h
+++ b/lib/persistence.h
@@ -311,8 +311,9 @@ namespace Persistence {
void
endObject(Persistence::Stack & stk) override
{
+ // TODO test with unique_ptr
map.emplace(std::invoke(Key, s), std::move(s));
- stk.pop();
+ Persistence::SelectionT<Type>::endObject(stk);
}
private:
@@ -327,8 +328,9 @@ namespace Persistence {
void
endObject(Persistence::Stack & stk) override
{
+ // TODO test with unique_ptr
container.emplace_back(std::move(s));
- stk.pop();
+ Persistence::SelectionT<Type>::endObject(stk);
}
private:
@@ -342,6 +344,7 @@ namespace Persistence {
DEFAULT_MOVE_COPY(Persistable);
virtual bool persist(PersistenceStore & store) = 0;
+ virtual void postLoad();
[[nodiscard]] virtual std::string getId() const;
@@ -484,6 +487,9 @@ namespace Persistence {
endObject(Stack & stk) override
{
make_default_as_needed(this->v);
+ if (this->v) {
+ this->v->postLoad();
+ }
stk.pop();
}