Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/Simulation/Common/SimulatorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ public abstract class SimulatorBase : AbstractFactory<AbstractCallable>, IOperat
public event Action<string>? OnLog = null;
public event Action<Exception, IEnumerable<StackFrame>>? OnException = null;


/// <summary>
/// An event fired whenever a simulator has additional diagnostic data
/// available for display (e.g. state information, assertion details,
/// execution traces).
/// </summary>
public event Action<object>? OnDisplayableDiagnostic = null;

public IQubitManager? QubitManager { get; }

public abstract string Name { get; }
Expand Down Expand Up @@ -182,6 +190,17 @@ public void EnableExceptionPrinting()
OnException += WriteStackTraceToLog;
}

/// <summary>
/// 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.
/// </summary>
protected void MaybeDisplayDiagnostic(object data)
{
OnDisplayableDiagnostic?.Invoke(data);
}


/// <summary>
/// Disables default handling of stack traces, such that stack
Expand Down