Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
fix compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
iopapamanoglou committed Nov 8, 2024
1 parent 2bed4d6 commit 420856e
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/faebryk/core/cpp/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions src/faebryk/core/cpp/include/pathfinder/bfs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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<void(BFSPath &)> visitor);
void bfs_visit(/*const*/ GI_ref_weak root, std::function<void(BFSPath)> visitor);
34 changes: 17 additions & 17 deletions src/faebryk/core/cpp/include/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ template <typename T> std::string get_type_name(const std::shared_ptr<T> &obj) {
}

// TODO not really used
template <typename T> inline std::string str_vec(const std::vector<T> &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<T, std::string>) {
ss << '"' << vec[i] << '"';
} else {
ss << vec[i].str();
}
if (i < vec.size() - 1) {
ss << ", ";
}
}
ss << "]";
return ss.str();
}
// template <typename T> inline std::string str_vec(const std::vector<T> &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<T, std::string>) {
// ss << '"' << vec[i] << '"';
// } else {
// ss << vec[i].str();
// }
// if (i < vec.size() - 1) {
// ss << ", ";
// }
// }
// ss << "]";
// return ss.str();
//}

} // namespace util
10 changes: 5 additions & 5 deletions src/faebryk/core/cpp/src/pathfinder/bfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ BFSPath::BFSPath(/*const*/ GI_ref_weak path_head)
, path_data(std::make_shared<PathData>()) {
}

BFSPath::BFSPath(/*const*/ BFSPath &other)
BFSPath::BFSPath(const BFSPath &other)
: path(other.path)
, path_data(std::make_shared<PathData>(*other.path_data))
, confidence(other.confidence)
, filtered(other.filtered)
, 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)
Expand Down Expand Up @@ -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<void(BFSPath &)> visitor) {
void bfs_visit(/*const*/ GI_ref_weak root, std::function<void(BFSPath)> 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();
Expand All @@ -157,7 +157,7 @@ void bfs_visit(/*const*/ GI_ref_weak root, std::function<void(BFSPath &)> visito
std::vector<bool> visited_weak(node_count, false);
std::deque<BFSPath> open_path_queue;

auto handle_path = [&](BFSPath &path) {
auto handle_path = [&](BFSPath path) {
pc.pause();
pc_filter.resume();
visitor(path);
Expand Down Expand Up @@ -214,7 +214,7 @@ void bfs_visit(/*const*/ GI_ref_weak root, std::function<void(BFSPath &)> 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();
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/faebryk/core/cpp/src/pathfinder/pathfinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ PathFinder::find_paths(Node_ref src, std::vector<Node_ref> 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;
Expand All @@ -139,7 +139,7 @@ PathFinder::find_paths(Node_ref src, std::vector<Node_ref> dst) {
p.stop = true;
}
}
paths.push_back(p);
paths.push_back(std::move(p));
});

printf("TIME: %3.2lf ms BFS\n", pc_bfs.ms());
Expand Down

0 comments on commit 420856e

Please sign in to comment.