From bc072ab3366503d51b75ea351acb7d99fc3d281f Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 30 Oct 2015 21:44:43 +0100 Subject: [PATCH] Generic Record: change semantics of the "match" operation for objects in the first version, I defined equality to just compare the IDs But that didn't seem right, or what one would expect by the concept of equality (this is a long standing discussion with persistent object-relationally mapped data). So I changed the semantics of equaility to be "deep". As this means possiblty to visit a whole tree depth-first, it seems reasonable to provide the shallow "identity-comparison" likewise. And the most reaonable choice is to use the "matches(object)" API for that, since, in case of objects, the matches was defined as full equality, which now seems redundant. Thus: from now on: obj.matches(otherObj) means they share the same IDs --- src/lib/diff/gen-node.hpp | 2 +- src/lib/diff/record.hpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/diff/gen-node.hpp b/src/lib/diff/gen-node.hpp index 44dbbf7cb..90f699e0f 100644 --- a/src/lib/diff/gen-node.hpp +++ b/src/lib/diff/gen-node.hpp @@ -286,7 +286,7 @@ namespace diff{ bool contains (X const& elm) const; - bool matches (GenNode const& o) const { return o == *this; } + bool matches (GenNode const& o) const { return this->matches(o.idi); } ///< @note \em not comparing payload data. Use equality for that bool matches (ID const& id) const { return idi == id; } bool matches (int number) const { return data.matchNum(number);} bool matches (int64_t number) const { return data.matchNum(number);} diff --git a/src/lib/diff/record.hpp b/src/lib/diff/record.hpp index ea3642536..73754d6f1 100644 --- a/src/lib/diff/record.hpp +++ b/src/lib/diff/record.hpp @@ -511,6 +511,7 @@ namespace diff{ * This trickery is necessary to avoid copying a large and possibly * nested object tree; this happens when applying a diff, when * recursively descending into nested child objects. + * @todo do we have a design mismatch here?? /////////////////////////////////////////TICKET #970 * @see tree-diff-application.hpp */ template