OpenSWMM Engine
6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
openswmm_api_common.hpp
Go to the documentation of this file.
1
13
#ifndef OPENSWMM_API_COMMON_HPP
14
#define OPENSWMM_API_COMMON_HPP
15
16
#include "SWMMEngine.hpp"
17
#include "../../../include/openswmm/engine/openswmm_engine.h"
18
19
#include <cstring>
20
#include <algorithm>
21
22
static
inline
openswmm::SWMMEngine* to_engine(
SWMM_Engine
e)
noexcept
{
23
return
static_cast<
openswmm::SWMMEngine*
>
(e);
24
}
25
26
#define CHECK_HANDLE(e) do { if (!(e)) return SWMM_ERR_BADHANDLE; } while(0)
27
#define CHECK_INDEX(cond) do { if (!(cond)) return SWMM_ERR_BADINDEX; } while(0)
28
29
// ============================================================================
30
// Lifecycle state guards
31
// ============================================================================
32
34
#define CHECK_GEOMETRY(ctx) \
35
do { \
36
if ((ctx).state != openswmm::EngineState::BUILDING && \
37
(ctx).state != openswmm::EngineState::OPENED) \
38
return SWMM_ERR_LIFECYCLE; \
39
} while(0)
40
42
#define CHECK_INITIAL_COND(ctx) \
43
do { \
44
if ((ctx).state != openswmm::EngineState::BUILDING && \
45
(ctx).state != openswmm::EngineState::OPENED && \
46
(ctx).state != openswmm::EngineState::INITIALIZED) \
47
return SWMM_ERR_LIFECYCLE; \
48
} while(0)
49
51
#define CHECK_RUNNING(ctx) \
52
do { \
53
if ((ctx).state != openswmm::EngineState::RUNNING) \
54
return SWMM_ERR_LIFECYCLE; \
55
} while(0)
56
58
#define CHECK_READABLE(ctx) \
59
do { \
60
if ((ctx).state == openswmm::EngineState::CREATED || \
61
(ctx).state == openswmm::EngineState::CLOSED || \
62
(ctx).state == openswmm::EngineState::ERROR_STATE) \
63
return SWMM_ERR_LIFECYCLE; \
64
} while(0)
65
66
#endif
/* OPENSWMM_API_COMMON_HPP */
SWMM_Engine
void * SWMM_Engine
Opaque handle to an OpenSWMM Engine instance.
Definition
openswmm_callbacks.h:35
src
engine
core
openswmm_api_common.hpp
Generated by
1.9.8