24#ifndef GOBY_MIDDLEWARE_TOOL_INTERFACE_RESOLVE_H
25#define GOBY_MIDDLEWARE_TOOL_INTERFACE_RESOLVE_H
98 std::vector<Unmatched>& subs)
100 for (
const auto& platform : deployment.
platforms)
102 for (
const auto& module : platform.modules)
104 for (
const auto& app_p :
module.applications)
106 const auto& app = app_p.second;
107 for (
const auto& thread_p : app.threads)
109 Endpoint at{&platform, &module, &app, thread_p.second.get()};
110 for (
const auto& e : thread_p.second->interthread_publishes)
111 pubs.push_back({e, at});
112 for (
const auto& e : thread_p.second->interthread_subscribes)
113 subs.push_back({e, at});
116 Endpoint at{&platform, &module, &app,
nullptr};
119 for (
const auto& e : app.publishes_on(layer)) pubs.push_back({e, at});
120 for (
const auto& e : app.subscribes_on(layer)) subs.push_back({e, at});
130 std::vector<Unmatched> pubs, subs;
134 std::vector<bool> sub_matched(subs.size(),
false);
135 for (
const auto& pub : pubs)
137 bool pub_matched =
false;
138 for (std::size_t i = 0, n = subs.size(); i < n; ++i)
140 const auto& sub = subs[i];
141 if (sub.entry.layer != pub.entry.layer || !
in_scope(pub.entry.layer, pub.at, sub.at))
143 auto match =
connection(pub.entry, sub.entry);
144 if (match != GroupMatch::NONE)
147 {pub.entry, pub.at, sub.entry, sub.at, match == GroupMatch::LOOSE});
149 sub_matched[i] =
true;
155 for (std::size_t i = 0, n = subs.size(); i < n; ++i)
171 bool include_coroner{
false};
172 bool include_terminate{
false};
173 bool include_internal{
false};
174 bool omit_interthread{
false};
176 bool expand_goby_apps{
false};
180 : params_(
std::move(params)),
181 omit_group_regex_(params_.omit_group_regex),
182 omit_node_regex_(params_.omit_node_regex)
190 static const std::set<std::string> internal_groups{
191 "goby::middleware::interprocess::to_portal",
192 "goby::middleware::interprocess::regex",
193 "goby::middleware::SerializationUnSubscribeAll",
194 "goby::middleware::Thread::joinable",
195 "goby::middleware::Thread::shutdown",
196 "goby::configuration",
197 "goby::datum_update",
198 "goby::middleware::intervehicle::modem_data_in",
199 "goby::middleware::intervehicle::modem_data_out",
200 "goby::middleware::intervehicle::metadata_request",
201 "goby::middleware::intervehicle::modem_ack_in",
202 "goby::middleware::intervehicle::modem_expire_in",
203 "goby::middleware::intervehicle::modem_subscription_forward_tx"};
204 static const std::set<std::string> terminate_groups{
205 "goby::terminate::request",
"goby::terminate::response",
"goby::terminate::result"};
206 static const std::set<std::string> coroner_groups{
207 "goby::health::request",
"goby::health::response",
"goby::health::report"};
209 if (!params_.omit_group_regex.empty() && std::regex_match(
group, omit_group_regex_))
213 if (internal_groups.count(name) && !params_.include_internal)
215 if (terminate_groups.count(name) && !params_.include_terminate)
217 if (coroner_groups.count(name) && !params_.include_coroner)
224 return params_.omit_node_regex.empty() || !std::regex_match(node, omit_node_regex_);
230 if (!params_.omit_interthread)
235 for (
const auto& layer_p : *layer_map)
237 for (
const auto& e : layer_p.second)
239 if (e.thread == name)
254 if (!is_node_included(at.
application->
name) || !is_node_included(thread))
258 is_thread_included(*at.
application, *thread_it->second);
263 if (params_.omit_interthread && c.
pub.
layer == Layer::INTERTHREAD)
271 if (params_.omit_interthread && u.
entry.
layer == Layer::INTERTHREAD)
278 std::regex omit_group_regex_;
279 std::regex omit_node_regex_;
285 return app.
name ==
"gobyd" || app.
name.rfind(
"goby_", 0) == 0;
291 static const std::regex goby_lambda(R
"(\(lambda at .*/goby/.*\))");
292 return name.rfind(
"goby::", 0) == 0 || std::regex_match(name, goby_lambda);
298 static const std::regex lambda(R
"(\(lambda at (?:.*/)?([^/]+):(\d+):\d+\))");
300 if (std::regex_match(name, match, lambda))
301 return "lambda (" + match[1].str() +
":" + match[2].str() +
")";
302 auto lt = name.find(
'<');
303 return lt == std::string::npos ? name : name.substr(0, lt) +
"<...>";
311 bool omit_disconnected)
312 : filter_(
std::move(filter)), omit_disconnected_(omit_disconnected)
315 for (
const auto& platform : deployment.
platforms)
317 for (
const auto& module : platform.modules)
319 for (
const auto& app_p :
module.applications)
320 collapse_goby_apps_ |= !is_goby_application(app_p.second);
323 collapse_goby_apps_ &= !filter_.params().expand_goby_apps;
325 auto use = [&](
const Endpoint& at,
const std::string& thread)
331 use(c.pub_at, c.pub.thread);
332 use(c.sub_at, c.sub.thread);
337 if (drawn_unsubscribed(u))
338 use(u.at, u.entry.thread);
342 if (drawn_unpublished(u))
343 use(u.at, u.entry.thread);
348 for (
const auto& platform : deployment.
platforms)
350 for (
const auto& module : platform.modules)
352 for (
const auto& app_p :
module.applications)
354 const auto& app = app_p.second;
355 if (app.name ==
"gobyd" && collapsed(app) && !used_.count(&app))
356 folded_.insert(&app);
374 for (
const auto& app_p :
module.applications)
376 if (folded(app_p.second))
377 return name + " (gobyd)";
386 return filter_.is_included(c);
392 !goby_internal(u) && filter_.is_included(u);
400 (!required || u.
entry.
layer == Layer::INTERTHREAD))
402 if (omit_disconnected_ && !required)
404 return filter_.is_included(u);
412 if (!filter_.is_node_included(name) || !filter_.is_thread_included(app, thread))
416 auto it = used_.find(&app);
417 return it != used_.end() && it->second.count(name);
422 bool goby_internal(
const Unmatched& u)
const
428 bool omit_disconnected_;
429 bool collapse_goby_apps_{
false};
430 std::map<const Application*, std::set<std::string>> used_;
431 std::set<const Application*> folded_;
goby::util::logger::GroupSetter group(std::string n)
The global namespace for the Goby project.
One publication or subscription as written to (and read from) an interface file.
goby::middleware::Necessity necessity