Table of Contents

Class DynamicFeatureTracker<TInbound>

Namespace
EncDotNet.S100.DynamicSources
Assembly
EncDotNet.S100.Core.dll

Optional helper that an adapter with aging semantics (AIS sleeping/lost, stale-sensor styling, fleet-track expiry) can opt into. Sources without aging do not use it.

public sealed class DynamicFeatureTracker<TInbound>

Type Parameters

TInbound

The adapter's raw update type, projected to DynamicFeature by the caller-supplied projection.

Inheritance
DynamicFeatureTracker<TInbound>
Inherited Members

Remarks

The tracker is a plain dictionary-plus-event store with two operations: Apply(TInbound) ingests one inbound update and returns a change descriptor; Sweep(DateTimeOffset, TimeSpan) retires entries that haven't been updated within a caller-supplied threshold. The library does not impose timer defaults — adapters supply their own (AIS, for example, uses spec-defined timers in the adapter, not in this helper).

The tracker is thread-safe for concurrent Apply(TInbound) / Sweep(DateTimeOffset, TimeSpan) / Current access; internal state is guarded by a single lock.

Constructors

DynamicFeatureTracker(Func<TInbound, DynamicFeature>)

Creates a tracker. project converts the adapter's inbound update into a DynamicFeature — typically a small mapping that fills the stable Id, the geometry, and the adapter-flavoured Attributes.

public DynamicFeatureTracker(Func<TInbound, DynamicFeature> project)

Parameters

project Func<TInbound, DynamicFeature>

Properties

Current

The current immutable snapshot. Updated atomically on each Apply(TInbound) / Sweep(DateTimeOffset, TimeSpan) call. Safe to read from any thread.

public IReadOnlyList<DynamicFeature> Current { get; }

Property Value

IReadOnlyList<DynamicFeature>

Methods

Apply(TInbound)

Applies one inbound update and returns a description of the change (Added or Updated). The returned descriptor names the single touched id.

public DynamicFeaturesChanged Apply(TInbound update)

Parameters

update TInbound

Returns

DynamicFeaturesChanged

Clear()

Drops all known features and returns a Reset descriptor.

public DynamicFeaturesChanged Clear()

Returns

DynamicFeaturesChanged

Remove(string)

Removes the entry with the given id, if present. Returns a Removed descriptor when the id was found, or a Reset descriptor with no ids when not.

public DynamicFeaturesChanged Remove(string id)

Parameters

id string

Returns

DynamicFeaturesChanged

Sweep(DateTimeOffset, TimeSpan)

Removes entries whose LastUpdated is older than now minus retain. Returns a Removed descriptor when anything was swept, or a Reset descriptor with no ids when nothing changed.

public DynamicFeaturesChanged Sweep(DateTimeOffset now, TimeSpan retain)

Parameters

now DateTimeOffset

Caller-supplied "now" — exposed for testability with a synthetic clock.

retain TimeSpan

Maximum age before an entry is removed.

Returns

DynamicFeaturesChanged