OpenSWMM Engine  6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
PluginDiscovery.hpp
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
36
37#ifndef OPENSWMM_PLUGIN_DISCOVERY_HPP
38#define OPENSWMM_PLUGIN_DISCOVERY_HPP
39
40#include <string>
41#include <vector>
42
44
45/* =========================================================================
46 * Export macro
47 *
48 * The engine target sets WINDOWS_EXPORT_ALL_SYMBOLS OFF and relies on explicit
49 * export macros (see src/engine/CMakeLists.txt). On ELF/Mach-O the target's
50 * CXX_VISIBILITY_PRESET is `default`, so omitting the macro still exports the
51 * symbol — which is why the unannotated declarations below linked fine on
52 * Linux/macOS while failing on Windows with:
53 * error LNK2001: unresolved external symbol openswmm::discover_all_filters
54 * Block is byte-identical to the one in openswmm_engine.h / openswmm_2d.h;
55 * identical macro redefinition is well-defined, so including those alongside
56 * this header is safe.
57 * ========================================================================= */
58
59#ifdef OPENSWMM_ENGINE_STATIC
60# define SWMM_ENGINE_API
61#else
62# ifdef _WIN32
63# ifdef openswmm_engine_EXPORTS
64# define SWMM_ENGINE_API __declspec(dllexport)
65# else
66# define SWMM_ENGINE_API __declspec(dllimport)
67# endif
68# else
69# define SWMM_ENGINE_API __attribute__((visibility("default")))
70# endif
71#endif
72
73namespace openswmm {
74
85 std::string plugin_id;
86 std::string plugin_version;
87 std::string plugin_caption;
89
95 bool is_builtin = false;
96};
97
112SWMM_ENGINE_API std::vector<DiscoveredFilter> discover_all_filters();
113
132 std::string plugin_id;
133 std::string plugin_version;
134 std::string plugin_caption;
135 std::vector<PluginRole> roles;
136 std::vector<FileFilter> filters;
137
151 bool is_builtin = false;
152};
153
169SWMM_ENGINE_API std::vector<DiscoveredPlugin> discover_plugins_by_id();
170
171} /* namespace openswmm */
172
173#endif /* OPENSWMM_PLUGIN_DISCOVERY_HPP */
Interface that describes a plugin component — metadata and factory methods.
Definition NodeCoupling.cpp:16
std::vector< DiscoveredPlugin > discover_plugins_by_id()
Enumerate every discovered plugin, grouped by plugin_id.
Definition PluginDiscovery.cpp:55
std::vector< DiscoveredFilter > discover_all_filters()
Enumerate every FileFilter advertised by every discovered plugin.
Definition PluginDiscovery.cpp:35
#define SWMM_ENGINE_API
Definition openswmm_2d.h:53
A FileFilter paired with the plugin id and version that emitted it.
Definition PluginDiscovery.hpp:84
bool is_builtin
Definition PluginDiscovery.hpp:95
std::string plugin_caption
IPluginComponentInfo::caption() — human-readable.
Definition PluginDiscovery.hpp:87
std::string plugin_id
IPluginComponentInfo::id() of the source plugin.
Definition PluginDiscovery.hpp:85
std::string plugin_version
IPluginComponentInfo::version() of the source plugin.
Definition PluginDiscovery.hpp:86
FileFilter filter
The advertised filter.
Definition PluginDiscovery.hpp:88
A plugin grouped by id with all the roles and filters it advertises.
Definition PluginDiscovery.hpp:131
std::string plugin_version
IPluginComponentInfo::version()
Definition PluginDiscovery.hpp:133
std::string plugin_id
IPluginComponentInfo::id()
Definition PluginDiscovery.hpp:132
std::string plugin_caption
IPluginComponentInfo::caption()
Definition PluginDiscovery.hpp:134
std::vector< FileFilter > filters
Every filter the plugin advertises.
Definition PluginDiscovery.hpp:136
std::vector< PluginRole > roles
Distinct roles advertised across all filters.
Definition PluginDiscovery.hpp:135
bool is_builtin
True when the plugin was registered as an engine built-in (via PluginFactory::register_builtin_infos)...
Definition PluginDiscovery.hpp:151
A file-format filter advertised by a plugin.
Definition IPluginComponentInfo.hpp:131