namespace BCG { // this is the stream that gets tables directly off the pubsubServer public class TableStream : ViewStream { private readonly string _table_name; private readonly ITableAccumulator _ta; public TableStream(string table_name) : this(table_name, ViewStreamDatabase.instance) { } public TableStream(string table_name, ViewStreamDatabase db) { _table_name = table_name; db = db == null ? ViewStreamDatabase.instance : db; _ta = db.getITableAccumulator(_table_name); } protected override void myOnFirstSubscriber() { _ta.on_update += new TableUpdateDelegate(_handle_updates); } protected override void myOnLastSubscriber() { _ta.on_update -= new TableUpdateDelegate(_handle_updates); } protected virtual void _handle_updates( IBlueRowCollection new_rows, IBlueRowCollection added_rows, IBlueRowCollection del_rows) { myFireEvent(new DataPacket(new_rows, added_rows, del_rows)); } public override string ToString() { return $"{GetType()} table: {_table_name}"; } } }