diff --git a/api/dsr_api.cpp b/api/dsr_api.cpp index 6baad43..002103c 100644 --- a/api/dsr_api.cpp +++ b/api/dsr_api.cpp @@ -432,6 +432,22 @@ std::vector DSRGraph::get_nodes_by_type(const std::string &type) return nodes_; } +std::vector DSRGraph::get_nodes() +{ + std::shared_lock lock(_mutex); + + std::vector nodes_; + nodes_.reserve(nodes.size()); + + for (auto &[id, N]: nodes) + { + nodes_.emplace_back(N.read_reg()); + } + return nodes_; + +} + + std::vector DSRGraph::get_nodes_by_types(const std::vector &types) { std::shared_lock lock(_mutex); diff --git a/api/include/dsr/api/dsr_api.h b/api/include/dsr/api/dsr_api.h index 2a99ec4..92ce363 100644 --- a/api/include/dsr/api/dsr_api.h +++ b/api/include/dsr/api/dsr_api.h @@ -107,6 +107,7 @@ namespace DSR std::optional get_node_root() { return get_node("root"); }; std::vector get_nodes_by_type(const std::string &type); std::vector get_nodes_by_types(const std::vector &types); + std::vector get_nodes(); std::optional get_name_from_id(uint64_t id); std::optional get_id_from_name(const std::string &name); std::optional get_node_level(const Node &n);