2#include "core/device/vdb/protocol.hpp"
5#include "core/device/vdb/visitor.hpp"
6#include "core/device/vdb/builtins.hpp"
9class RegistryController {
13 using CallbackFn = std::function<void(
const VDP::Channel &)>;
19 RegistryController(AbstractDevice *device);
24 void take_packet(
const Packet &pac);
30 PartPtr get_data(ChannelID
id);
41 ChannelID open_channel(PartPtr &for_data);
47 bool send_data(ChannelID
id);
54 int rec_switch_time = 1000;
57 std::vector<Channel> channels;
58 ChannelID new_channel_id() {
59 ChannelID
id = next_channel_id;
64 int responses_in_queue;
65 bool needs_ack =
false;
67 bool rec_mode =
false;
68 static constexpr size_t ack_ms = 500;
70 AbstractDevice *device;
73 ChannelID next_channel_id = 0;
77 CallbackFn on_broadcast = [&](VDP::Channel chan) {
78 std::string schema_str = chan.data->pretty_print();
80 "VDB-Controller: No Broadcast Callback installed: Received broadcast "
83 int(chan.getID()), schema_str.c_str()
90 CallbackFn on_data = [&](VDP::Channel new_data) {
91 ResponsePacketVisitor RV(new_data.data);
92 PartPtr original_data = channels[new_data.id].data;
93 original_data->Visit(&RV);
94 original_data->response();