Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix queryable examples #320

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/universal/z_queryable.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ int _main(int argc, char **argv) {
auto on_query = [payload, keyexpr](const Query &query) {
auto params = query.get_parameters();
auto query_payload = query.get_payload();
std::cout << ">> [Queryable ] Received Query '" << keyexpr << "?" << params;
std::cout << ">> [Queryable ] Received Query '" << query.get_keyexpr().as_string_view() << "?" << params;
if (query_payload.has_value()) {
std::cout << "' with value = '" << query_payload->get().as_string();
}
Expand Down
8 changes: 4 additions & 4 deletions examples/zenohc/z_queryable_shm.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ int _main(int argc, char **argv) {
std::cout << "Preparing SHM Provider...\n";
PosixShmProvider provider(MemoryLayout(65536, AllocAlignment({0})));

auto on_query = [provider = std::move(provider), payload](const Query &query) {
auto on_query = [provider = std::move(provider), payload, keyexpr](const Query &query) {
auto query_payload = query.get_payload();

const char *payload_type = "";
Expand All @@ -63,10 +63,9 @@ int _main(int argc, char **argv) {
}
}

const KeyExpr &keyexpr = query.get_keyexpr();
auto params = query.get_parameters();
std::cout << ">> [Queryable ] Received Query [" << payload_type << "] '" << keyexpr.as_string_view() << "?"
<< params;
std::cout << ">> [Queryable ] Received Query [" << payload_type << "] '" << query.get_keyexpr().as_string_view()
<< "?" << params;
if (query_payload.has_value()) {
std::cout << "' value = '" << query_payload->get().as_string();
}
Expand All @@ -77,6 +76,7 @@ int _main(int argc, char **argv) {
ZShmMut &&buf = std::get<ZShmMut>(std::move(alloc_result));
memcpy(buf.data(), payload.data(), len);

std::cout << "[Queryable ] Responding ('" << keyexpr << "': '" << payload << "')\n";
query.reply(keyexpr, std::move(buf));
};

Expand Down
Loading