29#ifndef OPENSWMM_API_COMMON_HPP
30#define OPENSWMM_API_COMMON_HPP
32#include "SWMMEngine.hpp"
39static inline openswmm::SWMMEngine* to_engine(
SWMM_Engine e)
noexcept {
40 return static_cast<openswmm::SWMMEngine*
>(e);
63static inline double to_display(
const Ctx& ctx,
int q,
double v)
noexcept {
69static inline double to_internal(
const Ctx& ctx,
int q,
double v)
noexcept {
73#define CHECK_HANDLE(e) do { if (!(e)) return SWMM_ERR_BADHANDLE; } while(0)
74#define CHECK_INDEX(cond) do { if (!(cond)) return SWMM_ERR_BADINDEX; } while(0)
81#define CHECK_GEOMETRY(ctx) \
83 if ((ctx).state != openswmm::EngineState::BUILDING && \
84 (ctx).state != openswmm::EngineState::OPENED) \
85 return SWMM_ERR_LIFECYCLE; \
93#define CHECK_EDITABLE(ctx) \
95 if ((ctx).state != openswmm::EngineState::BUILDING && \
96 (ctx).state != openswmm::EngineState::OPENED) \
97 return SWMM_ERR_LIFECYCLE; \
101#define CHECK_INITIAL_COND(ctx) \
103 if ((ctx).state != openswmm::EngineState::BUILDING && \
104 (ctx).state != openswmm::EngineState::OPENED && \
105 (ctx).state != openswmm::EngineState::INITIALIZED) \
106 return SWMM_ERR_LIFECYCLE; \
110#define CHECK_RUNNING(ctx) \
112 if ((ctx).state != openswmm::EngineState::RUNNING) \
113 return SWMM_ERR_LIFECYCLE; \
117#define CHECK_READABLE(ctx) \
119 if ((ctx).state == openswmm::EngineState::CREATED || \
120 (ctx).state == openswmm::EngineState::CLOSED || \
121 (ctx).state == openswmm::EngineState::ERROR_STATE) \
122 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:39
double UCF_inv(int quantity, const SimulationOptions &opts)
Reciprocal of UCF — multiply display by this to get internal units.
Definition UnitConversion.cpp:53
void * SWMM_Engine
Opaque handle to an OpenSWMM Engine instance.
Definition openswmm_callbacks.h:51
OpenSWMM Engine — primary transparent C API (master header).