-
Notifications
You must be signed in to change notification settings - Fork 15
Add full_product_spec and use that in provider API #501
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| #ifndef PHLEX_MODEL_FULL_PRODUCT_SPEC_HPP | ||
| #define PHLEX_MODEL_FULL_PRODUCT_SPEC_HPP | ||
|
|
||
| #include "phlex/phlex_model_export.hpp" | ||
|
|
||
| #include "phlex/model/identifier.hpp" | ||
| #include "phlex/model/product_specification.hpp" | ||
| #include "phlex/model/type_id.hpp" | ||
|
|
||
| #include "boost/container_hash/hash.hpp" | ||
| #include "fmt/format.h" | ||
|
|
||
| namespace phlex::experimental { | ||
| class PHLEX_MODEL_EXPORT full_product_spec { | ||
| public: | ||
| full_product_spec(product_specification spec, identifier layer, identifier stage) : | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am leery of creating a full product specification when what is constructed is not, in fact, a full specification (the type is not set until later). We did this for I think this means that the provider's m.provide(...)
.output_product(
/* algorithm_name*/ creator,
/* identifier */ suffix,
/* identifier */ layer,
/* identifier, possibly defaulted */ stage
)How these fields are packaged is then an implementation detail.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #602 takes this approach (drafted for now). I'll close this PR. |
||
| spec_{std::move(spec)}, layer_{std::move(layer)}, stage_{std::move(stage)} | ||
| { | ||
| } | ||
|
|
||
| bool operator==(full_product_spec const&) const noexcept = default; | ||
|
|
||
| product_specification const& spec() const noexcept { return spec_; } | ||
| algorithm_name const& creator() const noexcept { return spec_.qualifier(); } | ||
| identifier const& suffix() const noexcept { return spec_.suffix(); } | ||
| type_id type() const noexcept { return spec_.type(); } | ||
| void set_type(type_id&& type) { spec_.set_type(std::move(type)); } | ||
| identifier const& layer() const noexcept { return layer_; } | ||
| identifier const& stage() const noexcept { return stage_; } | ||
| std::size_t hash() const noexcept | ||
| { | ||
| std::size_t result = creator().plugin().hash(); | ||
| boost::hash_combine(result, creator().algorithm().hash()); | ||
| boost::hash_combine(result, suffix().hash()); | ||
| boost::hash_combine(result, layer().hash()); | ||
| boost::hash_combine(result, stage().hash()); | ||
| boost::hash_combine(result, type()); | ||
| return result; | ||
| } | ||
|
|
||
| std::string to_string() const | ||
| { | ||
| return fmt::format( | ||
| "{}:{}/{} ϵ {}", creator().plugin(), creator().algorithm(), suffix(), layer()); | ||
| } | ||
|
|
||
| private: | ||
| product_specification spec_; | ||
| identifier layer_; | ||
| identifier stage_; | ||
| }; | ||
| } | ||
|
|
||
| #endif // PHLEX_MODEL_FULL_PRODUCT_SPEC_HPP | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The deprecation attribute is fine for our users. They decide how to build their own Phlex-dependent code, with or without
-Werrorand-Wno-error=deprecated-declarations.For our own purposes, we'll continue building with
-Werrorand not exclude deprecated declarations. We should convert all tests to use the encouraged API. If we want to test the deprecation, we can add a dedicated compile-only test that verifies the deprecation message. I'm not sure that's necessary, though.