Table of Contents

Class LinksUndoLog<TLinkAddress>

Namespace
Foundation.Data.Doublets.Cli
Assembly
Foundation.Data.Doublets.Cli.dll

The writes made to a store, kept to undo them: every change a write reports, and the names the links had before (issue #149).

public sealed class LinksUndoLog<TLinkAddress> where TLinkAddress : struct, IUnsignedNumber<TLinkAddress>

Type Parameters

TLinkAddress
Inheritance
LinksUndoLog<TLinkAddress>
Inherited Members

Remarks

A store reports a change as (before, after): (null, link) for a creation, (link, null) for a deletion. Undoing goes back through the changes: it deletes what was created, updates back what was updated and creates again, at the same address, what was deleted. Names are not changes: a deleted link loses its name before anyone above the names store hears of the deletion, so the names a write may touch are kept before it, with KeepName(INamedTypes<TLinkAddress>, TLinkAddress) and KeepNamesOfUsages(INamedTypesLinks<TLinkAddress>, TLinkAddress).

Properties

Changes

The changes kept, in the order they were made.

public IReadOnlyList<(Link<TLinkAddress>? Before, Link<TLinkAddress>? After)> Changes { get; }

Property Value

IReadOnlyList<(Link<TLinkAddress>? Before, Link<TLinkAddress>? After)>

IsEmpty

Whether nothing is kept.

public bool IsEmpty { get; }

Property Value

bool

Methods

Clear()

Forgets everything kept: the writes stay.

public void Clear()

Keeps the name of the link called name now, if any.

public void KeepHolderOf(INamedTypesLinks<TLinkAddress> links, string name)

Parameters

links INamedTypesLinks<TLinkAddress>
name string

KeepName(INamedTypes<TLinkAddress>, TLinkAddress)

Keeps the name link has now, unless one of it is kept already.

public void KeepName(INamedTypes<TLinkAddress> names, TLinkAddress link)

Parameters

names INamedTypes<TLinkAddress>
link TLinkAddress

Keeps the names of link and of every link that uses it, directly or not: the links deleting it deletes, or merging it repoints.

public void KeepNamesOfUsages(INamedTypesLinks<TLinkAddress> links, TLinkAddress link)

Parameters

links INamedTypesLinks<TLinkAddress>
link TLinkAddress

Record(IList<TLinkAddress>?, IList<TLinkAddress>?)

Keeps one change a store reported.

public void Record(IList<TLinkAddress>? before, IList<TLinkAddress>? after)

Parameters

before IList<TLinkAddress>
after IList<TLinkAddress>

Undoes every write kept, on links (the store the writes were made on, not a view or a recorder over it), and forgets them.

public IReadOnlyList<TLinkAddress> Undo(INamedTypesLinks<TLinkAddress> links)

Parameters

links INamedTypesLinks<TLinkAddress>

Returns

IReadOnlyList<TLinkAddress>

The addresses of the links the writes created, now deleted again.

link and every link that uses it, directly or not.

public static List<TLinkAddress> UsagesOf(ILinks<TLinkAddress> links, TLinkAddress link)

Parameters

links ILinks<TLinkAddress>
link TLinkAddress

Returns

List<TLinkAddress>