From 420856eb4af224723eb3c5be788fba17e90bc58f Mon Sep 17 00:00:00 2001 From: iopapamanoglou Date: Fri, 8 Nov 2024 13:54:14 +0100 Subject: [PATCH] fix compile errors --- src/faebryk/core/cpp/__init__.pyi | 4 +-- .../core/cpp/include/pathfinder/bfs.hpp | 6 ++-- src/faebryk/core/cpp/include/util.hpp | 34 +++++++++---------- src/faebryk/core/cpp/src/pathfinder/bfs.cpp | 10 +++--- .../core/cpp/src/pathfinder/pathfinder.cpp | 4 +-- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/faebryk/core/cpp/__init__.pyi b/src/faebryk/core/cpp/__init__.pyi index a4ec03f4..40d406c8 100644 --- a/src/faebryk/core/cpp/__init__.pyi +++ b/src/faebryk/core/cpp/__init__.pyi @@ -85,10 +85,10 @@ class LinkDirect(Link): class LinkDirectConditional(LinkDirect): def __init__( self, - arg: Callable[ + filter: Callable[ [GraphInterface, GraphInterface], LinkDirectConditionalFilterResult ], - /, + needs_only_first_in_path: bool = False, ) -> None: ... class LinkDirectConditionalFilterResult(enum.Enum): diff --git a/src/faebryk/core/cpp/include/pathfinder/bfs.hpp b/src/faebryk/core/cpp/include/pathfinder/bfs.hpp index ab86328d..256dfe11 100644 --- a/src/faebryk/core/cpp/include/pathfinder/bfs.hpp +++ b/src/faebryk/core/cpp/include/pathfinder/bfs.hpp @@ -56,8 +56,8 @@ class BFSPath { bool stop = false; BFSPath(/*const*/ GI_ref_weak path_head); - BFSPath(/*const*/ BFSPath &other); - BFSPath(/*const*/ BFSPath &other, /*const*/ GI_ref_weak new_head); + BFSPath(const BFSPath &other); + BFSPath(const BFSPath &other, /*const*/ GI_ref_weak new_head); BFSPath(BFSPath &&other); PathData &get_path_data_mut(); @@ -77,4 +77,4 @@ class BFSPath { size_t index(/*const*/ GI_ref_weak gif) /*const*/; }; -void bfs_visit(/*const*/ GI_ref_weak root, std::function visitor); +void bfs_visit(/*const*/ GI_ref_weak root, std::function visitor); diff --git a/src/faebryk/core/cpp/include/util.hpp b/src/faebryk/core/cpp/include/util.hpp index ae4fa79d..2665013d 100644 --- a/src/faebryk/core/cpp/include/util.hpp +++ b/src/faebryk/core/cpp/include/util.hpp @@ -22,22 +22,22 @@ template std::string get_type_name(const std::shared_ptr &obj) { } // TODO not really used -template inline std::string str_vec(const std::vector &vec) { - std::stringstream ss; - ss << "["; - for (size_t i = 0; i < vec.size(); ++i) { - // if T is string just put it into stream directly - if constexpr (std::is_same_v) { - ss << '"' << vec[i] << '"'; - } else { - ss << vec[i].str(); - } - if (i < vec.size() - 1) { - ss << ", "; - } - } - ss << "]"; - return ss.str(); -} +// template inline std::string str_vec(const std::vector &vec) { +// std::stringstream ss; +// ss << "["; +// for (size_t i = 0; i < vec.size(); ++i) { +// // if T is string just put it into stream directly +// if constexpr (std::is_same_v) { +// ss << '"' << vec[i] << '"'; +// } else { +// ss << vec[i].str(); +// } +// if (i < vec.size() - 1) { +// ss << ", "; +// } +// } +// ss << "]"; +// return ss.str(); +//} } // namespace util diff --git a/src/faebryk/core/cpp/src/pathfinder/bfs.cpp b/src/faebryk/core/cpp/src/pathfinder/bfs.cpp index 9f7d1019..20d3fef4 100644 --- a/src/faebryk/core/cpp/src/pathfinder/bfs.cpp +++ b/src/faebryk/core/cpp/src/pathfinder/bfs.cpp @@ -38,7 +38,7 @@ BFSPath::BFSPath(/*const*/ GI_ref_weak path_head) , path_data(std::make_shared()) { } -BFSPath::BFSPath(/*const*/ BFSPath &other) +BFSPath::BFSPath(const BFSPath &other) : path(other.path) , path_data(std::make_shared(*other.path_data)) , confidence(other.confidence) @@ -46,7 +46,7 @@ BFSPath::BFSPath(/*const*/ BFSPath &other) , stop(other.stop) { } -BFSPath::BFSPath(/*const*/ BFSPath &other, /*const*/ GI_ref_weak new_head) +BFSPath::BFSPath(const BFSPath &other, /*const*/ GI_ref_weak new_head) : path(other.path) , path_data(other.path_data) , confidence(other.confidence) @@ -141,7 +141,7 @@ size_t BFSPath::index(/*const*/ GI_ref_weak gif) /*const*/ { return std::distance(path.begin(), std::find(path.begin(), path.end(), gif)); } -void bfs_visit(/*const*/ GI_ref_weak root, std::function visitor) { +void bfs_visit(/*const*/ GI_ref_weak root, std::function visitor) { PerfCounterAccumulating pc, pc_search, pc_set_insert, pc_setup, pc_deque_insert, pc_edges, pc_check_visited, pc_filter, pc_new_path; pc_set_insert.pause(); @@ -157,7 +157,7 @@ void bfs_visit(/*const*/ GI_ref_weak root, std::function visito std::vector visited_weak(node_count, false); std::deque open_path_queue; - auto handle_path = [&](BFSPath &path) { + auto handle_path = [&](BFSPath path) { pc.pause(); pc_filter.resume(); visitor(path); @@ -214,7 +214,7 @@ void bfs_visit(/*const*/ GI_ref_weak root, std::function visito auto new_path = path + neighbour; pc_new_path.pause(); pc_search.pause(); - handle_path(new_path); + handle_path(std::move(new_path)); pc_search.resume(); } } diff --git a/src/faebryk/core/cpp/src/pathfinder/pathfinder.cpp b/src/faebryk/core/cpp/src/pathfinder/pathfinder.cpp index 1cb39cab..71fa2dcb 100644 --- a/src/faebryk/core/cpp/src/pathfinder/pathfinder.cpp +++ b/src/faebryk/core/cpp/src/pathfinder/pathfinder.cpp @@ -126,7 +126,7 @@ PathFinder::find_paths(Node_ref src, std::vector dst) { PerfCounter pc_bfs; - bfs_visit(src->get_self_gif().get(), [&](BFSPath &p) { + bfs_visit(src->get_self_gif().get(), [&](BFSPath p) { bool res = total_counter.exec(this, &PathFinder::run_filters, p); if (!res) { return; @@ -139,7 +139,7 @@ PathFinder::find_paths(Node_ref src, std::vector dst) { p.stop = true; } } - paths.push_back(p); + paths.push_back(std::move(p)); }); printf("TIME: %3.2lf ms BFS\n", pc_bfs.ms());