SWMMVis  6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
ISessionEvents.hpp
Go to the documentation of this file.
1
13#pragma once
14#include <QFlags>
15#include <QList>
16#include <QMetaObject>
17#include <QMetaType>
18#include <QObject>
19#include <QString>
20#include <QUuid>
21#include <functional>
22
24#define OPENSWMM_SESSION_EVENTS_IID "io.opensimulator.openswmm.IEventSource/2.0"
25
26namespace OpenSWMM::Sdk
27{
28class IModelInstance;
29inline constexpr auto SESSION_EVENTS_IID =
31
33enum class SessionStatus : quint32 {
34 Created = 1,
35 Loading = 2,
36 Ready = 3,
37 Failed = 4,
38 Closing = 5
39};
40
42enum class StateChange : quint32 {
43 None = 0,
44 Metadata = 1,
45 Model = 2,
46 Selection = 4,
47 Viewport = 8,
48 Layers = 16,
49 Results = 32,
50 ProjectState = 64
51};
52Q_DECLARE_FLAGS(StateChanges, StateChange)
53Q_DECLARE_OPERATORS_FOR_FLAGS(StateChanges)
54
55
57 QUuid sessionId;
58 QUuid instanceId;
59 quint64 loadGeneration = 0;
60 quint64 stateRevision = 0;
61 quint64 modelRevision = 0;
63 QString title;
64 QString inputPath;
65 QString projectPath;
66 QString error;
67 bool dirty = false;
68 bool saving = false;
69};
70
77 quint64 sequence =
78 0;
79 QList<ModelSessionState> sessions;
80};
81
83enum class StateEventKind : quint32 {
84 SessionOpened = 1,
85 LoadStarted = 2,
86 ModelReady = 3,
87 LoadFailed = 4,
88 StateChanged = 5,
89 SaveStarted = 6,
90 SaveFinished = 7,
91 SessionClosing = 8,
92 SessionClosed = 9
93};
94
96enum class SaveKind : quint32 {
97 Project = 1,
98 Sidecar = 2,
99 Recovery = 3
100};
102enum class SaveOutcome : quint32 {
103 None = 0,
104 Started = 1,
105 Succeeded = 2,
106 Failed = 3
107};
108
117
131
134 QList<StateEventKind> kinds;
135 QUuid
140 bool accepts(const StateEvent &event) const
141 {
142 return (kinds.isEmpty() || kinds.contains(event.kind)) &&
143 (sessionId.isNull() || sessionId == event.session.sessionId);
144 }
145};
146
160
163{
164public:
166 virtual ~ISessionEvents() = default;
169 virtual StateSnapshot stateSnapshot() const = 0;
174 virtual IModelInstance *resolveSession(const QUuid &sessionId) const = 0;
183 virtual QMetaObject::Connection
184 observeState(QObject *context, const StateEventFilter &filter,
185 std::function<void(const StateEvent &)> callback) = 0;
192 virtual QMetaObject::Connection
193 observeBeforeSave(QObject *context, std::function<void(const SaveRequest &)> callback) = 0;
194};
195}
197Q_DECLARE_METATYPE(OpenSWMM::Sdk::ModelSessionState)
198Q_DECLARE_METATYPE(OpenSWMM::Sdk::StateSnapshot)
199Q_DECLARE_METATYPE(OpenSWMM::Sdk::StateEvent)
200Q_DECLARE_METATYPE(OpenSWMM::Sdk::StateEventKind)
201Q_DECLARE_METATYPE(OpenSWMM::Sdk::StateChanges)
202Q_DECLARE_METATYPE(OpenSWMM::Sdk::SaveRequest)
#define OPENSWMM_SESSION_EVENTS_IID
Frozen Qt discovery identity for authoritative lifecycle observations.
Definition ISessionEvents.hpp:24
Definition IModelInstance.hpp:25
Frozen optional access to session snapshots and authoritative lifecycle observations.
Definition ISessionEvents.hpp:163
virtual StateSnapshot stateSnapshot() const =0
Copy live session metadata without creating facades or publishing events.
virtual QMetaObject::Connection observeBeforeSave(QObject *context, std::function< void(const SaveRequest &)> callback)=0
Register a short synchronous pre-save state collector.
virtual IModelInstance * resolveSession(const QUuid &sessionId) const =0
Resolve exactly one ready, current open lifetime.
virtual ~ISessionEvents()=default
Destroy an implementation; callers borrow the host-owned capability.
virtual QMetaObject::Connection observeState(QObject *context, const StateEventFilter &filter, std::function< void(const StateEvent &)> callback)=0
Observe future queued state transitions with GUI-thread lifetime guards.
QPointer< QObject > context
Required provider lifetime guard.
Definition extensionattributes.cpp:31
Public header-only ABI for independently compiled native GUI extensions.
Definition ExtensionHost.hpp:24
StateChange
Broad invalidations of queryable state, without claiming changed-field deltas.
Definition ISessionEvents.hpp:42
@ ProjectState
Project-owned extension/presentation state changed.
@ None
No additional invalidation category.
@ Selection
Shared model selection changed.
@ Layers
Canvas layer membership changed.
@ Viewport
Visible area or canvas CRS changed.
@ Metadata
Identity, title, path or dirty metadata changed.
@ Results
Active result source changed.
SaveOutcome
Outcome state of a correlated save operation.
Definition ISessionEvents.hpp:102
@ None
This event does not describe a save.
@ Started
Save preparation/state collection has begun.
@ Succeeded
Settled successfully; a late cancel cannot change this outcome.
@ Failed
Settled with an explicit worker/preparation error.
SaveKind
Meaning of a persisted save destination.
Definition ISessionEvents.hpp:96
@ Project
Normal model/project save transaction.
@ Recovery
Independent recovery snapshot/project write.
@ Sidecar
Standalone project-sidecar write.
SessionStatus
Current availability of an open model-window session.
Definition ISessionEvents.hpp:33
@ Created
Window exists, with no completed load attempt.
@ Loading
A particular load generation is being prepared/restored.
@ Closing
Close committed; resolution must not return an actionable model.
@ Ready
Native readiness barrier completed for the current generation.
constexpr auto SESSION_EVENTS_IID
Public alias for the frozen discovery identity.
Definition ISessionEvents.hpp:29
@ Model
Native model document with a per-open session identity.
StateEventKind
Lifecycle or save transition recorded by the shared application registry.
Definition ISessionEvents.hpp:83
@ SaveFinished
Save transaction succeeded or failed.
@ SaveStarted
Informational queued save start; state collection uses a separate hook.
@ LoadFailed
The generation ended without becoming ready.
@ SessionClosed
Session was removed from live state before this record was published.
@ StateChanged
Broad queryable-state invalidation with merged categories.
@ SessionClosing
Close committed and resolution is unavailable.
@ LoadStarted
A new accepted load generation started.
@ SessionOpened
An open lifetime was registered.
@ ModelReady
The generation's native readiness barrier completed.
Owning metadata for one open lifetime, distinct from its persistent project identity.
Definition ISessionEvents.hpp:56
QUuid sessionId
Unique per-window open lifetime; never reused on reopen.
Definition ISessionEvents.hpp:57
QString inputPath
Current model path, possibly empty for an unsaved model.
Definition ISessionEvents.hpp:64
QString error
Current load failure detail; empty after a successful load.
Definition ISessionEvents.hpp:66
QString projectPath
Current/inferred project sidecar path.
Definition ISessionEvents.hpp:65
QString title
Copied model-window caption.
Definition ISessionEvents.hpp:63
QUuid instanceId
Persistent model UUID; multiple sessions may share this value.
Definition ISessionEvents.hpp:58
Synchronous, non-vetoing opportunity to collect state before a save writes.
Definition ISessionEvents.hpp:151
QString targetPath
Outer destination, possibly empty until a recovery snapshot path is selected.
Definition ISessionEvents.hpp:158
QUuid instanceId
Persistent model UUID at collection time.
Definition ISessionEvents.hpp:154
QUuid operationId
Correlated outer save transaction.
Definition ISessionEvents.hpp:152
quint64 loadGeneration
Generation whose state is being collected.
Definition ISessionEvents.hpp:155
SaveKind kind
Outer save category.
Definition ISessionEvents.hpp:156
QUuid sessionId
Affected open lifetime.
Definition ISessionEvents.hpp:153
Copied outcome and destination for one uniquely identified save operation.
Definition ISessionEvents.hpp:110
SaveOutcome outcome
Current operation outcome.
Definition ISessionEvents.hpp:113
SaveKind kind
Outer transaction's save category.
Definition ISessionEvents.hpp:112
QString targetPath
Outer final destination; recovery starts may precede its selection.
Definition ISessionEvents.hpp:114
QString error
Failure detail, empty on success.
Definition ISessionEvents.hpp:115
QUuid operationId
Correlation UUID shared by start/finish and nested save scopes.
Definition ISessionEvents.hpp:111
Copied selection of lifecycle kinds and optionally one open lifetime.
Definition ISessionEvents.hpp:133
QList< StateEventKind > kinds
Empty selects every lifecycle kind.
Definition ISessionEvents.hpp:134
QUuid sessionId
Null selects all sessions; persistent instance IDs are not session filters.
Definition ISessionEvents.hpp:136
bool accepts(const StateEvent &event) const
Match a transition without querying mutable host state.
Definition ISessionEvents.hpp:140
Immutable transition record delivered later on the GUI thread.
Definition ISessionEvents.hpp:124
StateEventKind kind
Transition reason.
Definition ISessionEvents.hpp:125
SaveState save
Save detail for SaveStarted/SaveFinished, otherwise outcome None.
Definition ISessionEvents.hpp:129
quint64 sequence
Shared registry publication identity/watermark.
Definition ISessionEvents.hpp:126
ModelSessionState session
Copied affected session state.
Definition ISessionEvents.hpp:127
StateChanges changes
Broad categories for StateChanged; no field/object delta is implied.
Definition ISessionEvents.hpp:128
Atomic GUI-thread copy of live session metadata and its event watermark.
Definition ISessionEvents.hpp:76
QList< ModelSessionState > sessions
Live Created/Loading/Ready/Failed/Closing sessions.
Definition ISessionEvents.hpp:79
quint64 sequence
Registry-wide committed-publication watermark, not IModelEvents' host sequence.
Definition ISessionEvents.hpp:77