Skip to content

Commit

Permalink
Identifying differences between records, structures, and tags using H…
Browse files Browse the repository at this point in the history
…ashCode (#583)
  • Loading branch information
Serg-Norseman committed Jul 2, 2024
1 parent bd3a87f commit aa0352f
Show file tree
Hide file tree
Showing 58 changed files with 617 additions and 49 deletions.
20 changes: 20 additions & 0 deletions projects/GKCore/GDModel/GDMAddress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,5 +240,25 @@ public void SetAddressArray(string[] value)
fLines.Clear();
fLines.AddRange(value);
}

protected override void ProcessHashes(ref HashCode hashCode)
{
base.ProcessHashes(ref hashCode);

hashCode.AddHash(fLines.GetHashCode());

hashCode.AddObj(fAddressLine1);
hashCode.AddObj(fAddressLine2);
hashCode.AddObj(fAddressLine3);
hashCode.AddObj(fAddressCity);
hashCode.AddObj(fAddressState);
hashCode.AddObj(fAddressPostalCode);
hashCode.AddObj(fAddressCountry);

ProcessHashes(ref hashCode, fPhoneList);
ProcessHashes(ref hashCode, fEmailList);
ProcessHashes(ref hashCode, fFaxList);
ProcessHashes(ref hashCode, fWWWList);
}
}
}
11 changes: 10 additions & 1 deletion projects/GKCore/GDModel/GDMAssociation.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* "GEDKeeper", the personal genealogical database editor.
* Copyright (C) 2009-2021 by Sergey V. Zhdanovskih.
* Copyright (C) 2009-2024 by Sergey V. Zhdanovskih.
*
* This file is part of "GEDKeeper".
*
Expand Down Expand Up @@ -102,5 +102,14 @@ public override void Assign(GDMTag source)
fRelation = sourceObj.fRelation;
if (sourceObj.fSourceCitations != null) AssignList(sourceObj.fSourceCitations, SourceCitations);
}

protected override void ProcessHashes(ref HashCode hashCode)
{
base.ProcessHashes(ref hashCode);

hashCode.AddObj(fRelation);

ProcessHashes(ref hashCode, fSourceCitations);
}
}
}
9 changes: 8 additions & 1 deletion projects/GKCore/GDModel/GDMChangeDate.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* "GEDKeeper", the personal genealogical database editor.
* Copyright (C) 2009-2019 by Sergey V. Zhdanovskih.
* Copyright (C) 2009-2024 by Sergey V. Zhdanovskih.
*
* This file is part of "GEDKeeper".
*
Expand Down Expand Up @@ -71,5 +71,12 @@ public override bool IsEmpty()
{
return base.IsEmpty() && (fChangeDateTime.Equals(ZeroDateTime));
}

protected override void ProcessHashes(ref HashCode hashCode)
{
base.ProcessHashes(ref hashCode);

hashCode.AddVal(fChangeDateTime);
}
}
}
10 changes: 9 additions & 1 deletion projects/GKCore/GDModel/GDMChildToFamilyLink.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* "GEDKeeper", the personal genealogical database editor.
* Copyright (C) 2009-2022 by Sergey V. Zhdanovskih.
* Copyright (C) 2009-2024 by Sergey V. Zhdanovskih.
*
* This file is part of "GEDKeeper".
*
Expand Down Expand Up @@ -82,5 +82,13 @@ public override void Assign(GDMTag source)
fChildLinkageStatus = srcCFL.fChildLinkageStatus;
fPedigreeLinkageType = srcCFL.fPedigreeLinkageType;
}

protected override void ProcessHashes(ref HashCode hashCode)
{
base.ProcessHashes(ref hashCode);

hashCode.AddVal(fChildLinkageStatus);
hashCode.AddVal(fPedigreeLinkageType);
}
}
}
13 changes: 12 additions & 1 deletion projects/GKCore/GDModel/GDMCommunicationRecord.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* "GEDKeeper", the personal genealogical database editor.
* Copyright (C) 2009-2022 by Sergey V. Zhdanovskih.
* Copyright (C) 2009-2024 by Sergey V. Zhdanovskih.
*
* This file is part of "GEDKeeper".
*
Expand Down Expand Up @@ -155,5 +155,16 @@ public override void ReplaceXRefs(GDMXRefReplacer map)
base.ReplaceXRefs(map);
fCorresponder.ReplaceXRefs(map);
}

