ORE Studio 0.0.4
Loading...
Searching...
No Matches
Signals | Public Member Functions | List of all members
IInstrumentForm Class Referenceabstract

Pure-virtual interface implemented by every per-family instrument form widget hosted in TradeDetailDialog. More...

#include <IInstrumentForm.hpp>

Inheritance diagram for IInstrumentForm:
Inheritance graph
Collaboration diagram for IInstrumentForm:
Collaboration graph

Signals

void changed ()
 Emitted when any field changes (after the initial load).
 
void instrumentLoaded ()
 Emitted once the asynchronous load has populated the form.
 
void loadFailed (const QString &error)
 Emitted on a load failure with the server's error message.
 
void provenanceChanged (const InstrumentProvenance &provenance)
 Emitted with the latest audit metadata after load and save.
 

Public Member Functions

virtual void setClientManager (ClientManager *cm)=0
 Inject the NATS client used for load and save round-trips.
 
virtual void setUsername (const std::string &username)=0
 Inject the username stamped on every saved instrument.
 
virtual void setImageCache (ImageCache *)
 Inject the image cache for flag icons on currency combo boxes.
 
virtual void setInstrument (const trading::domain::trade_instrument &instrument)=0
 Populate the form with the already-resolved instrument.
 
virtual void clear ()=0
 Reset the form to a blank state ready for create mode.
 
virtual void setTradeType (const QString &code, bool has_options, bool has_extension)=0
 Inform the form which trade type is currently selected.
 
virtual void setReadOnly (bool readOnly)=0
 Toggle read-only on every editable widget.
 
virtual bool isDirty () const =0
 Has the user edited any field since the last load or save?
 
virtual bool isLoaded () const =0
 True after the asynchronous load has populated the form.
 
virtual void setChangeReason (const std::string &code, const std::string &commentary)=0
 Stamp the change reason on the in-flight instrument before the dialog calls saveInstrument.
 
virtual void writeUiToInstrument ()=0
 Pull the current UI values into the in-flight domain object.
 
virtual void saveInstrument (std::function< void(const std::string &id)> on_success, std::function< void(const QString &error)> on_failure)=0
 Save the in-flight instrument via the family's NATS request.
 

Detailed Description

Pure-virtual interface implemented by every per-family instrument form widget hosted in TradeDetailDialog.

Each subclass owns the UI, the in-flight domain object, and the NATS load/save plumbing for exactly one product family. The outer dialog only sees this interface and never references family-specific types.

Lifecycle:

  1. Dialog construction: instantiate the form via the registry, call setClientManager and setUsername.
  2. Edit mode: dialog already holds the trade_instrument from the trade bundle and pushes it via setInstrument; the form pattern-matches its family and populates fields synchronously.
  3. Create mode: clear is called and the form starts blank.
  4. The user picks a trade type → dialog calls setTradeType so the form can show or hide its options/extension sub-sections (driven by the has_options / has_extension flags on the trade_type reference data).
  5. On save: dialog calls writeUiToInstrument, then setChangeReason, then saveInstrument with success and failure callbacks. On success the dialog continues to saveTrade; on failure the trade save is aborted.

Member Function Documentation

◆ setClientManager()

virtual void setClientManager ( ClientManager cm)
pure virtual

◆ setUsername()

virtual void setUsername ( const std::string &  username)
pure virtual

◆ setImageCache()

virtual void setImageCache ( ImageCache )
virtual

◆ setInstrument()

virtual void setInstrument ( const trading::domain::trade_instrument &  instrument)
pure virtual

Populate the form with the already-resolved instrument.

The dialog holds the full trade bundle and pushes the instrument here. The form pattern-matches its family from the variant, stores the per-type domain object, and updates the UI synchronously. On success it emits instrumentLoaded and provenanceChanged. If the variant does not hold this family's alternative the form emits loadFailed with a descriptive message.

