OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
TypeHelpers.hpp
Go to the documentation of this file.
1
18#ifndef OPENSWMM_ENGINE_TYPE_HELPERS_HPP
19#define OPENSWMM_ENGINE_TYPE_HELPERS_HPP
20
21#include "../data/NodeData.hpp"
22#include "../data/LinkData.hpp"
23#include "../../../include/openswmm/engine/openswmm_nodes.h"
24#include "../../../include/openswmm/engine/openswmm_links.h"
25
26namespace openswmm {
27
28// ============================================================================
29// Node type mapping
30// ============================================================================
31
32inline bool c_to_internal_node_type(int c_type, NodeType& out_type) noexcept {
33 switch (c_type) {
34 case SWMM_NODE_JUNCTION: out_type = NodeType::JUNCTION; return true;
35 case SWMM_NODE_OUTFALL: out_type = NodeType::OUTFALL; return true;
36 case SWMM_NODE_STORAGE: out_type = NodeType::STORAGE; return true;
37 case SWMM_NODE_DIVIDER: out_type = NodeType::DIVIDER; return true;
38 default: return false;
39 }
40}
41
42inline int internal_to_c_node_type(NodeType type) noexcept {
43 switch (type) {
48 default: return SWMM_NODE_JUNCTION;
49 }
50}
51
52// ============================================================================
53// Link type mapping (C API and internal values match, but wrap for symmetry)
54// ============================================================================
55
56inline bool c_to_internal_link_type(int c_type, LinkType& out_type) noexcept {
57 switch (c_type) {
58 case SWMM_LINK_CONDUIT: out_type = LinkType::CONDUIT; return true;
59 case SWMM_LINK_PUMP: out_type = LinkType::PUMP; return true;
60 case SWMM_LINK_ORIFICE: out_type = LinkType::ORIFICE; return true;
61 case SWMM_LINK_WEIR: out_type = LinkType::WEIR; return true;
62 case SWMM_LINK_OUTLET: out_type = LinkType::OUTLET; return true;
63 default: return false;
64 }
65}
66
67inline int internal_to_c_link_type(LinkType type) noexcept {
68 switch (type) {
70 case LinkType::PUMP: return SWMM_LINK_PUMP;
72 case LinkType::WEIR: return SWMM_LINK_WEIR;
74 default: return SWMM_LINK_CONDUIT;
75 }
76}
77
78} // namespace openswmm
79
80#endif /* OPENSWMM_ENGINE_TYPE_HELPERS_HPP */
Definition NodeCoupling.cpp:15
int internal_to_c_link_type(LinkType type) noexcept
Definition TypeHelpers.hpp:67
LinkType
Link type codes.
Definition LinkData.hpp:42
NodeType
Node type codes.
Definition NodeData.hpp:43
bool c_to_internal_node_type(int c_type, NodeType &out_type) noexcept
Definition TypeHelpers.hpp:32
int internal_to_c_node_type(NodeType type) noexcept
Definition TypeHelpers.hpp:42
bool c_to_internal_link_type(int c_type, LinkType &out_type) noexcept
Definition TypeHelpers.hpp:56
@ SWMM_NODE_JUNCTION
Definition openswmm_nodes.h:33
@ SWMM_NODE_OUTFALL
Definition openswmm_nodes.h:34
@ SWMM_NODE_DIVIDER
Definition openswmm_nodes.h:36
@ SWMM_NODE_STORAGE
Definition openswmm_nodes.h:35