diff --git a/src/Simulation/Common/SimulatorBase.cs b/src/Simulation/Common/SimulatorBase.cs index 1440e2112db..41f566ea641 100644 --- a/src/Simulation/Common/SimulatorBase.cs +++ b/src/Simulation/Common/SimulatorBase.cs @@ -31,6 +31,14 @@ public abstract class SimulatorBase : AbstractFactory, IOperat public event Action? OnLog = null; public event Action>? OnException = null; + + /// + /// An event fired whenever a simulator has additional diagnostic data + /// available for display (e.g. state information, assertion details, + /// execution traces). + /// + public event Action? OnDisplayableDiagnostic = null; + public IQubitManager? QubitManager { get; } public abstract string Name { get; } @@ -182,6 +190,17 @@ public void EnableExceptionPrinting() OnException += WriteStackTraceToLog; } + /// + /// Sends diagnostic data to any listening display handlers. + /// Display handlers may discard any unrecognized data, such that + /// no guarantee is made as to any particular action taken as a result + /// of calling this method. + /// + protected void MaybeDisplayDiagnostic(object data) + { + OnDisplayableDiagnostic?.Invoke(data); + } + /// /// Disables default handling of stack traces, such that stack