75 lines
2.4 KiB
C#
75 lines
2.4 KiB
C#
using System;
|
|
|
|
namespace BCG
|
|
{
|
|
/// <summary>
|
|
/// Marker abstract class
|
|
/// </summary>
|
|
public abstract class ViewStream : DataStream
|
|
{
|
|
private IBlueRowCollection myLastValueForTestMode;
|
|
// protected bool myUseUncopiedNewRowsInFireEvent =
|
|
// Configuration.get<DataStreamConfig>().UseUncopiedNewRowsInFire;
|
|
protected bool myUseUncopiedNewRowsInFireEvent = false;
|
|
|
|
string streamName;
|
|
|
|
public ViewStream (ViewStream sourceStream)
|
|
:
|
|
base(sourceStream)
|
|
{}
|
|
|
|
public ViewStream(string streamName) {
|
|
this.streamName = streamName;
|
|
}
|
|
|
|
public ViewStream()
|
|
{}
|
|
|
|
public Guid StreamId { get; } = Guid.NewGuid();
|
|
|
|
public string StreamName => streamName
|
|
?? (myRealSource as ViewStream)?.StreamName
|
|
?? GetType().Name;
|
|
|
|
protected override object myGetValueForInitialSubscription()
|
|
{
|
|
if (myLastValue == null)
|
|
return null;
|
|
else
|
|
{
|
|
var rows = ((IDataPacket)myLastValue).newRows;
|
|
return new DataPacket(rows, rows, new BlueTable(rows.schema));
|
|
}
|
|
|
|
}
|
|
|
|
protected override void myFireEvent(object o)
|
|
{
|
|
var dp = o as IDataPacket;
|
|
|
|
// BlueTrace.WriteViewStreamFireEvent(this.ID,
|
|
// dp.newRows == null ? 0 : dp.newRows.Count,
|
|
// dp.addedRows == null ? 0 : dp.addedRows.Count,
|
|
// dp.deletedRows == null ? 0 : dp.deletedRows.Count);
|
|
|
|
if (myTestMode)
|
|
{
|
|
// BlueEventLog.logAssert ((myFirstSubImplemented && myLastSubImplemented) | myRealSource != null,
|
|
// @"either myOnFirstSub/myOnLastSub should be implemented or mySetRealSource
|
|
// called with a non-null arg in " + this.GetType().FullName);
|
|
if (myLastValueForTestMode != null)
|
|
BlueDataUtility.checkConsistency(myLastValueForTestMode,
|
|
dp.newRows, dp.deletedRows, dp.addedRows);
|
|
myLastValueForTestMode = new ImmutableBlueTable(dp.newRows);
|
|
}
|
|
// the view already garantees that added & deleted are immutable.
|
|
// this garantess that new is also immutable
|
|
base.myFireEvent(myUseUncopiedNewRowsInFireEvent ? dp : dp.ToImmutable());
|
|
}
|
|
|
|
private void myDummy (object o)
|
|
{}
|
|
}
|
|
}
|