Class TContractDB

Unit

Declaration

type TContractDB = class(TObject)

Description

Main lightweight DB class

Hierarchy

Overview

Methods

Public constructor Create(const AConsoleServer: TConsoleReaderThread);
Public destructor Destroy; override;
Public procedure Test;
Public procedure SetConsoleServer(const AConsoleServer: TConsoleReaderThread);
Public procedure UnregisterPanel(const PanelID: Integer);
Public procedure PanelChanged(const PanelID: Integer; const AItem: TTradeRouteLegItem; const ATradeRouteLeg: TTradeRouteLeg);
Public function GetContracts: TContractArray;
Public function RegisterPanel( const ATradeRouteLeg: TTradeRouteLeg; const OnLegNotify: TPanelLegNotify; const OnContractNotify: TPanelContractNotify): Integer; overload;
Public function RegisterPanel( const OnLegNotify: TPanelLegNotify; const OnContractNotify: TPanelContractNotify): Integer; overload;

Properties

Public property Contracts: TContractArray read GetContracts;

Description

Methods

Public constructor Create(const AConsoleServer: TConsoleReaderThread);

Constructor

Parameters
AConsoleServer
Public destructor Destroy; override;

Destructor

Public procedure Test;

Test the DB.

Public procedure SetConsoleServer(const AConsoleServer: TConsoleReaderThread);

Set the console server for logging purposes.

Public procedure UnregisterPanel(const PanelID: Integer);

Unregister a panel and cleanup limbo leg (if any).

Public procedure PanelChanged(const PanelID: Integer; const AItem: TTradeRouteLegItem; const ATradeRouteLeg: TTradeRouteLeg);

Called by panels when something changed in the GUI. The DB will decide whether to store the leg in the limbo dict or attach it to a contract. AItem describes which field was changed.

Parameters
PanelID
AItem
The field that changed.
ATradeRouteLeg
The updated leg.
Exceptions raised
Exception
Public function GetContracts: TContractArray;

Retrieve all contracts.

Returns

TContractArray

Public function RegisterPanel( const ATradeRouteLeg: TTradeRouteLeg; const OnLegNotify: TPanelLegNotify; const OnContractNotify: TPanelContractNotify): Integer; overload;

Register a panel. Returns a unique PanelID. The panel should keep this ID. Both callbacks are optional (pass nil if not required).

Parameters
ATradeRouteLeg
The updated leg.
OnLegNotify
The callback for leg updates.
OnContractNotify
The callback for contract updates.
Returns

Integer the PanelID.

Public function RegisterPanel( const OnLegNotify: TPanelLegNotify; const OnContractNotify: TPanelContractNotify): Integer; overload;

Register a panel. Returns a unique PanelID. The panel should keep this ID. Both callbacks are optional (pass nil if not required).

Parameters
OnLegNotify
The callback for leg updates.
OnContractNotify
The callback for contract updates.
Returns

Integer the PanelID.

Properties

Public property Contracts: TContractArray read GetContracts;

Retrieve contracts.