protected override void ProcessHashes(ref HashCode hashCode)
{
base.ProcessHashes(ref hashCode);

hashCode.AddObj(fCommName);
hashCode.AddVal(fCommunicationType);
hashCode.AddObj(fDate);
hashCode.AddVal(fCommDirection);
hashCode.AddObj(fCorresponder);
}
}
}
19 changes: 18 additions & 1 deletion projects/GKCore/GDModel/GDMCustomEvent.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* "GEDKeeper", the personal genealogical database editor.
* Copyright (C) 2009-2023 by Sergey V. Zhdanovskih.
* Copyright (C) 2009-2024 by Sergey V. Zhdanovskih.
*
* This file is part of "GEDKeeper".
*
Expand Down Expand Up @@ -296,5 +296,22 @@ public int GetChronologicalYear()
{
return Date.GetChronologicalYear();
}

protected override void ProcessHashes(ref HashCode hashCode)
{
base.ProcessHashes(ref hashCode);

hashCode.AddObj(fAddress);
hashCode.AddObj(fAgency);
hashCode.AddObj(fCause);
hashCode.AddObj(fClassification);
hashCode.AddObj(fDate);
hashCode.AddObj(fPlace);
hashCode.AddObj(fReligiousAffilation);
hashCode.AddVal(fRestriction);
ProcessHashes(ref hashCode, fNotes);
ProcessHashes(ref hashCode, fSourceCitations);
ProcessHashes(ref hashCode, fMultimediaLinks);
}
}
}
12 changes: 11 additions & 1 deletion projects/GKCore/GDModel/GDMCutoutPosition.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* "GEDKeeper", the personal genealogical database editor.
* Copyright (C) 2009-2021 by Sergey V. Zhdanovskih.
* Copyright (C) 2009-2024 by Sergey V. Zhdanovskih.
*
* This file is part of "GEDKeeper".
*
Expand Down Expand Up @@ -126,5 +126,15 @@ internal void SetRawData(int x1, int y1, int x2, int y2)
fX2 = x2;
fY2 = y2;
}

protected override void ProcessHashes(ref HashCode hashCode)
{
base.ProcessHashes(ref hashCode);

hashCode.AddVal(fX1);
hashCode.AddVal(fY1);
hashCode.AddVal(fX2);
hashCode.AddVal(fY2);
}
}
}
13 changes: 13 additions & 0 deletions projects/GKCore/GDModel/GDMDate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -698,5 +698,18 @@ private static byte DaysInMonth(bool yearBC, short year, byte month, GDMCalendar

return (byte)DateTime.DaysInMonth(year, month);
}

protected override void ProcessHashes(ref HashCode hashCode)
{
base.ProcessHashes(ref hashCode);

hashCode.AddVal(fApproximated);
hashCode.AddVal(fCalendar);
hashCode.AddVal(fDay);
hashCode.AddVal(fMonth);
hashCode.AddVal(fYear);
hashCode.AddVal(fYearBC);
hashCode.AddObj(fYearModifier);
}
}
}
10 changes: 9 additions & 1 deletion projects/GKCore/GDModel/GDMDateInterpreted.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* "GEDKeeper", the personal genealogical database editor.
* Copyright (C) 2009-2019 by Sergey V. Zhdanovskih.
* Copyright (C) 2009-2024 by Sergey V. Zhdanovskih.
*
* This file is part of "GEDKeeper".
*
Expand All @@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

using System;
using GDModel.Providers.GEDCOM;

namespace GDModel
Expand Down Expand Up @@ -75,5 +76,12 @@ public override string ParseString(string strValue)
}
return result;
}

protected override void ProcessHashes(ref HashCode hashCode)
{
base.ProcessHashes(ref hashCode);

hashCode.AddObj(fDatePhrase);
}
}
}
8 changes: 8 additions & 0 deletions projects/GKCore/GDModel/GDMDatePeriod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,13 @@ public override void GetDateRange(out GDMDate dateStart, out GDMDate dateEnd)
dateStart = fDateFrom;
dateEnd = fDateTo;
}

protected override void ProcessHashes(ref HashCode hashCode)
{
base.ProcessHashes(ref hashCode);

hashCode.AddObj(fDateFrom);
hashCode.AddObj(fDateTo);
}
}
}
8 changes: 8 additions & 0 deletions projects/GKCore/GDModel/GDMDateRange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,5 +197,13 @@ public override void GetDateRange(out GDMDate dateStart, out GDMDate dateEnd)
dateStart = fDateAfter;
dateEnd = fDateBefore;
}

protected override void ProcessHashes(ref HashCode hashCode)
{
base.ProcessHashes(ref hashCode);

hashCode.AddObj(fDateAfter);
hashCode.AddObj(fDateBefore);
}
}
}
7 changes: 7 additions & 0 deletions projects/GKCore/GDModel/GDMDateValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,5 +179,12 @@ public override void GetDateRange(out GDMDate dateStart, out GDMDate dateEnd)
fValue.GetDateRange(out dateStart, out dateEnd);
}
}

