Class ViewBase
Non-generic base class for EcsView<TArchetype> and NavigationView<TSource, TTarget>. Contains entity set management, delta tracking, disposal, and process-unique ViewId generation.
public abstract class ViewBase : IView, IDisposable, IEnumerable<long>, IEnumerable
- Inheritance
-
ViewBase
- Implements
- Derived
-
EcsView<TArchetype>NavigationView<TSource, TTarget>
- Inherited Members
Fields
Evaluators
Field predicate evaluators applied during refresh. Empty for pull-mode views with no WHERE clause.
protected readonly FieldEvaluator[] Evaluators
Field Value
Properties
CachedPlan
First cached execution plan, or default when the view has no cached plan.
protected ExecutionPlan CachedPlan { get; }
Property Value
CachedPlans
All cached execution plans (one per OR branch), or null when the view has no cached plan.
protected ExecutionPlan[] CachedPlans { get; }
Property Value
Count
Number of entities currently in the view.
public int Count { get; }
Property Value
ExecutionPlan
Cached execution plan for the primary query branch, or default when the view has no cached plan.
public ExecutionPlan ExecutionPlan { get; }
Property Value
FieldDependencies
Indices of the indexed fields this view depends on; drives which component mutations notify the view.
public int[] FieldDependencies { get; }
Property Value
- int[]
HasCachedPlan
True when this view was built with a cached execution plan.
public bool HasCachedPlan { get; }
Property Value
HasCachedPlanInternal
True when cached execution plans are present.
protected bool HasCachedPlanInternal { get; }
Property Value
HasOverflow
True when the delta ring buffer overflowed since the last refresh, forcing a full re-scan.
After overflow, per-field Modified tracking is lost — only Added/Removed are reported.
public bool HasOverflow { get; }
Property Value
IsDisposed
True once the view has been disposed and its buffers released.
public bool IsDisposed { get; }
Property Value
IsPublished
True if this View has been published for client subscriptions via PublishView().
public bool IsPublished { get; }
Property Value
IsSystemInput
True if this View is used as a system input in the DAG scheduler.
public bool IsSystemInput { get; }
Property Value
LastRefreshTSN
Transaction sequence number (TSN) of the most recent refresh.
public long LastRefreshTSN { get; }
Property Value
SourceFile
User source file where this View was constructed. Captured via [CallerFilePath] on the public Query API (e.g., ToView()).
Null if construction was internal/unattributed. Path form depends on the consuming project's PathMap / DeterministicSourcePaths
MSBuild configuration — Typhon's own projects produce /_/… repo-relative paths.
public string SourceFile { get; }
Property Value
SourceLine
User source line where this View was constructed. Captured via [CallerLineNumber]. Zero if unattributed.
public int SourceLine { get; }
Property Value
SourceMethod
User source method name where this View was constructed. Captured via [CallerMemberName]. Null if unattributed.
public string SourceMethod { get; }
Property Value
ViewId
Process-unique identifier for this view, assigned at construction.
public int ViewId { get; }
Property Value
Methods
ApplyDelta(long, bool, bool)
Updates the entity set and delta tracking for one entity given its previous and new membership: adds it, removes it,
or marks it Modified when membership is unchanged but the entity remains in the view.
protected void ApplyDelta(long pk, bool wasInView, bool shouldBeInView)
Parameters
pklongEntity primary key.
wasInViewboolWhether the entity was in the view before this change.
shouldBeInViewboolWhether the entity should be in the view after this change.
ClearDelta()
Clears accumulated delta tracking, invalidating any ViewDelta previously returned by GetDelta().
public void ClearDelta()
Contains(long)
Returns true when the entity with the given primary key is currently in the view.
public bool Contains(long pk)
Parameters
pklongEntity primary key.
Returns
DeregisterFromRegistries()
Deregister from all owning ViewRegistries. Called during disposal.
protected abstract void DeregisterFromRegistries()
Dispose()
Deregisters the view from all owning registries and releases the delta ring buffer and entity set. Idempotent — subsequent calls are no-ops.
public void Dispose()
DrainBufferAfterRefreshFull(long)
Drains ring buffer entries that arrived during a RefreshFull re-scan, advancing the consumer position without processing entries (the full scan already captured the authoritative entity set).
protected void DrainBufferAfterRefreshFull(long targetTSN)
Parameters
targetTSNlong
GetDelta()
Returns a zero-allocation ViewDelta over the entities added, removed, and modified since the last ClearDelta(). The returned struct is only valid until the next ClearDelta() call.
public ViewDelta GetDelta()
Returns
Refresh(Transaction, string, int, string)
Drain the ring buffer, evaluate predicates, and update entity set and delta tracking.
public abstract void Refresh(Transaction tx, string callerFile = null, int callerLine = 0, string callerMethod = null)
Parameters
txTransactioncallerFilestringcallerLineintcallerMethodstring
Remarks
The three trailing caller… parameters are populated by [CallerFilePath] / [CallerLineNumber] / [CallerMemberName]
at user call sites. When the runtime/scheduler invokes a refresh, it must use Typhon.Engine.ViewBase.RefreshFromScheduler(Typhon.Engine.Transaction) instead so engine-internal
paths don't end up as the "user execution site" in the trace.
SetLastRefreshTSN(long)
Records the TSN of the current refresh, surfaced by LastRefreshTSN.
protected void SetLastRefreshTSN(long tsn)
Parameters
tsnlongTransaction sequence number of the refresh.
SetOverflowDetected(bool)
Sets the overflow flag surfaced by HasOverflow.
protected void SetOverflowDetected(bool value)
Parameters
valueboolNew overflow state.
TryMarkDisposed()
Atomically transitions the view to the disposed state. Returns true on the first call, false if already disposed.
protected bool TryMarkDisposed()
Returns
WithTier(SimTier)
Set this view's tier filter to scope subsequent materializations to a subset of SimTier values.
Non-generic overload. Returns this for chaining when the concrete type is not needed. Issue #231.
public ViewBase WithTier(SimTier tier)
Parameters
tierSimTier
Returns
WithTier<T>(SimTier)
Set this view's tier filter to scope subsequent materializations to a subset of SimTier values.
Returns this (as T) to allow chaining: tx.Query<Ant>().ToView().WithTier(SimTier.Tier0). Issue #231.
public T WithTier<T>(SimTier tier) where T : ViewBase
Parameters
tierSimTier
Returns
- T
Type Parameters
T