|
| | TimeseriesRegistry (QObject *parent=nullptr) |
| |
| | ~TimeseriesRegistry () override |
| |
| QVector< TimeseriesProvider * > | providers () const |
| | All providers in insertion order.
|
| |
| int | providerCount () const noexcept |
| |
| TimeseriesProvider * | findByName (const QString &name) const |
| | Find by exact name (case-insensitive). Returns nullptr if absent.
|
| |
| bool | hasName (const QString &name) const |
| | True iff a provider with this name exists (case-insensitive).
|
| |
| TimeseriesProvider * | create (const QString &name) |
| | Create + own a new provider with the given name.
|
| |
| void | remove (TimeseriesProvider *p) |
| | Remove + delete a provider. Safe to call with a stale pointer (no-op if not owned by this registry).
|
| |
| bool | rename (TimeseriesProvider *p, const QString &newName) |
| | Rename a provider. Performs the uniqueness check; returns false (and emits no signal) if newName collides with a different existing provider. Same provider with same name is a no-op success.
|
| |
| int | loadFromEngine (void *engineHandle) |
| | Populate the registry from a live SWMM engine handle. Walks swmm_table_*, filters to TIMESERIES tables (type code 0), and creates one TimeseriesProvider per entry — loading all points via setAllPoints (so the monotone-time invariant gets validated up-front).
|
| |
| int | saveToEngine (void *engineHandle) |
| | Push every Inline-mode and file-backed provider to the engine.
|
| |
| int | saveToEngine () |
| | Convenience overload — flush to the cached engine handle set by the most recent loadFromEngine / saveToEngine(handle) call. No-op (returns 0) if no handle has been bound yet. Used by auto-flush hooks (e.g. closing the TimeseriesEditorDialog) so the caller doesn't need to re-thread the engine pointer through the UI.
|
| |
| void * | engineHandle () const noexcept |
| | The engine handle currently bound to this registry (the one loadFromEngine / saveToEngine last operated on), or nullptr if none.
|
| |
| QString | projectAnchor () const |
| | Directory of the project's .inp, used to DISPLAY file-backed series paths relatively (TimeseriesEditorDialog::setProjectAnchor).
|
| |
| void | setProjectAnchor (const QString &dir) |
| |
| QDateTime | simulationStart () const |
| | Simulation start (START_DATE + START_TIME), the anchor for Relative-mode series and the seed time for a new series' first point.
|
| |
| void | setSimulationStart (const QDateTime &start) |
| |
| int openswmmvis::timeseries::TimeseriesRegistry::loadFromEngine |
( |
void * |
engineHandle | ) |
|
Populate the registry from a live SWMM engine handle. Walks swmm_table_*, filters to TIMESERIES tables (type code 0), and creates one TimeseriesProvider per entry — loading all points via setAllPoints (so the monotone-time invariant gets validated up-front).
FILE-backed series (a non-empty TIMESERIES_DATA file-path slot, token "path[:column]") become ExternalFile-mode providers with the column selector split out (drive-letter-aware, mirroring the engine); their loaded points are the engine's resolved cache for that column.
Pre-existing providers are NOT cleared; conflicts (duplicate name) are skipped silently. Caller should typically construct the registry empty and call this once on project open.
- Parameters
-
| engineHandle | Opaque pointer to a SWMM_Engine. Passed as void* so this header stays free of the engine C header (which conflicts with Qt MOC under -Wstrict-bool). |
- Returns
- the number of providers added.
| QString openswmmvis::timeseries::TimeseriesRegistry::projectAnchor |
( |
| ) |
const |
|
inline |
Directory of the project's .inp, used to DISPLAY file-backed series paths relatively (TimeseriesEditorDialog::setProjectAnchor).
Lives on the registry rather than being threaded through each dialog because every timeseries dialog already receives the registry, while the six construction sites have no common owner. Display only — the provider still owns the absolute path, and the engine's InpWriter is what rebases the token on save. Empty = show absolute paths.
| int openswmmvis::timeseries::TimeseriesRegistry::saveToEngine |
( |
void * |
engineHandle | ) |
|
Push every Inline-mode and file-backed provider to the engine.
For each Inline provider:
- If
swmm_table_index(eng, name) finds an existing engine entry, swmm_table_clear it and re-add every point (also clearing any stale FILE token, so a series Detached to Inline round-trips).
- Otherwise call
swmm_timeseries_add to create it, then add points.
ExternalFile providers with a linked path persist as engine FILE timeseries: the composed "path:col" token is written to the TIMESERIES_DATA file-path slot (B4), so the .inp emits name FILE "path:col" and dependents referencing the series by name resolve to that file column. An unchanged reference is left verbatim (a relative token stays relative). Pathless ExternalFile and GeopackageObserved providers are still skipped.
- Returns
- the number of providers written.
Caller is responsible for engine state — the engine must be in SWMM_STATE_BUILDING for new-timeseries creation; swmm_table_clear
swmm_table_add_point work in BUILDING and OPENED.
Side effect: caches engineHandle as the registry's bound engine so the no-arg saveToEngine() overload can flush without re-passing it.