protected override void ProcessHashes(ref HashCode hashCode)
{
base.ProcessHashes(ref hashCode);

hashCode.AddObj(fValue);
}
}
}
7 changes: 7 additions & 0 deletions projects/GKCore/GDModel/GDMFamilyEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

using System;

namespace GDModel
{
public sealed class GDMFamilyEvent : GDMCustomEvent
Expand All @@ -30,5 +32,10 @@ public GDMFamilyEvent(int tagId, string tagValue)
{
SetNameValue(tagId, tagValue);
}

protected override void ProcessHashes(ref HashCode hashCode)
{
base.ProcessHashes(ref hashCode);
}
}
}
12 changes: 11 additions & 1 deletion projects/GKCore/GDModel/GDMFamilyRecord.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* "GEDKeeper", the personal genealogical database editor.
* Copyright (C) 2009-2022 by Sergey V. Zhdanovskih.
* Copyright (C) 2009-2024 by Sergey V. Zhdanovskih.
*
* This file is part of "GEDKeeper".
*
Expand Down Expand Up @@ -305,5 +305,15 @@ public bool HasChild(GDMIndividualRecord child)
{
return IndexOfChild(child) >= 0;
}

protected override void ProcessHashes(ref HashCode hashCode)
{
base.ProcessHashes(ref hashCode);

ProcessHashes(ref hashCode, fChildren);
hashCode.AddObj(fHusband);
hashCode.AddObj(fWife);
hashCode.AddVal(fStatus);
}
}
}
10 changes: 9 additions & 1 deletion projects/GKCore/GDModel/GDMFileReference.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* "GEDKeeper", the personal genealogical database editor.
* Copyright (C) 2009-2021 by Sergey V. Zhdanovskih.
* Copyright (C) 2009-2024 by Sergey V. Zhdanovskih.
*
* This file is part of "GEDKeeper".
*
Expand Down Expand Up @@ -178,5 +178,13 @@ public static GDMMultimediaFormat RecognizeFormat(string fileName)
var strFmt = GetMultimediaExt(fileName);
return string.IsNullOrEmpty(strFmt) ? GDMMultimediaFormat.mfUnknown : GEDCOMUtils.GetMultimediaFormatVal(strFmt);
}

protected override void ProcessHashes(ref HashCode hashCode)
{
base.ProcessHashes(ref hashCode);

hashCode.AddObj(fMultimediaFormat);
hashCode.AddVal(fMediaType);
}
}
}
9 changes: 8 additions & 1 deletion projects/GKCore/GDModel/GDMFileReferenceWithTitle.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* "GEDKeeper", the personal genealogical database editor.
* Copyright (C) 2009-2019 by Sergey V. Zhdanovskih.
* Copyright (C) 2009-2024 by Sergey V. Zhdanovskih.
*
* This file is part of "GEDKeeper".
*
Expand Down Expand Up @@ -54,5 +54,12 @@ public override bool IsEmpty()
{
return base.IsEmpty() && string.IsNullOrEmpty(fTitle);
}

protected override void ProcessHashes(ref HashCode hashCode)
{
base.ProcessHashes(ref hashCode);

hashCode.AddObj(fTitle);
}
}
}
10 changes: 9 additions & 1 deletion projects/GKCore/GDModel/GDMGroupRecord.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* "GEDKeeper", the personal genealogical database editor.
* Copyright (C) 2009-2022 by Sergey V. Zhdanovskih.
* Copyright (C) 2009-2024 by Sergey V. Zhdanovskih.
*
* This file is part of "GEDKeeper".
*
Expand Down Expand Up @@ -160,5 +160,13 @@ public override void MoveTo(GDMRecord targetRecord)
targetGroup.Members.Add(obj);
}
}

protected override void ProcessHashes(ref HashCode hashCode)
{
base.ProcessHashes(ref hashCode);

hashCode.AddObj(fGroupName);
ProcessHashes(ref hashCode, fMembers);
}
}
}
8 changes: 8 additions & 0 deletions projects/GKCore/GDModel/GDMIndividualAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

using System;
using GDModel.Providers.GEDCOM;

namespace GDModel
Expand All @@ -39,5 +40,12 @@ public GDMIndividualAttribute(int tagId, string tagValue)
{
SetNameValue(tagId, tagValue);
}

protected override void ProcessHashes(ref HashCode hashCode)
{
base.ProcessHashes(ref hashCode);

//hashCode.AddObj(PhysicalDescription); <- inner Tags
}
}
}
Loading

0 comments on commit aa0352f

Please sign in to comment.