Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions phlex/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace phlex {
{
using detail::value_decorate_exception;
auto query_object = jv.as_object();
return product_query{.spec = {value_decorate_exception<std::string>(query_object, "product")},
.layer = value_decorate_exception<std::string>(query_object, "layer")};
return product_query{{value_decorate_exception<std::string>(query_object, "product")},
value_decorate_exception<std::string>(query_object, "layer")};
}
}
2 changes: 1 addition & 1 deletion phlex/core/declared_provider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace phlex::experimental {
AlgorithmBits alg,
product_query output) :
declared_provider{std::move(name), output},
output_{output.spec},
output_{output.spec()},
provider_{
g, concurrency, [this, ft = alg.release_algorithm()](message const& msg, auto& output) {
auto& [stay_in_graph, to_output] = output;
Expand Down
14 changes: 8 additions & 6 deletions phlex/core/detail/filter_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
#include <string>

namespace {
phlex::product_query const output_dummy{phlex::experimental::product_specification{
phlex::experimental::algorithm_name{"for_output_only", ""},
"for_output_only",
phlex::experimental::type_id{}}};
std::vector<phlex::product_query> const for_output_only{output_dummy};
phlex::product_query const output_dummy{
phlex::experimental::product_specification{
phlex::experimental::algorithm_name{"for_output_only", ""},
"for_output_only",
phlex::experimental::type_id{}},
"dummy_layer"};
phlex::product_queries const for_output_only{output_dummy};
}

namespace phlex::experimental {
Expand Down Expand Up @@ -78,7 +80,7 @@ namespace phlex::experimental {

// Fill slots in the order of the input arguments to the downstream node.
for (std::size_t i = 0; i != nargs_; ++i) {
if (elem[i] or not store->contains_product((*product_names_)[i].spec.full()))
if (elem[i] or not store->contains_product((*product_names_)[i].spec().full()))
continue;
elem[i] = store;
}
Expand Down
2 changes: 1 addition & 1 deletion phlex/core/edge_creation_policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace phlex::experimental {
edge_creation_policy::named_output_port const* edge_creation_policy::find_producer(
product_query const& query) const
{
auto const& spec = query.spec;
auto const& spec = query.spec();
auto [b, e] = producers_.equal_range(spec.name());
if (b == e) {
spdlog::debug(
Expand Down
2 changes: 1 addition & 1 deletion phlex/core/input_arguments.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace phlex::experimental {
auto retrieve(auto const& messages) const
{
return std::get<JoinNodePort>(messages).store->template get_handle<handle_arg_t>(
query.spec.name());
query.spec().name());
}
};

Expand Down
2 changes: 1 addition & 1 deletion phlex/core/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
auto const [b, e] = std::tuple{cbegin(product_labels), cend(product_labels)};
auto it = std::find(b, e, product_label);
if (it == e) {
throw std::runtime_error("Algorithm does not accept product '" + product_label.spec.name() +
throw std::runtime_error("Algorithm does not accept product '" + product_label.spec().name() +

Check warning on line 29 in phlex/core/message.cpp

View check run for this annotation

Codecov / codecov/patch

phlex/core/message.cpp#L29

Added line #L29 was not covered by tests
"'.");
}
return std::distance(b, it);
Expand Down
2 changes: 1 addition & 1 deletion phlex/core/multiplexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace phlex::experimental {
auto start_time = steady_clock::now();

for (auto const& [product_label, port] : provider_input_ports_ | std::views::values) {
if (auto store_to_send = store_for(store, product_label.layer)) {
if (auto store_to_send = store_for(store, product_label.layer())) {
port->try_put({std::move(store_to_send), eom, message_id});
}
}
Expand Down
39 changes: 12 additions & 27 deletions phlex/core/product_query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,30 @@

#include "fmt/format.h"

#include <ostream>
#include <stdexcept>
#include <tuple>

namespace phlex::experimental {
product_query product_tag::operator()(std::string data_layer) &&
namespace phlex {
product_query::product_query() = default;

product_query::product_query(experimental::product_specification spec, std::string layer) :
spec_{std::move(spec)}, layer_{std::move(layer)}
{
}

product_query experimental::product_tag::operator()(std::string data_layer) &&
{
if (data_layer.empty()) {
throw std::runtime_error("Cannot specify the empty string as a data layer.");
}
return {std::move(spec), std::move(data_layer)};
}

std::ostream& operator<<(std::ostream& os, product_query const& query)
{
os << query.to_string();
return os;
}
}

namespace phlex {
std::string product_query::to_string() const
{
if (layer.empty()) {
return spec.full();
if (layer_.empty()) {
return spec_.full();

Check warning on line 26 in phlex/core/product_query.cpp

View check run for this annotation

Codecov / codecov/patch

phlex/core/product_query.cpp#L26

Added line #L26 was not covered by tests
}
return fmt::format("{} ϵ {}", spec.full(), layer);
}

bool operator==(product_query const& a, product_query const& b)
{
return std::tie(a.spec, a.layer) == std::tie(b.spec, b.layer);
}

bool operator!=(product_query const& a, product_query const& b) { return !(a == b); }

bool operator<(product_query const& a, product_query const& b)
{
return std::tie(a.spec, a.layer) < std::tie(b.spec, b.layer);
return fmt::format("{} ϵ {}", spec_.full(), layer_);
}

experimental::product_tag operator""_in(char const* product_name, std::size_t length)
Expand Down
32 changes: 19 additions & 13 deletions phlex/core/product_query.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,30 @@

#include "phlex/model/product_specification.hpp"

#include <algorithm>
#include <array>
#include <iosfwd>
// #include <algorithm>
#include <string>
#include <vector>

namespace phlex {
struct product_query {
experimental::product_specification spec;
std::string layer;
class product_query {
public:
// FIXME: Boost JSON's parameter retrieval facilities require a default constructor
// whenever the type is (e.g.) std::array<product_query, N>.
product_query();
product_query(experimental::product_specification spec, std::string layer);

auto const& spec() const noexcept { return spec_; }
auto const& layer() const noexcept { return layer_; }
void set_type(experimental::type_id&& type) { spec_.set_type(std::move(type)); }

std::string to_string() const;
};

bool operator==(product_query const& a, product_query const& b);
bool operator!=(product_query const& a, product_query const& b);
bool operator<(product_query const& a, product_query const& b);
auto operator<=>(product_query const&) const = default;

private:
experimental::product_specification spec_;
std::string layer_;
};

using product_queries = std::vector<product_query>;
}
Expand All @@ -29,8 +37,6 @@ namespace phlex::experimental {
product_query operator()(std::string layer) &&;
};

std::ostream& operator<<(std::ostream& os, product_query const& query);

namespace detail {
// C is a container of product_queries
template <typename C, typename T>
Expand All @@ -45,7 +51,7 @@ namespace phlex::experimental {
template <typename T>
void set_type(C& container)
{
container.at(index_).spec.set_type(make_type_id<T>());
container.at(index_).set_type(make_type_id<T>());
++index_;
}

Expand Down
2 changes: 1 addition & 1 deletion phlex/core/registration_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ namespace phlex::experimental {
using return_type = return_type<typename AlgorithmBits::algorithm_type>;
using provider_type = provider_node<AlgorithmBits>;

output.spec.set_type(make_type_id<return_type>());
output.set_type(make_type_id<return_type>());

registrar_.set_creator(
[this, output = std::move(output)](auto /* predicates */, auto /* output_products */) {
Expand Down
14 changes: 0 additions & 14 deletions phlex/model/algorithm_name.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,6 @@ namespace phlex::experimental {
return false;
}

auto algorithm_name::cmp_tuple() const { return std::tie(plugin_, algorithm_, fields_); }

bool algorithm_name::operator==(algorithm_name const& other) const
{
return cmp_tuple() == other.cmp_tuple();
}

bool algorithm_name::operator!=(algorithm_name const& other) const { return !operator==(other); }

bool algorithm_name::operator<(algorithm_name const& other) const
{
return cmp_tuple() < other.cmp_tuple();
}

algorithm_name algorithm_name::create(char const* spec) { return create(std::string{spec}); }
algorithm_name algorithm_name::create(std::string const& spec)
{
Expand Down
4 changes: 1 addition & 3 deletions phlex/model/algorithm_name.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ namespace phlex::experimental {
std::string const& algorithm() const noexcept { return algorithm_; }

bool match(algorithm_name const& other) const;
bool operator==(algorithm_name const& other) const;
bool operator!=(algorithm_name const& other) const;
bool operator<(algorithm_name const& other) const;
auto operator<=>(algorithm_name const&) const = default;

static algorithm_name create(char const* spec);
static algorithm_name create(std::string const& spec);
Expand Down
17 changes: 0 additions & 17 deletions phlex/model/product_specification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,6 @@ namespace phlex::experimental {
return qualifier + "/" + name_;
}

bool product_specification::operator==(product_specification const& other) const
{
return std::tie(qualifier_, name_, type_id_) ==
std::tie(other.qualifier_, other.name_, other.type_id_);
}

bool product_specification::operator!=(product_specification const& other) const
{
return !operator==(other);
}

bool product_specification::operator<(product_specification const& other) const
{
return std::tie(qualifier_, name_, type_id_) <
std::tie(other.qualifier_, other.name_, type_id_);
}

product_specification product_specification::create(char const* c)
{
return create(std::string{c});
Expand Down
4 changes: 1 addition & 3 deletions phlex/model/product_specification.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ namespace phlex::experimental {

void set_type(type_id&& type) { type_id_ = std::move(type); }

bool operator==(product_specification const& other) const;
bool operator!=(product_specification const& other) const;
bool operator<(product_specification const& other) const;
auto operator<=>(product_specification const&) const = default;

static product_specification create(char const* c);
static product_specification create(std::string const& s);
Expand Down
Loading