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
openswmmvis::timeseries::TimeseriesRegistry Class Reference

#include <timeseriesregistry.h>

Inheritance diagram for openswmmvis::timeseries::TimeseriesRegistry:
Collaboration diagram for openswmmvis::timeseries::TimeseriesRegistry:

Signals

void simulationStartChanged (const QDateTime &now)
 The cached simulation start date/time changed.
 
void providerAdded (openswmmvis::timeseries::TimeseriesProvider *provider)
 A provider was created and added to the registry.
 
void providerAboutToBeRemoved (openswmmvis::timeseries::TimeseriesProvider *provider)
 A provider is about to be removed. Subscribers must drop refs.
 
void providerRenamed (openswmmvis::timeseries::TimeseriesProvider *provider, const QString &prevName, const QString &newName)
 A provider's name changed.
 

Public Member Functions

 TimeseriesRegistry (QObject *parent=nullptr)
 
 ~TimeseriesRegistry () override
 
QVector< TimeseriesProvider * > providers () const
 All providers in insertion order.
 
int providerCount () const noexcept
 
TimeseriesProviderfindByName (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).
 
TimeseriesProvidercreate (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)
 

Constructor & Destructor Documentation

◆ TimeseriesRegistry()

openswmmvis::timeseries::TimeseriesRegistry::TimeseriesRegistry ( QObject *  parent = nullptr)
explicit

◆ ~TimeseriesRegistry()

openswmmvis::timeseries::TimeseriesRegistry::~TimeseriesRegistry ( )
overridedefault

Member Function Documentation

◆ create()

TimeseriesProvider * openswmmvis::timeseries::TimeseriesRegistry::create ( const QString &  name)

Create + own a new provider with the given name.

Returns
the new provider, or nullptr if the name is already in use.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ engineHandle()

void * openswmmvis::timeseries::TimeseriesRegistry::engineHandle ( ) const
inlinenoexcept

The engine handle currently bound to this registry (the one loadFromEngine / saveToEngine last operated on), or nullptr if none.

Here is the caller graph for this function:

◆ findByName()

TimeseriesProvider * openswmmvis::timeseries::TimeseriesRegistry::findByName ( const QString &  name) const

Find by exact name (case-insensitive). Returns nullptr if absent.

Here is the caller graph for this function:

◆ hasName()

bool openswmmvis::timeseries::TimeseriesRegistry::hasName ( const QString &  name) const
inline

True iff a provider with this name exists (case-insensitive).

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadFromEngine()

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
engineHandleOpaque 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.
Here is the call graph for this function:

◆ projectAnchor()

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.

◆ providerAboutToBeRemoved

void openswmmvis::timeseries::TimeseriesRegistry::providerAboutToBeRemoved ( openswmmvis::timeseries::TimeseriesProvider provider)
signal

A provider is about to be removed. Subscribers must drop refs.

Here is the caller graph for this function:

◆ providerAdded

void openswmmvis::timeseries::TimeseriesRegistry::providerAdded ( openswmmvis::timeseries::TimeseriesProvider provider)
signal

A provider was created and added to the registry.

Here is the caller graph for this function:

◆ providerCount()

int openswmmvis::timeseries::TimeseriesRegistry::providerCount ( ) const
inlinenoexcept

◆ providerRenamed

void openswmmvis::timeseries::TimeseriesRegistry::providerRenamed ( openswmmvis::timeseries::TimeseriesProvider provider,
const QString &  prevName,
const QString &  newName 
)
signal

A provider's name changed.

Here is the caller graph for this function:

◆ providers()

QVector< TimeseriesProvider * > openswmmvis::timeseries::TimeseriesRegistry::providers ( ) const
inline

All providers in insertion order.

◆ remove()

void openswmmvis::timeseries::TimeseriesRegistry::remove ( TimeseriesProvider p)

Remove + delete a provider. Safe to call with a stale pointer (no-op if not owned by this registry).

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rename()

bool openswmmvis::timeseries::TimeseriesRegistry::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.

Here is the call graph for this function:

◆ saveToEngine() [1/2]

int openswmmvis::timeseries::TimeseriesRegistry::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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ saveToEngine() [2/2]

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setProjectAnchor()

void openswmmvis::timeseries::TimeseriesRegistry::setProjectAnchor ( const QString &  dir)
inline

◆ setSimulationStart()

void openswmmvis::timeseries::TimeseriesRegistry::setSimulationStart ( const QDateTime &  start)
inline
Here is the call graph for this function:

◆ simulationStart()

QDateTime openswmmvis::timeseries::TimeseriesRegistry::simulationStart ( ) const
inline

Simulation start (START_DATE + START_TIME), the anchor for Relative-mode series and the seed time for a new series' first point.

Lives on the registry for the same reason projectAnchor does: every timeseries dialog already receives the registry. Seeded (and re-seeded) by SWMMModelLayer::ensureTimeseriesRegistry(), which also forwards START_DATE / START_TIME option edits. Invalid = unknown.

◆ simulationStartChanged

void openswmmvis::timeseries::TimeseriesRegistry::simulationStartChanged ( const QDateTime &  now)
signal

The cached simulation start date/time changed.

Here is the caller graph for this function:

The documentation for this class was generated from the following files: