Skip to content

Commit 4a0904e

Browse files
committed
Make find_producer take a product_query instead of a specification
This fits better with the new class names, and should make it easier to extend the set of properties on which we match later
1 parent 03b58ff commit 4a0904e

3 files changed

Lines changed: 16 additions & 16 deletions

File tree

phlex/core/edge_creation_policy.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,27 @@
66

77
namespace phlex::experimental {
88
edge_creation_policy::named_output_port const* edge_creation_policy::find_producer(
9-
product_specification const& specified_product_name) const
9+
product_query const& query) const
1010
{
11-
auto [b, e] = producers_.equal_range(specified_product_name.name());
11+
auto const& spec = query.name;
12+
auto [b, e] = producers_.equal_range(spec.name());
1213
if (b == e) {
1314
return nullptr;
1415
}
1516
std::map<std::string, named_output_port const*> candidates;
1617
for (auto const& [key, producer] : std::ranges::subrange{b, e}) {
17-
if (producer.node.match(specified_product_name.qualifier())) {
18-
if (specified_product_name.type() != producer.type) {
18+
if (producer.node.match(spec.qualifier())) {
19+
if (spec.type() != producer.type) {
1920
spdlog::debug("Matched {} from {} but types don't match (`{}` vs `{}`)",
20-
specified_product_name.full(),
21+
spec.full(),
2122
producer.node.full(),
22-
specified_product_name.type(),
23+
spec.type(),
2324
producer.type);
2425
} else {
2526
spdlog::debug("Matched {} from {} and types match (`{}` vs `{}`)",
26-
specified_product_name.full(),
27+
spec.full(),
2728
producer.node.full(),
28-
specified_product_name.type(),
29+
spec.type(),
2930
producer.type);
3031
candidates.emplace(producer.node.full(), &producer);
3132
}
@@ -34,13 +35,12 @@ namespace phlex::experimental {
3435

3536
if (candidates.empty()) {
3637
throw std::runtime_error("Cannot identify product matching the specified label " +
37-
specified_product_name.full());
38+
spec.full());
3839
}
3940

4041
if (candidates.size() > 1ull) {
4142
std::ostringstream msg;
42-
msg << "More than one candidate matches the specified label " << specified_product_name.full()
43-
<< ":";
43+
msg << "More than one candidate matches the specified label " << spec.full() << ":";
4444
for (auto const& key : candidates | std::views::keys) {
4545
msg << "\n - " << key;
4646
}

phlex/core/edge_creation_policy.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace phlex::experimental {
2626
type_id type;
2727
};
2828

29-
named_output_port const* find_producer(product_specification const& product_name) const;
29+
named_output_port const* find_producer(product_query const& query) const;
3030
auto values() const { return producers_ | std::views::values; }
3131

3232
private:

phlex/core/edge_maker.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ namespace phlex::experimental {
5757
collector = &coll_it->second.data_port();
5858
}
5959

60-
for (auto const& product_label : node->input()) {
61-
auto* receiver_port = collector ? collector : &node->port(product_label);
62-
auto producer = producers_.find_producer(product_label.name);
60+
for (auto const& query : node->input()) {
61+
auto* receiver_port = collector ? collector : &node->port(query);
62+
auto producer = producers_.find_producer(query);
6363
if (not producer) {
6464
// Is there a way to detect mis-specified product dependencies?
65-
result[node_name].push_back({product_label, receiver_port});
65+
result[node_name].push_back({query, receiver_port});
6666
continue;
6767
}
6868

0 commit comments

Comments
 (0)