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{
nullptr};
30 struct ConnectionsList;
31 struct PotentialConnections;
33 class TemplateMatcher;
47 explicit Connector(std::vector<std::string> args);
64 const std::shared_ptr<Core>& coreObj,
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; }
122 using ConnectionsType = std::unordered_multimap<std::string_view, Connection>;
125 std::unique_ptr<helicsCLI11App> generateParser();
134 virtual void loadJsonFile(
const std::string& jsonString,
135 bool enableFederateInterfaceRegistration)
override;
137 virtual void loadTextFile(
const std::string& filename)
override;
139 bool addConnectionVector(
const std::vector<std::string>& connection);
141 void establishPotentialInterfaces(ConnectionsList& possibleConnections);
144 void scanPotentialInterfaces(ConnectionsList& possibleConnections);
147 void scanPotentialInterfaceTemplates(ConnectionsList& possibleConnections);
150 void scanUnconnectedInterfaces(ConnectionsList& possibleConnections);
153 void makeConnections(ConnectionsList& possibleConnections);
155 int makeTargetConnection(
156 std::string_view origin,
157 const std::vector<std::size_t>& tagList,
158 std::unordered_set<std::string_view>& possibleConnections,
159 const std::unordered_multimap<std::string_view, std::string_view>& aliases,
160 const std::function<
void(std::string_view origin, std::string_view target)>& callback);
161 bool makePotentialConnection(
162 std::string_view interfaceName,
163 const std::vector<std::size_t>& tagList,
164 std::unordered_map<std::string_view, PotentialConnections>& potentials,
165 const std::unordered_multimap<std::string_view, std::string_view>& aliases);
167 bool makePotentialTemplateConnection(
168 std::string_view interfaceName,
169 const std::vector<std::size_t>& tagList,
170 std::vector<TemplateMatcher>& potentialTemplates,
171 const std::unordered_multimap<std::string_view, std::string_view>& aliases);
173 bool checkPotentialConnection(
174 std::string_view interface,
175 const std::vector<std::size_t>& tagList,
176 std::unordered_set<std::string_view>& possibleConnections,
177 std::unordered_map<std::string_view, PotentialConnections>& potentials,
178 std::vector<TemplateMatcher>& potentialTemplates,
179 const std::unordered_multimap<std::string_view, std::string_view>& aliases);
181 std::vector<Connection>
182 buildPossibleConnectionList(std::string_view startingInterface,
183 const std::vector<std::size_t>& tagList)
const;
185 void generateRegexMatchers();
190 ConnectionsType connections;
191 std::vector<Connection> matchers;
192 std::vector<std::shared_ptr<RegexMatcher>> regexMatchers;
193 std::unordered_map<std::size_t, std::string> tags;
194 std::unordered_set<std::string> interfaces;
195 std::uint64_t matchCount{0};
196 std::uint64_t interfacesRequested{0};
198 bool matchTargetEndpoints{
false};
200 bool matchMultiple{
false};
202 bool alwaysCheckRegex{
false};
Definition: FederateInfo.hpp:28
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