53 lines
1.8 KiB
ObjectPascal
53 lines
1.8 KiB
ObjectPascal
unit Myc.Trade.DataServer;
|
|
|
|
interface
|
|
|
|
uses
|
|
System.SysUtils,
|
|
Myc.Lazy,
|
|
Myc.Signals,
|
|
Myc.Futures;
|
|
|
|
type
|
|
// Represents a generic data server capable of providing sequential data chunks.
|
|
// The type parameter T specifies the type of data points served.
|
|
IDataServer<T> = interface
|
|
['{A6E246A2-E84E-49AB-A63E-333E561E488C}']
|
|
// Provides a TMutable<Boolean> that indicates if the server is currently
|
|
// serving live data (true) or historical data (false).
|
|
function GetIsLiveData: TMutable<Boolean>;
|
|
// Retrieves a chunk of data into the provided dynamic array.
|
|
// Returns the number of items successfully read into the array.
|
|
function GetChunk(var Data: array of T): Integer;
|
|
property IsLiveData: TMutable<Boolean> read GetIsLiveData;
|
|
end;
|
|
|
|
// Abstract base class for IDataServer implementations.
|
|
TDataServer<T> = class(TInterfacedObject, IDataServer<T>)
|
|
protected
|
|
function GetIsLiveData: TMutable<Boolean>; virtual; abstract;
|
|
function GetChunk(var Data: array of T): Integer; virtual; abstract;
|
|
end;
|
|
|
|
// Represents a factory for creating IDataServer instances.
|
|
// The type parameter T specifies the type of data points the created server will provide.
|
|
IDataServerNode<T> = interface
|
|
['{DA3531F1-158E-4A63-8E5A-34089C537B1B}']
|
|
// Creates and returns a new instance of an IDataServer.
|
|
function CreateDataServer: IDataServer<T>;
|
|
end;
|
|
|
|
// Abstract base class for IDataServerNode implementations.
|
|
TDataServerNode<T> = class(TInterfacedObject, IDataServerNode<T>)
|
|
public
|
|
// Factory method to create the actual data server instance.
|
|
function CreateDataServer: IDataServer<T>; virtual; abstract;
|
|
end;
|
|
|
|
implementation
|
|
|
|
uses
|
|
System.IOUtils;
|
|
|
|
end.
|