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
timeseriesregistry.h
Go to the documentation of this file.
1
21#ifndef OPENSWMMVIS_TIMESERIES_TIMESERIESREGISTRY_H
22#define OPENSWMMVIS_TIMESERIES_TIMESERIESREGISTRY_H
23
24#include <QDateTime>
25#include <QHash>
26#include <QObject>
27#include <QString>
28#include <QVector>
29
31
32class TimeseriesProvider;
33
34class TimeseriesRegistry : public QObject
35{
36 Q_OBJECT
37
38public:
39 explicit TimeseriesRegistry(QObject *parent = nullptr);
41
42 // ── Lookup ──────────────────────────────────────────────────────────────
43
45 QVector<TimeseriesProvider *> providers() const { return m_providers; }
46
47 int providerCount() const noexcept { return m_providers.size(); }
48
50 TimeseriesProvider *findByName(const QString& name) const;
51
53 bool hasName(const QString& name) const { return findByName(name) != nullptr; }
54
55 // ── Mutation ────────────────────────────────────────────────────────────
56
59 TimeseriesProvider *create(const QString& name);
60
64
68 bool rename(TimeseriesProvider *p, const QString& newName);
69
70 // ── Engine I/O (Phase 6.7.3.8 — minimum load path) ─────────────────────
71
92
118 int saveToEngine(void *engineHandle);
119
125 int saveToEngine();
126
129 void *engineHandle() const noexcept { return m_engineHandle; }
130
140 QString projectAnchor() const { return m_projectAnchor; }
141 void setProjectAnchor(const QString &dir) { m_projectAnchor = dir; }
142
150 QDateTime simulationStart() const { return m_simulationStart; }
151 void setSimulationStart(const QDateTime &start)
152 {
153 if (start == m_simulationStart) return;
154 m_simulationStart = start;
155 emit simulationStartChanged(m_simulationStart);
156 }
157
158signals:
160 void simulationStartChanged(const QDateTime &now);
161
164
167
170 const QString& prevName, const QString& newName);
171
172private:
173 QVector<TimeseriesProvider *> m_providers;
174 QHash<QString, TimeseriesProvider *> m_byLowerName;
175 void *m_engineHandle = nullptr;
176 QString m_projectAnchor;
177 QDateTime m_simulationStart;
178
179 void onProviderRenamed_(const QString& prev, const QString& now);
180};
181
182} // namespace openswmmvis::timeseries
183
184#endif // OPENSWMMVIS_TIMESERIES_TIMESERIESREGISTRY_H
Definition timeseriesprovider.h:43
Definition timeseriesregistry.h:35
QDateTime simulationStart() const
Simulation start (START_DATE + START_TIME), the anchor for Relative-mode series and the seed time for...
Definition timeseriesregistry.h:150
bool rename(TimeseriesProvider *p, const QString &newName)
Rename a provider. Performs the uniqueness check; returns false (and emits no signal) if newName coll...
Definition timeseriesregistry.cpp:87
TimeseriesProvider * create(const QString &name)
Create + own a new provider with the given name.
Definition timeseriesregistry.cpp:43
void setSimulationStart(const QDateTime &start)
Definition timeseriesregistry.h:151
void providerRenamed(openswmmvis::timeseries::TimeseriesProvider *provider, const QString &prevName, const QString &newName)
A provider's name changed.
void simulationStartChanged(const QDateTime &now)
The cached simulation start date/time changed.
void setProjectAnchor(const QString &dir)
Definition timeseriesregistry.h:141
bool hasName(const QString &name) const
True iff a provider with this name exists (case-insensitive).
Definition timeseriesregistry.h:53
void remove(TimeseriesProvider *p)
Remove + delete a provider. Safe to call with a stale pointer (no-op if not owned by this registry).
Definition timeseriesregistry.cpp:65
void providerAdded(openswmmvis::timeseries::TimeseriesProvider *provider)
A provider was created and added to the registry.
TimeseriesProvider * findByName(const QString &name) const
Find by exact name (case-insensitive). Returns nullptr if absent.
Definition timeseriesregistry.cpp:38
QString projectAnchor() const
Directory of the project's .inp, used to DISPLAY file-backed series paths relatively (TimeseriesEdito...
Definition timeseriesregistry.h:140
void providerAboutToBeRemoved(openswmmvis::timeseries::TimeseriesProvider *provider)
A provider is about to be removed. Subscribers must drop refs.
int saveToEngine()
Convenience overload — flush to the cached engine handle set by the most recent loadFromEngine / save...
Definition timeseriesregistry.cpp:187
QVector< TimeseriesProvider * > providers() const
All providers in insertion order.
Definition timeseriesregistry.h:45
void * engineHandle() const noexcept
The engine handle currently bound to this registry (the one loadFromEngine / saveToEngine last operat...
Definition timeseriesregistry.h:129
int loadFromEngine(void *engineHandle)
Populate the registry from a live SWMM engine handle. Walks swmm_table_*, filters to TIMESERIES table...
Definition timeseriesregistry.cpp:101
int providerCount() const noexcept
Definition timeseriesregistry.h:47
ArrowPlacement p
Definition linesymbollayer.cpp:27
std::vector< int > start
size = pixels + 1
Definition mesh2dresultsexport.cpp:608
Definition timeseriesprovider.h:34
QVector< int > parent
union-find
Definition pslgminsize.cpp:176
QString name
Definition sectionmodelbuilders.cpp:474