summaryrefslogtreecommitdiff
path: root/src/identity.cpp
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2021-05-09 15:20:30 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2021-05-09 19:34:01 +0200
commitd563500c915de2f0a652513af03f101c99715db3 (patch)
tree735c0dd4d3b62737170b5328b455b74ea60f3822 /src/identity.cpp
parent00e52ec8ee38a85737c093d90ebfba5069829608 (diff)
SharedType: type trait instead of member functions and typedef
Diffstat (limited to 'src/identity.cpp')
-rw-r--r--src/identity.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/identity.cpp b/src/identity.cpp
index a4c12f2..f55f6dd 100644
--- a/src/identity.cpp
+++ b/src/identity.cpp
@@ -1,5 +1,7 @@
#include "identity.h"
+#include <erebos/state.h>
+
#include <algorithm>
#include <set>
#include <stdexcept>
@@ -11,7 +13,14 @@ using std::nullopt;
using std::runtime_error;
using std::set;
-const UUID Identity::sharedTypeId { "0c6c1fe0-f2d7-4891-926b-c332449f7871" };
+DEFINE_SHARED_TYPE(optional<Identity>,
+ "0c6c1fe0-f2d7-4891-926b-c332449f7871",
+ &Identity::load,
+ [](const optional<Identity> & id) {
+ if (id)
+ return id->store();
+ return vector<Ref>();
+ })
Identity::Identity(const Priv * p): p(p) {}
Identity::Identity(shared_ptr<const Priv> && p): p(std::move(p)) {}
@@ -34,6 +43,15 @@ optional<Identity> Identity::load(const vector<Ref> & refs)
return nullopt;
}
+vector<Ref> Identity::store() const
+{
+ vector<Ref> res;
+ res.reserve(p->data.size());
+ for (const auto & x : p->data)
+ res.push_back(x.ref());
+ return res;
+}
+
vector<Ref> Identity::store(const Storage & st) const
{
vector<Ref> res;