summaryrefslogtreecommitdiff
path: root/src/state.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/state.cpp')
-rw-r--r--src/state.cpp34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/state.cpp b/src/state.cpp
index 8790dfc..6e39b5e 100644
--- a/src/state.cpp
+++ b/src/state.cpp
@@ -78,13 +78,41 @@ vector<Ref> LocalState::lookupShared(UUID type) const
return res;
}
+vector<Ref> LocalState::sharedRefs() const
+{
+ vector<Ref> refs;
+ for (const auto & x : p->shared)
+ refs.push_back(x.ref());
+ return refs;
+}
+
+LocalState LocalState::sharedRefAdd(const Ref & ref) const
+{
+ const Storage * st;
+ if (p->shared.size() > 0)
+ st = &p->shared[0].ref().storage();
+ else if (p->identity)
+ st = &p->identity->ref()->storage();
+ else
+ st = &ref.storage();
+
+ LocalState ret;
+ ret.p->identity = p->identity;
+ ret.p->shared = p->shared;
+ ret.p->shared.push_back(SharedState(ref).store(*st));
+ filterAncestors(ret.p->shared);
+ return ret;
+}
+
LocalState LocalState::updateShared(UUID type, const vector<Ref> & xs) const
{
const Storage * st;
- if (xs.size() > 0)
- st = &xs[0].storage();
- else if (p->shared.size() > 0)
+ if (p->shared.size() > 0)
st = &p->shared[0].ref().storage();
+ else if (p->identity)
+ st = &p->identity->ref()->storage();
+ else if (xs.size() > 0)
+ st = &xs[0].storage();
else
return *this;