summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/merge.cpp26
2 files changed, 27 insertions, 0 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 72094b8..cb0db6d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -8,6 +8,7 @@ add_library(erebos
contact.cpp
frp.cpp
identity.cpp
+ merge.cpp
message.cpp
network.cpp
pairing.cpp
diff --git a/src/merge.cpp b/src/merge.cpp
new file mode 100644
index 0000000..040ebb4
--- /dev/null
+++ b/src/merge.cpp
@@ -0,0 +1,26 @@
+#include <erebos/merge.h>
+
+namespace erebos {
+
+static void findPropertyObjects(vector<Stored<Object>> & candidates, const Stored<Object> & obj, const string & prop)
+{
+ if (auto rec = obj->asRecord()) {
+ if (rec->item(prop)) {
+ candidates.push_back(obj);
+ } else {
+ for (const auto & r : obj.ref().previous())
+ findPropertyObjects(candidates, Stored<Object>::load(r), prop);
+ }
+ }
+}
+
+vector<Stored<Object>> findPropertyObjects(const vector<Stored<Object>> & leaves, const string & prop)
+{
+ vector<Stored<Object>> candidates;
+ for (const auto & obj : leaves)
+ findPropertyObjects(candidates, obj, prop);
+ filterAncestors(candidates);
+ return candidates;
+}
+
+}