Unit ContractDBUnit
Description
Lightweight in-memory DB for Contracts and TradeRouteLegs.
TContractDB manages:
Contracts (mapped by GroupId)
TradeRouteLegs (temporary "limbo" legs mapped by PanelID)
Panel subscriptions (panels register to receive notifications)
Design notes:
Panels register with RegisterPanel and receive a unique PanelID.
Panels provide two optional callbacks: one for leg/row updates (OnLegNotify) and one for contract-level updates (OnContractNotify).
When a panel pushes an updated TTradeRouteLeg to the DB via PanelChanged, if Leg.GroupId = 0 the leg is kept in the TTradeRouteLeg mapping; if Leg.GroupId > 0 the DB will create or update a TContract for that GroupId, convert the leg into a TContractLeg and add/remove it from the contract.
If a panel moves from a GroupId > 0 back to 0, the associated contract leg is removed from the contract and the route leg is returned to the limbo mapping.
We assume that all changes to the status of the system stored in the database occur within limbo; to achieve this, we modify the GroupID of the calling panel by setting it to 0 and only operate in the instruction block with AItem = eGroupID. *
Overview
Classes, Interfaces, Objects and Records
| Name | Description |
|---|---|
Class TPanelSubscriber |
Internal subscription object for panels. |
Class TContractDB |
Main lightweight DB class |