Implemented in BondInstrumentForm, CommodityInstrumentForm, CompositeInstrumentForm, CreditInstrumentForm, EquityInstrumentForm, FxAccumulatorInstrumentForm, FxAsianForwardInstrumentForm, FxBarrierOptionInstrumentForm, FxDigitalOptionInstrumentForm, FxInstrumentForm, FxVanillaOptionInstrumentForm, FxVarianceSwapInstrumentForm, ScriptedInstrumentForm, and SwapInstrumentForm.

◆ clear()

virtual void clear ( )
pure virtual

◆ setTradeType()

virtual void setTradeType ( const QString &  code,
bool  has_options,
bool  has_extension 
)
pure virtual

Inform the form which trade type is currently selected.

Parameters
codeThe trade type code (e.g. "FxOption").
has_optionsReveal the family's options sub-section.
has_extensionReveal the family's extension sub-section.

The form decides how to lay out its sub-sections based on these flags — typically by toggling the visibility of internal tabs.

Implemented in BondInstrumentForm, CommodityInstrumentForm, CompositeInstrumentForm, CreditInstrumentForm, EquityInstrumentForm, FxAccumulatorInstrumentForm, FxAsianForwardInstrumentForm, FxBarrierOptionInstrumentForm, FxDigitalOptionInstrumentForm, FxInstrumentForm, FxVanillaOptionInstrumentForm, FxVarianceSwapInstrumentForm, ScriptedInstrumentForm, and SwapInstrumentForm.

◆ setReadOnly()

virtual void setReadOnly ( bool  readOnly)
pure virtual

◆ isDirty()

virtual bool isDirty ( ) const
pure virtual

◆ isLoaded()

virtual bool isLoaded ( ) const
pure virtual

◆ setChangeReason()

virtual void setChangeReason ( const std::string &  code,
const std::string &  commentary 
)
pure virtual

Stamp the change reason on the in-flight instrument before the dialog calls saveInstrument.

The dialog gathers a single change reason once per save and applies it identically to both the trade and the instrument so that the two audit trails stay aligned.

Implemented in BondInstrumentForm, CommodityInstrumentForm, CompositeInstrumentForm, CreditInstrumentForm, EquityInstrumentForm, FxAccumulatorInstrumentForm, FxAsianForwardInstrumentForm, FxBarrierOptionInstrumentForm, FxDigitalOptionInstrumentForm, FxInstrumentForm, FxVanillaOptionInstrumentForm, FxVarianceSwapInstrumentForm, ScriptedInstrumentForm, and SwapInstrumentForm.

◆ writeUiToInstrument()

virtual void writeUiToInstrument ( )
pure virtual

◆ saveInstrument()

virtual void saveInstrument ( std::function< void(const std::string &id)>  on_success,
std::function< void(const QString &error)>  on_failure 
)
pure virtual

Save the in-flight instrument via the family's NATS request.

Parameters
on_successInvoked on the Qt thread with the saved instrument id (so the dialog can populate trade.instrument_id in create mode and continue to the trade save).
on_failureInvoked on the Qt thread with a human-readable error message; the dialog should abort the trade save and surface the error to the user.

Implemented in BondInstrumentForm, CommodityInstrumentForm, CompositeInstrumentForm, CreditInstrumentForm, EquityInstrumentForm, FxAccumulatorInstrumentForm, FxAsianForwardInstrumentForm, FxBarrierOptionInstrumentForm, FxDigitalOptionInstrumentForm, FxInstrumentForm, FxVanillaOptionInstrumentForm, FxVarianceSwapInstrumentForm, ScriptedInstrumentForm, and SwapInstrumentForm.

◆ provenanceChanged

void provenanceChanged ( const InstrumentProvenance provenance)
signal

Emitted with the latest audit metadata after load and save.

The outer dialog uses this to refresh its shared instrumentProvenanceWidget — the widget itself stays in the dialog so it remains family-agnostic.