13#ifndef OPENSWMM_API_COMMON_HPP
14#define OPENSWMM_API_COMMON_HPP
16#include "SWMMEngine.hpp"
23static inline openswmm::SWMMEngine* to_engine(
SWMM_Engine e)
noexcept {
24 return static_cast<openswmm::SWMMEngine*
>(e);
47static inline double to_display(
const Ctx& ctx,
int q,
double v)
noexcept {
53static inline double to_internal(
const Ctx& ctx,
int q,
double v)
noexcept {
57#define CHECK_HANDLE(e) do { if (!(e)) return SWMM_ERR_BADHANDLE; } while(0)
58#define CHECK_INDEX(cond) do { if (!(cond)) return SWMM_ERR_BADINDEX; } while(0)
65#define CHECK_GEOMETRY(ctx) \
67 if ((ctx).state != openswmm::EngineState::BUILDING && \
68 (ctx).state != openswmm::EngineState::OPENED) \
69 return SWMM_ERR_LIFECYCLE; \
77#define CHECK_EDITABLE(ctx) \
79 if ((ctx).state != openswmm::EngineState::BUILDING && \
80 (ctx).state != openswmm::EngineState::OPENED) \
81 return SWMM_ERR_LIFECYCLE; \
85#define CHECK_INITIAL_COND(ctx) \
87 if ((ctx).state != openswmm::EngineState::BUILDING && \
88 (ctx).state != openswmm::EngineState::OPENED && \
89 (ctx).state != openswmm::EngineState::INITIALIZED) \
90 return SWMM_ERR_LIFECYCLE; \
94#define CHECK_RUNNING(ctx) \
96 if ((ctx).state != openswmm::EngineState::RUNNING) \
97 return SWMM_ERR_LIFECYCLE; \
101#define CHECK_READABLE(ctx) \
103 if ((ctx).state == openswmm::EngineState::CREATED || \
104 (ctx).state == openswmm::EngineState::CLOSED || \
105 (ctx).state == openswmm::EngineState::ERROR_STATE) \
106 return SWMM_ERR_LIFECYCLE; \
Global unit conversion factors — matching legacy SWMM Ucf[]/Qcf[].
double UCF(int quantity, const SimulationOptions &opts)
Get unit conversion factor for a quantity.
Definition UnitConversion.cpp:23
double UCF_inv(int quantity, const SimulationOptions &opts)
Reciprocal of UCF — multiply display by this to get internal units.
Definition UnitConversion.cpp:37
void * SWMM_Engine
Opaque handle to an OpenSWMM Engine instance.
Definition openswmm_callbacks.h:35
OpenSWMM Engine — primary transparent C API (master header).