diff options
Diffstat (limited to 'daemon/src/config.cpp')
| -rw-r--r-- | daemon/src/config.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/daemon/src/config.cpp b/daemon/src/config.cpp index b711d52..6859571 100644 --- a/daemon/src/config.cpp +++ b/daemon/src/config.cpp @@ -49,7 +49,7 @@ Config_Loader::Config_Loader(std::string url) auto toml_config = toml::parse(m_file_contents); - auto* devices = toml_config["devices"].as_table(); + auto const * devices = toml_config["devices"].as_table(); if (!devices) { std::cerr << "Expected \"devices\" to be a table.\n"; @@ -58,7 +58,19 @@ Config_Loader::Config_Loader(std::string url) for (auto&& [id, name] : *devices) { - m_device_map[name.as_string()->get()] = id.str(); + m_device_map[name.as_string()->get()] = std::make_pair<Device_Id, bool>(std::string{id.str()}, false); + } + + auto const * virtual_devices = toml_config["virtual"].as_table(); + if (!virtual_devices) + { + std::cerr << "Expected \"virtual\" to be a table.\n"; + return; + } + + for (auto && [id, name] : *virtual_devices) + { + m_device_map[name.as_string()->get()] = std::make_pair<Device_Id, bool>(std::string{id.str()}, true); } } @@ -132,8 +144,9 @@ add_type_routes(Device_Map const & device_map, Device_Id const & from_device, Ro std::string to_device = device.as_string()->get(); if (to_device == "all") { - for (auto&& [name, id] : device_map) + for (auto&& [name, details] : device_map) { + Device_Id const & id = details.first; if (id == from_device) continue; if (auto sender = cm.get_sender(id)) { @@ -159,8 +172,9 @@ Config_Loader::compile_route_table(Connection_Manager const & cm) auto toml_config = toml::parse(m_file_contents); - for (auto && [name, id] : m_device_map) + for (auto && [name, details] : m_device_map) { + Device_Id const & id = details.first; auto * to_routes = toml_config["route"]["from"][id]["to"].as_table(); if (to_routes) { |
