OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmm_tables.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2//
3// Copyright 2026 Caleb Buahin
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
31
32#ifndef OPENSWMM_TABLES_H
33#define OPENSWMM_TABLES_H
34
35#include "openswmm_engine.h"
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41/* =========================================================================
42 * Identity
43 * ========================================================================= */
44
51
62SWMM_ENGINE_API int swmm_table_index(SWMM_Engine engine, const char* id);
63
74SWMM_ENGINE_API const char* swmm_table_id(SWMM_Engine engine, int idx);
75
101SWMM_ENGINE_API int swmm_table_get_type(SWMM_Engine engine, int idx, int* type);
102
103/* =========================================================================
104 * Creation (BUILDING or OPENED — references resolve by name at initialize())
105 * ========================================================================= */
106
118SWMM_ENGINE_API int swmm_timeseries_add(SWMM_Engine engine, const char* id);
119
139SWMM_ENGINE_API int swmm_curve_add(SWMM_Engine engine, const char* id, int type);
140
141/* =========================================================================
142 * Data points
143 * ========================================================================= */
144
164SWMM_ENGINE_API int swmm_table_add_point(SWMM_Engine engine, int idx, double x, double y);
165
177SWMM_ENGINE_API int swmm_table_get_point_count(SWMM_Engine engine, int idx, int* count);
178
193SWMM_ENGINE_API int swmm_table_get_point(SWMM_Engine engine, int idx, int pt_idx, double* x,
194 double* y);
195
207SWMM_ENGINE_API int swmm_table_clear(SWMM_Engine engine, int idx);
208
233SWMM_ENGINE_API int swmm_timeseries_get_relative_info(SWMM_Engine engine, int idx, int* n_relative,
234 double* anchor);
235
259SWMM_ENGINE_API int swmm_timeseries_set_relative_info(SWMM_Engine engine, int idx, int n_relative,
260 double anchor);
261
262/* =========================================================================
263 * Lookup (cursor-optimized)
264 * ========================================================================= */
265
285SWMM_ENGINE_API int swmm_table_lookup(SWMM_Engine engine, int idx, double x, double* y);
286
287/* =========================================================================
288 * Patterns
289 * ========================================================================= */
290
307SWMM_ENGINE_API int swmm_pattern_add(SWMM_Engine engine, const char* id, int type);
308
324SWMM_ENGINE_API int swmm_pattern_set_factors(SWMM_Engine engine, int idx, const double* factors,
325 int count);
326
333
343SWMM_ENGINE_API int swmm_pattern_index(SWMM_Engine engine, const char* id);
344
355SWMM_ENGINE_API const char* swmm_pattern_id(SWMM_Engine engine, int idx);
356
373SWMM_ENGINE_API int swmm_pattern_get_type(SWMM_Engine engine, int idx, int* type);
374
386SWMM_ENGINE_API int swmm_pattern_get_factor_count(SWMM_Engine engine, int idx, int* count);
387
400SWMM_ENGINE_API int swmm_pattern_get_factor(SWMM_Engine engine, int idx, int i, double* v);
401
426
445SWMM_ENGINE_API int swmm_pattern_rename(SWMM_Engine engine, int idx, const char* newId);
446
474SWMM_ENGINE_API int swmm_table_rename(SWMM_Engine engine, int idx, const char* newId);
475
491SWMM_ENGINE_API int swmm_table_set_type(SWMM_Engine engine, int idx, int type);
492
493#ifdef __cplusplus
494} /* extern "C" */
495#endif
496
497#endif /* OPENSWMM_TABLES_H */
double * y
Definition odesolve.c:37
#define SWMM_ENGINE_API
Definition openswmm_2d.h:62
void * SWMM_Engine
Opaque handle to an OpenSWMM Engine instance.
Definition openswmm_callbacks.h:55
OpenSWMM Engine — primary transparent C API (master header).
SWMM_ENGINE_API int swmm_table_add_point(SWMM_Engine engine, int idx, double x, double y)
Append a data point (x, y) to a table.
Definition openswmm_tables_impl.cpp:220
SWMM_ENGINE_API int swmm_pattern_add(SWMM_Engine engine, const char *id, int type)
Add a new time pattern to the model.
Definition openswmm_tables_impl.cpp:318
SWMM_ENGINE_API int swmm_pattern_get_factor(SWMM_Engine engine, int idx, int i, double *v)
Get one multiplier factor from a pattern.
Definition openswmm_tables_impl.cpp:387
SWMM_ENGINE_API int swmm_table_get_point(SWMM_Engine engine, int idx, int pt_idx, double *x, double *y)
Get a specific data point from a table.
Definition openswmm_tables_impl.cpp:239
SWMM_ENGINE_API int swmm_table_lookup(SWMM_Engine engine, int idx, double x, double *y)
Interpolate a Y value from a table for a given X.
Definition openswmm_tables_impl.cpp:304
SWMM_ENGINE_API const char * swmm_pattern_id(SWMM_Engine engine, int idx)
Get the string identifier of a pattern by index.
Definition openswmm_tables_impl.cpp:358
SWMM_ENGINE_API int swmm_pattern_index(SWMM_Engine engine, const char *id)
Look up a pattern's zero-based index by its string identifier.
Definition openswmm_tables_impl.cpp:351
SWMM_ENGINE_API int swmm_table_get_point_count(SWMM_Engine engine, int idx, int *count)
Get the number of data points in a table.
Definition openswmm_tables_impl.cpp:230
SWMM_ENGINE_API int swmm_table_get_type(SWMM_Engine engine, int idx, int *type)
Get a table's type code.
Definition openswmm_tables_impl.cpp:166
SWMM_ENGINE_API int swmm_timeseries_add(SWMM_Engine engine, const char *id)
Add a new time series to the model.
Definition openswmm_tables_impl.cpp:180
SWMM_ENGINE_API int swmm_pattern_remove(SWMM_Engine engine, int idx)
Remove a time pattern by index, clearing any reference sites.
Definition openswmm_tables_impl.cpp:399
SWMM_ENGINE_API int swmm_table_set_type(SWMM_Engine engine, int idx, int type)
Change a curve's type (STORAGE … PUMP5) in place, keeping its points and every reference to it.
Definition openswmm_tables_impl.cpp:445
SWMM_ENGINE_API int swmm_table_clear(SWMM_Engine engine, int idx)
Remove all data points from a table.
Definition openswmm_tables_impl.cpp:254
SWMM_ENGINE_API int swmm_table_count(SWMM_Engine engine)
Get the total number of tables (time series + curves) in the model.
Definition openswmm_tables_impl.cpp:143
SWMM_ENGINE_API int swmm_pattern_count(SWMM_Engine engine)
Get the total number of time patterns in the model.
Definition openswmm_tables_impl.cpp:345
SWMM_ENGINE_API const char * swmm_table_id(SWMM_Engine engine, int idx)
Get the string identifier of a table by index.
Definition openswmm_tables_impl.cpp:157
SWMM_ENGINE_API int swmm_pattern_get_type(SWMM_Engine engine, int idx, int *type)
Get a pattern's type code.
Definition openswmm_tables_impl.cpp:367
SWMM_ENGINE_API int swmm_table_rename(SWMM_Engine engine, int idx, const char *newId)
Rename a timeseries or curve; rewrites every name-based reference to it (gages, external inflows,...
Definition openswmm_tables_impl.cpp:413
SWMM_ENGINE_API int swmm_timeseries_get_relative_info(SWMM_Engine engine, int idx, int *n_relative, double *anchor)
Get a timeseries' time-only (relative) row info.
Definition openswmm_tables_impl.cpp:270
SWMM_ENGINE_API int swmm_curve_add(SWMM_Engine engine, const char *id, int type)
Add a new curve to the model.
Definition openswmm_tables_impl.cpp:198
SWMM_ENGINE_API int swmm_timeseries_set_relative_info(SWMM_Engine engine, int idx, int n_relative, double anchor)
Declare a timeseries' leading rows as time-only (relative).
Definition openswmm_tables_impl.cpp:285
SWMM_ENGINE_API int swmm_table_index(SWMM_Engine engine, const char *id)
Look up a table's zero-based index by its string identifier.
Definition openswmm_tables_impl.cpp:149
SWMM_ENGINE_API int swmm_pattern_set_factors(SWMM_Engine engine, int idx, const double *factors, int count)
Set the multiplier factors for a time pattern.
Definition openswmm_tables_impl.cpp:330
SWMM_ENGINE_API int swmm_pattern_rename(SWMM_Engine engine, int idx, const char *newId)
Rename a time pattern; updates every stored reference to the previous name across inflows,...
Definition openswmm_tables_impl.cpp:462
SWMM_ENGINE_API int swmm_pattern_get_factor_count(SWMM_Engine engine, int idx, int *count)
Get the number of multiplier factors stored for a pattern.
Definition openswmm_tables_impl.cpp:377