10 #include "helicsApp.hpp"
14 #include <string_view>
15 #include <unordered_map>
16 #include <unordered_set>
19 namespace helics::apps {
20 enum class InterfaceDirection { TO_FROM = -1, BIDIRECTIONAL = 0, FROM_TO = 1 };
23 std::string_view interface1;
24 std::string_view interface2;
25 InterfaceDirection direction;
26 std::vector<std::size_t> tags;
27 std::shared_ptr<std::string> stringBuffer;
30 struct ConnectionsList;
31 struct PotentialConnections;
33 class TemplateMatcher;
47 explicit Connector(std::vector<std::string> args);
64 const std::shared_ptr<Core>& core,
77 Connector(std::string_view appName,
const std::string& configString);
90 virtual void initialize()
override;
95 virtual void runTo(
Time stopTime_input)
override;
103 void addConnection(std::string_view interface1,
104 std::string_view interface2,
105 InterfaceDirection direction = InterfaceDirection::BIDIRECTIONAL,
106 const std::vector<std::string>& tags = {});
109 std::size_t addTag(std::string_view tagName);
113 std::string_view addInterface(std::string_view interfaceName);
119 void allowMultipleConnections(
bool value =
true) { matchMultiple = value; }
120 void matchEndpointTargets(
bool value =
true) { matchTargetEndpoints = value; }
123 std::unique_ptr<helicsCLI11App> generateParser();
132 virtual void loadJsonFile(
const std::string& jsonString,
133 bool enableFederateInterfaceRegistration)
override;
135 virtual void loadTextFile(
const std::string& filename)
override;
137 bool addConnectionVector(
const std::vector<std::string>& connection);
139 void establishPotentialInterfaces(ConnectionsList& possibleConnections);
142 void scanPotentialInterfaces(ConnectionsList& possibleConnections);
145 void scanPotentialInterfaceTemplates(ConnectionsList& possibleConnections);
148 void scanUnconnectedInterfaces(ConnectionsList& possibleConnections);
151 void makeConnections(ConnectionsList& possibleConnections);
153 int makeTargetConnection(
154 std::string_view origin,
155 const std::vector<std::size_t>& tagList,
156 std::unordered_set<std::string_view>& possibleConnections,
157 const std::unordered_multimap<std::string_view, std::string_view>& aliases,
158 const std::function<
void(std::string_view origin, std::string_view target)>& callback);
159 bool makePotentialConnection(
160 std::string_view interfaceName,
161 const std::vector<std::size_t>& tagList,
162 std::unordered_map<std::string_view, PotentialConnections>& potentials,
163 const std::unordered_multimap<std::string_view, std::string_view>& aliases);
165 bool makePotentialTemplateConnection(
166 std::string_view interfaceName,
167 const std::vector<std::size_t>& tagList,
168 std::vector<TemplateMatcher>& potentialTemplates,
169 const std::unordered_multimap<std::string_view, std::string_view>& aliases);
171 bool checkPotentialConnection(
172 std::string_view interface,
173 const std::vector<std::size_t>& tagList,
174 std::unordered_set<std::string_view>& possibleConnections,
175 std::unordered_map<std::string_view, PotentialConnections>& potentials,
176 std::vector<TemplateMatcher>& potentialTemplates,
177 const std::unordered_multimap<std::string_view, std::string_view>& aliases);
179 std::vector<Connection>
180 buildPossibleConnectionList(std::string_view startingInterface,
181 const std::vector<std::size_t>& tagList)
const;
183 void generateRegexMatchers();
188 std::unordered_multimap<std::string_view, Connection> connections;
189 std::vector<Connection> matchers;
190 std::vector<std::shared_ptr<RegexMatcher>> regexMatchers;
191 std::unordered_map<std::size_t, std::string> tags;
192 std::unordered_set<std::string> interfaces;
193 std::uint64_t matchCount{0};
194 std::uint64_t interfacesRequested{0};
196 bool matchTargetEndpoints{
false};
198 bool matchMultiple{
false};
200 bool alwaysCheckRegex{
false};
Definition: FederateInfo.hpp:29
Definition: helicsApp.hpp:32
Definition: Connector.hpp:40
Connector & operator=(Connector &&fed)=default
auto connectionCount() const
Definition: Connector.hpp:116
Connector(Connector &&other_player)=default
auto madeConnections() const
Definition: Connector.hpp:118
TimeRepresentation< count_time< 9 > > Time
Definition: helicsTime.hpp:27
Definition: Connector.hpp:22