OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
openswmm_model.h
Go to the documentation of this file.
1
23#ifndef OPENSWMM_MODEL_H
24#define OPENSWMM_MODEL_H
25
26#include "openswmm_engine.h"
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32/* =========================================================================
33 * Model building — programmatic construction (state guard: BUILDING only)
34 * ========================================================================= */
35
47
48/* =========================================================================
49 * Model finalisation and validation
50 * ========================================================================= */
51
63
76
77/* =========================================================================
78 * Model serialisation
79 * ========================================================================= */
80
93SWMM_ENGINE_API int swmm_model_write(SWMM_Engine engine, const char* new_inp_path);
94
136 const char* new_path,
137 const char* output_plugin_id);
138
139/* =========================================================================
140 * [PLUGINS] section access (Slice AA-3.1 Phase B)
141 *
142 * The [PLUGINS] section of an .inp file is a list of rows, one per
143 * plugin to load. Each row is `path arg1 arg2 …` where `path` resolves
144 * via the same logic as the input plugin lib (a library path, an id, or
145 * an `id:version` pair) and the trailing tokens are passed to the
146 * plugin's initialize() method as `init_args`.
147 *
148 * The accessors below let a host (GUI) read, mutate, and remove rows
149 * without re-parsing the .inp file. Plugins themselves are
150 * (re-)resolved by PluginFactory at swmm_engine_open / swmm_model_write
151 * time — these accessors only mutate the in-memory `plugin_specs` list.
152 * ========================================================================= */
153
158SWMM_ENGINE_API int swmm_plugins_count(SWMM_Engine engine, int* count);
159
179 int idx,
180 char* path_buf,
181 int path_buf_sz,
182 char* args_buf,
183 int args_buf_sz);
184
202 const char* path_or_id,
203 const char* args);
204
215swmm_plugin_remove(SWMM_Engine engine, const char* path_or_id);
216
217/* =========================================================================
218 * [FILES] section access (Slice AA-3 follow-up — secondary file refs)
219 *
220 * Read / write the legacy SWMM5 `[FILES]` section: rainfall, runoff,
221 * RDII, inflows, outflows, and hot-start file references. The
222 * accessors are keyed by an uppercase string so callers don't depend
223 * on the field layout of `FilesSpec`.
224 *
225 * Recognised keys (case-insensitive):
226 * "RAINFALL_PATH" / "RAINFALL_MODE"
227 * "RUNOFF_PATH" / "RUNOFF_MODE"
228 * "RDII_PATH" / "RDII_MODE"
229 * "INFLOWS_PATH"
230 * "OUTFLOWS_PATH"
231 * "HOTSTART_USE_PATH"
232 * "HOTSTART_SAVE_PATH" / "HOTSTART_SAVE_DATETIME"
233 *
234 * `*_MODE` keys take "SAVE" / "USE" / "" (empty clears the slot).
235 * `HOTSTART_SAVE_DATETIME` is a SWMM decimal-day floating-point string
236 * (0 == unset, write at end of run).
237 * ========================================================================= */
238
252swmm_files_get(SWMM_Engine engine, const char* key, char* buf, int buflen);
253
267swmm_files_set(SWMM_Engine engine, const char* key, const char* value);
268
269/* =========================================================================
270 * Title / notes access
271 * ========================================================================= */
272
280SWMM_ENGINE_API int swmm_title_get_count(SWMM_Engine engine, int* count);
281
292 SWMM_Engine engine,
293 int index,
294 char* buf,
295 int buflen
296);
297
305SWMM_ENGINE_API int swmm_title_add_line(SWMM_Engine engine, const char* line);
306
317SWMM_ENGINE_API int swmm_title_set(SWMM_Engine engine, const char* text);
318
326
327/* =========================================================================
328 * OPTIONS access
329 * ========================================================================= */
330
347 SWMM_Engine engine,
348 const char* key,
349 char* buf,
350 int buflen
351);
352
362 SWMM_Engine engine,
363 const char* key,
364 const char* value
365);
366
377 SWMM_Engine engine,
378 const char* key,
379 char* buf,
380 int buflen
381);
382
392 SWMM_Engine engine,
393 const char* key,
394 const char* value
395);
396
405SWMM_ENGINE_API int swmm_get_crs(SWMM_Engine engine, char* buf, int buflen);
406
407/* =========================================================================
408 * Typed time-control accessors
409 *
410 * Date values are SWMM OADate doubles: the integer part is days since
411 * 1899-12-30 and the fractional part is the time-of-day fraction.
412 * ========================================================================= */
413
421
429
436SWMM_ENGINE_API int swmm_options_get_end_date(SWMM_Engine engine, double* value);
437
445
453
461
462/* =========================================================================
463 * User flags
464 * ========================================================================= */
465
473SWMM_ENGINE_API int swmm_userflag_get_bool(SWMM_Engine engine, const char* name, int* value);
474
482SWMM_ENGINE_API int swmm_userflag_get_int (SWMM_Engine engine, const char* name, int* value);
483
491SWMM_ENGINE_API int swmm_userflag_get_real(SWMM_Engine engine, const char* name, double* value);
492
494SWMM_ENGINE_API int swmm_userflag_set_bool(SWMM_Engine engine, const char* name, int value);
495
497SWMM_ENGINE_API int swmm_userflag_set_int (SWMM_Engine engine, const char* name, int value);
498
500SWMM_ENGINE_API int swmm_userflag_set_real(SWMM_Engine engine, const char* name, double value);
501
502#ifdef __cplusplus
503} /* extern "C" */
504#endif
505
506#endif /* OPENSWMM_MODEL_H */
#define SWMM_ENGINE_API
Definition openswmm_2d.h:37
void * SWMM_Engine
Opaque handle to an OpenSWMM Engine instance.
Definition openswmm_callbacks.h:35
OpenSWMM Engine — primary transparent C API (master header).
SWMM_ENGINE_API int swmm_model_write(SWMM_Engine engine, const char *new_inp_path)
Write the current model state to a SWMM input (.inp) file.
Definition openswmm_model_impl.cpp:179
SWMM_ENGINE_API int swmm_options_set_start_date(SWMM_Engine engine, double value)
Set the simulation start date/time from an OADate.
Definition openswmm_model_impl.cpp:1077
SWMM_ENGINE_API int swmm_options_set_end_date(SWMM_Engine engine, double value)
Set the simulation end date/time from an OADate.
Definition openswmm_model_impl.cpp:1090
SWMM_ENGINE_API int swmm_userflag_get_bool(SWMM_Engine engine, const char *name, int *value)
Get the value of a BOOLEAN user flag (schema-level).
Definition openswmm_model_impl.cpp:1113
SWMM_ENGINE_API int swmm_title_set(SWMM_Engine engine, const char *text)
Replace all title/note lines with a single block of text.
Definition openswmm_model_impl.cpp:496
SWMM_ENGINE_API SWMM_Engine swmm_engine_new(void)
Create an empty engine in BUILDING state (no .inp file required).
Definition openswmm_model_impl.cpp:94
SWMM_ENGINE_API int swmm_finalize_model(SWMM_Engine engine)
Finalise a programmatically-built model.
Definition openswmm_model_impl.cpp:138
SWMM_ENGINE_API int swmm_options_set_report_start(SWMM_Engine engine, double value)
Set the report start date/time from an OADate.
Definition openswmm_model_impl.cpp:1103
SWMM_ENGINE_API int swmm_plugins_count(SWMM_Engine engine, int *count)
Number of [PLUGINS] entries currently registered on the engine.
Definition openswmm_model_impl.cpp:227
SWMM_ENGINE_API int swmm_plugin_set(SWMM_Engine engine, const char *path_or_id, const char *args)
Add or replace a [PLUGINS] row keyed by path_or_id.
Definition openswmm_model_impl.cpp:250
SWMM_ENGINE_API int swmm_options_set_ext(SWMM_Engine engine, const char *key, const char *value)
Set (or create) an extension OPTIONS value.
Definition openswmm_model_impl.cpp:1048
SWMM_ENGINE_API int swmm_options_get_ext(SWMM_Engine engine, const char *key, char *buf, int buflen)
Retrieve an extension OPTIONS value (keys unknown to standard SWMM).
Definition openswmm_model_impl.cpp:1034
SWMM_ENGINE_API int swmm_title_clear(SWMM_Engine engine)
Remove all lines from the [TITLE] section.
Definition openswmm_model_impl.cpp:515
SWMM_ENGINE_API int swmm_userflag_set_int(SWMM_Engine engine, const char *name, int value)
Set an INTEGER user flag at runtime.
Definition openswmm_model_impl.cpp:1164
SWMM_ENGINE_API int swmm_userflag_get_int(SWMM_Engine engine, const char *name, int *value)
Get the value of an INTEGER user flag.
Definition openswmm_model_impl.cpp:1127
SWMM_ENGINE_API int swmm_userflag_set_real(SWMM_Engine engine, const char *name, double value)
Set a REAL user flag at runtime.
Definition openswmm_model_impl.cpp:1173
SWMM_ENGINE_API int swmm_options_set(SWMM_Engine engine, const char *key, const char *value)
Set a standard OPTIONS value.
Definition openswmm_model_impl.cpp:761
SWMM_ENGINE_API int swmm_get_crs(SWMM_Engine engine, char *buf, int buflen)
Retrieve the CRS string (e.g., "EPSG:4326" or PROJ string).
Definition openswmm_model_impl.cpp:1056
SWMM_ENGINE_API int swmm_title_add_line(SWMM_Engine engine, const char *line)
Add a new line to the end of the [TITLE] section.
Definition openswmm_model_impl.cpp:489
SWMM_ENGINE_API int swmm_options_get_report_start(SWMM_Engine engine, double *value)
Retrieve the report start date/time as an OADate.
Definition openswmm_model_impl.cpp:1096
SWMM_ENGINE_API int swmm_files_get(SWMM_Engine engine, const char *key, char *buf, int buflen)
Read one [FILES] field by key.
Definition openswmm_model_impl.cpp:290
SWMM_ENGINE_API int swmm_files_set(SWMM_Engine engine, const char *key, const char *value)
Write one [FILES] field by key.
Definition openswmm_model_impl.cpp:323
SWMM_ENGINE_API int swmm_options_get_end_date(SWMM_Engine engine, double *value)
Retrieve the simulation end date/time as an OADate.
Definition openswmm_model_impl.cpp:1083
SWMM_ENGINE_API int swmm_plugin_get(SWMM_Engine engine, int idx, char *path_buf, int path_buf_sz, char *args_buf, int args_buf_sz)
Read one [PLUGINS] row by index.
Definition openswmm_model_impl.cpp:234
SWMM_ENGINE_API int swmm_validate_model(SWMM_Engine engine)
Validate model topology without changing state.
Definition openswmm_model_impl.cpp:104
SWMM_ENGINE_API int swmm_options_get_start_date(SWMM_Engine engine, double *value)
Retrieve the simulation start date/time as an OADate.
Definition openswmm_model_impl.cpp:1070
SWMM_ENGINE_API int swmm_userflag_get_real(SWMM_Engine engine, const char *name, double *value)
Get the value of a REAL user flag.
Definition openswmm_model_impl.cpp:1141
SWMM_ENGINE_API int swmm_model_write_with_plugin(SWMM_Engine engine, const char *new_path, const char *output_plugin_id)
Write the current model state via a named writer plugin.
Definition openswmm_model_impl.cpp:185
SWMM_ENGINE_API int swmm_plugin_remove(SWMM_Engine engine, const char *path_or_id)
Remove the [PLUGINS] row matching path_or_id.
Definition openswmm_model_impl.cpp:274
SWMM_ENGINE_API int swmm_title_get_line(SWMM_Engine engine, int index, char *buf, int buflen)
Get a specific title/note line by index.
Definition openswmm_model_impl.cpp:476
SWMM_ENGINE_API int swmm_title_get_count(SWMM_Engine engine, int *count)
Get the number of title/note lines in the [TITLE] section.
Definition openswmm_model_impl.cpp:469
SWMM_ENGINE_API int swmm_userflag_set_bool(SWMM_Engine engine, const char *name, int value)
Set a BOOLEAN user flag at runtime.
Definition openswmm_model_impl.cpp:1155
SWMM_ENGINE_API int swmm_options_get(SWMM_Engine engine, const char *key, char *buf, int buflen)
Retrieve a standard OPTIONS value as a string.
Definition openswmm_model_impl.cpp:525