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
This commit is contained in:
Fischlurch 2015-10-30 21:44:43 +01:00
parent 9267b57c54
commit bc072ab336
2 changed files with 2 additions and 1 deletions

View file

@ -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);}

View file

@ -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<typename VAL>