45 lines
1.7 KiB
C#
45 lines
1.7 KiB
C#
namespace BCG {
|
|
// Keeps adding changing rows to the stream, hence preserving the history
|
|
// and creating a time series, for example this can be used to make bbo updates
|
|
// into a time series of prices/qty
|
|
public class DebugStream : ViewStream {
|
|
|
|
private ViewStream _stream;
|
|
IBlueRowCollection? _last_recv_rows;
|
|
|
|
public DebugStream(ViewStream stream) {
|
|
_stream = stream;
|
|
}
|
|
|
|
protected override void myOnFirstSubscriber() {
|
|
_stream.onChange += new ChangeDelegate(_onstream_change);
|
|
}
|
|
protected override void myOnLastSubscriber() {
|
|
_stream.onChange -= new ChangeDelegate(_onstream_change);
|
|
}
|
|
|
|
private void _onstream_change(object o) {
|
|
var dp = (IDataPacket)o;
|
|
BlueDataUtility.validate_table_schema(dp.newRows);
|
|
BlueDataUtility.validate_table_schema(dp.addedRows);
|
|
if (_last_recv_rows == null) {
|
|
_last_recv_rows = dp.newRows;
|
|
} else {
|
|
//schema
|
|
bts.Log.assert(BlueDataUtility.compareSchemas(_last_recv_rows.schema, dp.newRows.schema));
|
|
bts.Log.assert(BlueDataUtility.compareSchemas(_last_recv_rows.schema, dp.addedRows.schema));
|
|
bts.Log.assert(BlueDataUtility.compareSchemas(_last_recv_rows.schema, dp.deletedRows.schema));
|
|
foreach (IBlueRow r in dp.deletedRows) {
|
|
bts.Log.assert(_last_recv_rows.containsID(r.get<int>("id")));
|
|
}
|
|
foreach (IBlueRow r in dp.addedRows) {
|
|
bts.Log.assert(dp.newRows.containsID(r.get<int>("id")));
|
|
}
|
|
_last_recv_rows = dp.newRows;
|
|
}
|
|
myFireEvent(o);
|
|
|
|
}
|
|
}
|
|
}
|