24#ifndef GOBY_MIDDLEWARE_TOOL_INTERFACE_PUBSUB_ENTRY_H
25#define GOBY_MIDDLEWARE_TOOL_INTERFACE_PUBSUB_ENTRY_H
32#include <yaml-cpp/yaml.h>
95 else if (s ==
"recommended")
116 auto thread_node = yaml[
"thread"];
117 thread = thread_node ? thread_node.as<std::string>() : th;
119 group = yaml[
"group"].as<std::string>();
120 scheme = yaml[
"scheme"].as<std::string>();
121 type = yaml[
"type"].as<std::string>();
126 auto inner_node = yaml[
"inner"];
129 auto is_regex_node = yaml[
"is_regex"];
130 is_regex = is_regex_node && is_regex_node.as<
bool>();
132 auto dynamic_node = yaml[
"dynamic"];
133 dynamic = dynamic_node && dynamic_node.as<
bool>();
134 auto numeric_node = yaml[
"numeric"];
135 numeric_runtime = numeric_node && numeric_node.as<std::string>() ==
"runtime";
136 if (
auto expr_node = yaml[
"expr"])
137 expr = expr_node.as<std::string>();
195 void write_yaml_map(YAML::Emitter& yaml_out,
bool include_thread =
true,
bool inner_pub =
false,
196 bool include_necessity =
true)
const
202 if (include_necessity)
207 entry_map.
add(
"inner",
"true");
209 entry_map.
add(
"is_regex",
"true");
211 entry_map.
add(
"dynamic",
"true");
213 entry_map.
add(
"numeric",
"runtime");
223 for (
auto it = values.begin(); it != values.end();)
225 auto first = *it, last = *it;
226 for (++it; it != values.end() && *it == last + 1; ++it) last = *it;
229 out += std::to_string(first);
231 out +=
"-" + std::to_string(last);
277 if (e.numeric_runtime)
282 key.values = e.bound_numerics;
286 auto semicolon = e.group.rfind(
';');
287 if (semicolon == std::string::npos)
292 key.name = e.group.substr(0, semicolon);
293 auto numeric = e.group.substr(semicolon + 1);
294 if (!numeric.empty() && numeric.find_first_not_of(
"0123456789") == std::string::npos)
297 key.values.insert(std::stoul(numeric));
317 if (ka.name != kb.name)
320 if (ka.numeric == Numeric::NONE || kb.numeric == Numeric::NONE)
322 if (ka.numeric == Numeric::RUNTIME || kb.numeric == Numeric::RUNTIME)
324 if (ka.numeric == Numeric::TEXT || kb.numeric == Numeric::TEXT)
327 for (
auto v : ka.values)
329 if (kb.values.count(v))
335inline std::ostream& operator<<(std::ostream& os,
const PubSubEntry& e)
337 return os <<
"layer: " <<
static_cast<int>(e.layer) <<
", thread: " << e.thread
338 <<
", group: " << e.group <<
", scheme: " << e.scheme <<
", type: " << e.type;
372 (a.
type ==
"mavlink::__mavlink_message" || b.
type ==
"mavlink::__mavlink_message"))
detail namespace with internal helper functions
Necessity
Used to tag subscriptions based on their necessity (e.g. required for correct functioning,...
The global namespace for the Goby project.
One publication or subscription as written to (and read from) an interface file.
bool necessity_overridden
std::string publish_index_str() const
std::string display_group() const
The group as a deployment sees it, with any bound numeric values.
bool unresolved() const
A dynamic group whose string goby_clang_tool could not determine.
bool unbound() const
A dynamic group whose numeric part is still unknown.
void write_yaml_map(YAML::Emitter &yaml_out, bool include_thread=true, bool inner_pub=false, bool include_necessity=true) const
PubSubEntry(Layer l, Direction dir, const YAML::Node &yaml, const std::string &th="")
goby::middleware::Necessity necessity
PubSubEntry(Layer l, Direction d, std::string th, std::string g, std::string s, std::string t, bool tk, goby::middleware::Necessity n, bool r)
std::set< std::uint32_t > bound_numerics