refactor: Move a few low-level DataStream types to DataStreamCore
So the lex/yacc generators can reference them
This commit is contained in:
1 parent
d1f5ae86fd
commit
ac1ede5986
10 files changed
+6
-30
No files matched your search
@@ -0,0 +1,97 @@
|
||||
using System;
|
||||
//using BCG.Utilities.BlueConfiguration;
|
||||
|
||||
using BCG.Utilities;
|
||||
|
||||
namespace BCG
|
||||
{
|
||||
/// <summary>
|
||||
/// Marker abstract class
|
||||
/// </summary>
|
||||
public abstract class ViewStream : DataStream
|
||||
{
|
||||
private IBlueRowCollection myLastValueForTestMode;
|
||||
protected bool myUseUncopiedNewRowsInFireEvent = DataStreamLoadFileConfig.instance.useUncopiedNewRowsInFireEvent;
|
||||
|
||||
public ViewStream (ViewStream sourceStream)
|
||||
:
|
||||
base(sourceStream)
|
||||
{}
|
||||
|
||||
public ViewStream()
|
||||
{}
|
||||
|
||||
public IBlueRowCollection rows
|
||||
{
|
||||
get
|
||||
{
|
||||
if (myRealSource != null)
|
||||
{
|
||||
// BlueEventLog.logAssert (myRealSource is ViewStream);
|
||||
|
||||
return (myRealSource as ViewStream).rows;
|
||||
}
|
||||
else
|
||||
{
|
||||
// used to force a computation of a stream which
|
||||
// happens to have no subscribers
|
||||
onChange += new DataStream.ChangeDelegate(myDummy);
|
||||
try
|
||||
{
|
||||
|
||||
if (myLastValue != null)
|
||||
return ((DataPacket) myLastValue).newRows;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
onChange -= new DataStream.ChangeDelegate(myDummy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override object myGetValueForInitialSubscription()
|
||||
{
|
||||
if (myLastValue == null)
|
||||
return null;
|
||||
else
|
||||
{
|
||||
return new DataPacket(
|
||||
(myLastValue as DataPacket).newRows,
|
||||
(myLastValue as DataPacket).newRows,
|
||||
new BlueTable((myLastValue as DataPacket).newRows.schema));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected override void myFireEvent(object o)
|
||||
{
|
||||
DataPacket dp = (DataPacket) o;
|
||||
|
||||
// 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.createImmutable());
|
||||
|
||||
}
|
||||
|
||||
private void myDummy (object o)
|
||||
{}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user