| helics 3.6.1

UnknownHandleManager.hpp
1 /*
2 Copyright (c) 2017-2025,
3 Battelle Memorial Institute; Lawrence Livermore National Security, LLC; Alliance for Sustainable
4 Energy, LLC. See the top-level NOTICE for additional details. All rights reserved.
5 SPDX-License-Identifier: BSD-3-Clause
6 */
7 #pragma once
8 #include "CoreTypes.hpp"
9 #include "GlobalFederateId.hpp"
10
11 #include <string>
12 #include <unordered_map>
13 #include <utility>
14 #include <vector>
15
16 namespace helics {
20 class UnknownHandleManager {
21 public:
22 using TargetInfo = std::pair<GlobalHandle, uint16_t>;
23
24 private:
25 std::unordered_multimap<std::string, TargetInfo>
26 unknown_publications;
27 std::unordered_multimap<std::string, TargetInfo>
28 unknown_endpoints;
29 std::unordered_multimap<std::string, TargetInfo> unknown_inputs;
30 std::unordered_multimap<std::string, TargetInfo>
31 unknown_filters;
32
33 std::unordered_multimap<std::string, std::string>
34 unknown_links;
35 std::unordered_multimap<std::string, std::string>
36 unknown_endpoint_links;
37 std::unordered_multimap<std::string, std::string>
38 unknown_src_filters;
39 std::unordered_multimap<std::string, std::string>
40 unknown_dest_filters;
41
42 std::unordered_multimap<std::string, TargetInfo>
43 reconnectable_publications;
44 std::unordered_multimap<std::string, TargetInfo>
45 reconnectable_endpoints;
46 std::unordered_multimap<std::string, TargetInfo>
47 reconnectable_inputs;
48 std::unordered_multimap<std::string, TargetInfo>
49 reconnectable_filters;
50 public:
52 UnknownHandleManager() = default;
54 void addUnknownPublication(std::string_view key, GlobalHandle target, uint16_t flags);
56 void addUnknownInput(std::string_view key, GlobalHandle target, uint16_t flags);
58 void addUnknownEndpoint(std::string_view key, GlobalHandle target, uint16_t flags);
60 void addUnknownFilter(std::string_view key, GlobalHandle target, uint16_t flags);
61
63 void addReconnectablePublication(std::string_view key, GlobalHandle target, uint16_t flags);
65 void addReconnectableInput(std::string_view key, GlobalHandle target, uint16_t flags);
67 void addReconnectableEndpoint(std::string_view key, GlobalHandle target, uint16_t flags);
69 void addReconnectableFilter(std::string_view key, GlobalHandle target, uint16_t flags);
70
72 void addDataLink(std::string_view source, std::string_view target);
74 void addEndpointLink(std::string_view source, std::string_view target);
75
76 void addSourceFilterLink(std::string_view filter, std::string_view endpoint);
77 void addDestinationFilterLink(std::string_view filter, std::string_view endpoint);
79 std::vector<TargetInfo> checkForInputs(const std::string& newInput) const;
81 std::vector<TargetInfo> checkForPublications(const std::string& newPublication) const;
83 std::vector<TargetInfo> checkForEndpoints(const std::string& newEndpoint) const;
84
86 std::vector<TargetInfo> checkForFilters(const std::string& newFilter) const;
87
89 std::vector<TargetInfo> checkForReconnectionInputs(const std::string& newInput) const;
91 std::vector<TargetInfo>
92 checkForReconnectionPublications(const std::string& newPublication) const;
94 std::vector<TargetInfo> checkForReconnectionEndpoints(const std::string& newEndpoint) const;
95
97 std::vector<TargetInfo> checkForReconnectionFilters(const std::string& newFilter) const;
98
100 std::vector<std::string> checkForLinks(const std::string& newSource) const;
101
103 std::vector<std::string> checkForEndpointLinks(const std::string& newSource) const;
104
105 std::vector<std::string> checkForFilterSourceTargets(const std::string& newFilter) const;
106 std::vector<std::string> checkForFilterDestTargets(const std::string& newFilter) const;
108 void clearInput(const std::string& newInput);
110 void clearPublication(const std::string& newPublication);
112 void clearEndpoint(const std::string& newEndpoint);
113
115 void clearFilter(const std::string& newFilter);
117 void clearFederateUnknowns(GlobalFederateId id);
119 void clearUnknownsIf(
120 const std::function<bool(const std::string& name, InterfaceType, TargetInfo)>& cfunc);
122 bool hasUnknowns() const;
123
125 bool hasNonOptionalUnknowns() const;
126
128 bool hasRequiredUnknowns() const;
133 void processRequiredUnknowns(
134 const std::function<void(const std::string& name, InterfaceType, TargetInfo)>& cfunc) const;
135
140 void processNonOptionalUnknowns(
141 const std::function<void(const std::string& name, InterfaceType, TargetInfo)>& cfunc) const;
142
147 void processUnknowns(
148 const std::function<void(const std::string& name, InterfaceType, TargetInfo)>& cfunc) const;
149
154 void processUnknownLinks(const std::function<void(const std::string& origin,
155 InterfaceType,
156 const std::string& target,
157 InterfaceType)>& cfunc) const;
158 };
159
160 } // namespace helics
CoreTypes.hpp
helics::GlobalFederateId
Definition: GlobalFederateId.hpp:75
helics::GlobalHandle
Definition: GlobalFederateId.hpp:147
helics::UnknownHandleManager
Definition: UnknownHandleManager.hpp:20
helics::UnknownHandleManager::hasRequiredUnknowns
bool hasRequiredUnknowns() const
Definition: UnknownHandleManager.cpp:222
helics::UnknownHandleManager::clearFilter
void clearFilter(const std::string &newFilter)
Definition: UnknownHandleManager.cpp:346
helics::UnknownHandleManager::clearFederateUnknowns
void clearFederateUnknowns(GlobalFederateId id)
Definition: UnknownHandleManager.cpp:367
helics::UnknownHandleManager::clearInput
void clearInput(const std::string &newInput)
Definition: UnknownHandleManager.cpp:327
helics::UnknownHandleManager::checkForReconnectionInputs
std::vector< TargetInfo > checkForReconnectionInputs(const std::string &newInput) const
Definition: UnknownHandleManager.cpp:176
helics::UnknownHandleManager::checkForFilters
std::vector< TargetInfo > checkForFilters(const std::string &newFilter) const
Definition: UnknownHandleManager.cpp:158
helics::UnknownHandleManager::addUnknownInput
void addUnknownInput(std::string_view key, GlobalHandle target, uint16_t flags)
Definition: UnknownHandleManager.cpp:26
helics::UnknownHandleManager::addReconnectablePublication
void addReconnectablePublication(std::string_view key, GlobalHandle target, uint16_t flags)
Definition: UnknownHandleManager.cpp:48
helics::UnknownHandleManager::clearUnknownsIf
void clearUnknownsIf(const std::function< bool(const std::string &name, InterfaceType, TargetInfo)> &cfunc)
Definition: UnknownHandleManager.cpp:376
helics::UnknownHandleManager::addUnknownEndpoint
void addUnknownEndpoint(std::string_view key, GlobalHandle target, uint16_t flags)
Definition: UnknownHandleManager.cpp:34
helics::UnknownHandleManager::processUnknownLinks
void processUnknownLinks(const std::function< void(const std::string &origin, InterfaceType, const std::string &target, InterfaceType)> &cfunc) const
Definition: UnknownHandleManager.cpp:251
helics::UnknownHandleManager::checkForReconnectionFilters
std::vector< TargetInfo > checkForReconnectionFilters(const std::string &newFilter) const
Definition: UnknownHandleManager.cpp:193
helics::UnknownHandleManager::checkForInputs
std::vector< TargetInfo > checkForInputs(const std::string &newInput) const
Definition: UnknownHandleManager.cpp:130
helics::UnknownHandleManager::checkForEndpoints
std::vector< TargetInfo > checkForEndpoints(const std::string &newEndpoint) const
Definition: UnknownHandleManager.cpp:152
helics::UnknownHandleManager::processUnknowns
void processUnknowns(const std::function< void(const std::string &name, InterfaceType, TargetInfo)> &cfunc) const
Definition: UnknownHandleManager.cpp:234
helics::UnknownHandleManager::processNonOptionalUnknowns
void processNonOptionalUnknowns(const std::function< void(const std::string &name, InterfaceType, TargetInfo)> &cfunc) const
Definition: UnknownHandleManager.cpp:270
helics::UnknownHandleManager::clearPublication
void clearPublication(const std::string &newPublication)
Definition: UnknownHandleManager.cpp:333
helics::UnknownHandleManager::checkForPublications
std::vector< TargetInfo > checkForPublications(const std::string &newPublication) const
Definition: UnknownHandleManager.cpp:135
helics::UnknownHandleManager::checkForReconnectionPublications
std::vector< TargetInfo > checkForReconnectionPublications(const std::string &newPublication) const
Definition: UnknownHandleManager.cpp:181
helics::UnknownHandleManager::clearEndpoint
void clearEndpoint(const std::string &newEndpoint)
Definition: UnknownHandleManager.cpp:339
helics::UnknownHandleManager::addEndpointLink
void addEndpointLink(std::string_view source, std::string_view target)
Definition: UnknownHandleManager.cpp:82
helics::UnknownHandleManager::processRequiredUnknowns
void processRequiredUnknowns(const std::function< void(const std::string &name, InterfaceType, TargetInfo)> &cfunc) const
Definition: UnknownHandleManager.cpp:300
helics::UnknownHandleManager::addReconnectableEndpoint
void addReconnectableEndpoint(std::string_view key, GlobalHandle target, uint16_t flags)
Definition: UnknownHandleManager.cpp:63
helics::UnknownHandleManager::addReconnectableInput
void addReconnectableInput(std::string_view key, GlobalHandle target, uint16_t flags)
Definition: UnknownHandleManager.cpp:55
helics::UnknownHandleManager::UnknownHandleManager
UnknownHandleManager()=default
helics::UnknownHandleManager::checkForReconnectionEndpoints
std::vector< TargetInfo > checkForReconnectionEndpoints(const std::string &newEndpoint) const
Definition: UnknownHandleManager.cpp:187
helics::UnknownHandleManager::hasUnknowns
bool hasUnknowns() const
Definition: UnknownHandleManager.cpp:198
helics::UnknownHandleManager::checkForLinks
std::vector< std::string > checkForLinks(const std::string &newSource) const
Definition: UnknownHandleManager.cpp:140
helics::UnknownHandleManager::addDataLink
void addDataLink(std::string_view source, std::string_view target)
Definition: UnknownHandleManager.cpp:77
helics::UnknownHandleManager::addUnknownPublication
void addUnknownPublication(std::string_view key, GlobalHandle target, uint16_t flags)
Definition: UnknownHandleManager.cpp:19
helics::UnknownHandleManager::addUnknownFilter
void addUnknownFilter(std::string_view key, GlobalHandle target, uint16_t flags)
Definition: UnknownHandleManager.cpp:41
helics::UnknownHandleManager::checkForEndpointLinks
std::vector< std::string > checkForEndpointLinks(const std::string &newSource) const
Definition: UnknownHandleManager.cpp:146
helics::UnknownHandleManager::addReconnectableFilter
void addReconnectableFilter(std::string_view key, GlobalHandle target, uint16_t flags)
Definition: UnknownHandleManager.cpp:70
helics::UnknownHandleManager::hasNonOptionalUnknowns
bool hasNonOptionalUnknowns() const
Definition: UnknownHandleManager.cpp:205
helics
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
helics::InterfaceType
InterfaceType
Definition: CoreTypes.hpp:112