From 2874f8a9ff4d637761b0f6d3dda0fae6814546ff Mon Sep 17 00:00:00 2001 From: Chris Green Date: Tue, 18 Nov 2025 09:30:13 -0600 Subject: [PATCH 1/6] Resolve issue with `string_view` to temporary `string` --- phlex/core/declared_unfold.cpp | 4 ++-- phlex/core/declared_unfold.hpp | 4 ++-- phlex/model/product_store.cpp | 38 ++++++++++++++++++++-------------- phlex/model/product_store.hpp | 16 +++++++------- 4 files changed, 34 insertions(+), 28 deletions(-) diff --git a/phlex/core/declared_unfold.cpp b/phlex/core/declared_unfold.cpp index 298ea7ce..615ace95 100644 --- a/phlex/core/declared_unfold.cpp +++ b/phlex/core/declared_unfold.cpp @@ -8,10 +8,10 @@ namespace phlex::experimental { generator::generator(product_store_const_ptr const& parent, - std::string const& node_name, + std::string node_name, std::string const& new_level_name) : parent_{std::const_pointer_cast(parent)}, - node_name_{node_name}, + node_name_{std::move(node_name)}, new_level_name_{new_level_name} { } diff --git a/phlex/core/declared_unfold.hpp b/phlex/core/declared_unfold.hpp index 201f56ab..7b0477ba 100644 --- a/phlex/core/declared_unfold.hpp +++ b/phlex/core/declared_unfold.hpp @@ -36,7 +36,7 @@ namespace phlex::experimental { class generator { public: explicit generator(product_store_const_ptr const& parent, - std::string const& node_name, + std::string node_name, std::string const& new_level_name); product_store_const_ptr flush_store() const; @@ -48,7 +48,7 @@ namespace phlex::experimental { private: product_store_const_ptr make_child(std::size_t i, products new_products); product_store_ptr parent_; - std::string_view node_name_; + std::string node_name_; std::string const& new_level_name_; std::map child_counts_; }; diff --git a/phlex/model/product_store.cpp b/phlex/model/product_store.cpp index a5be9780..03238bde 100644 --- a/phlex/model/product_store.cpp +++ b/phlex/model/product_store.cpp @@ -8,13 +8,13 @@ namespace phlex::experimental { product_store::product_store(product_store_const_ptr parent, level_id_ptr id, - std::string_view source, + std::string source, stage processing_stage, products new_products) : parent_{std::move(parent)}, products_{std::move(new_products)}, id_{std::move(id)}, - source_{source}, + source_{std::move(source)}, stage_{processing_stage} { } @@ -22,12 +22,12 @@ namespace phlex::experimental { product_store::product_store(product_store_const_ptr parent, std::size_t new_level_number, std::string const& new_level_name, - std::string_view source, + std::string source, products new_products) : parent_{parent}, products_{std::move(new_products)}, id_{parent->id()->make_child(new_level_number, new_level_name)}, - source_{source}, + source_{std::move(source)}, stage_{stage::process} { } @@ -35,11 +35,11 @@ namespace phlex::experimental { product_store::product_store(product_store_const_ptr parent, std::size_t new_level_number, std::string const& new_level_name, - std::string_view source, + std::string source, stage processing_stage) : parent_{parent}, id_{parent->id()->make_child(new_level_number, new_level_name)}, - source_{source}, + source_{std::move(source)}, stage_{processing_stage} { } @@ -77,33 +77,39 @@ namespace phlex::experimental { return product_store_ptr{new product_store{parent_, id_, "[inserted]", stage::flush}}; } - product_store_ptr product_store::make_continuation(std::string_view source, + product_store_ptr product_store::make_continuation(std::string source, products new_products) const { - return product_store_ptr{ - new product_store{parent_, id_, source, stage::process, std::move(new_products)}}; + return product_store_ptr{new product_store{ + parent_, id_, std::move(source), stage::process, std::move(new_products)}}; } product_store_ptr product_store::make_child(std::size_t new_level_number, std::string const& new_level_name, - std::string_view source, + std::string source, products new_products) { - return product_store_ptr{new product_store{ - shared_from_this(), new_level_number, new_level_name, source, std::move(new_products)}}; + return product_store_ptr{new product_store{shared_from_this(), + new_level_number, + new_level_name, + std::move(source), + std::move(new_products)}}; } product_store_ptr product_store::make_child(std::size_t new_level_number, std::string const& new_level_name, - std::string_view source, + std::string source, stage processing_stage) { - return product_store_ptr{new product_store{ - shared_from_this(), new_level_number, new_level_name, source, processing_stage}}; + return product_store_ptr{new product_store{shared_from_this(), + new_level_number, + new_level_name, + std::move(source), + processing_stage}}; } std::string const& product_store::level_name() const noexcept { return id_->level_name(); } - std::string_view product_store::source() const noexcept { return source_; } + std::string const& product_store::source() const noexcept { return source_; } product_store_const_ptr product_store::parent() const noexcept { return parent_; } level_id_ptr const& product_store::id() const noexcept { return id_; } bool product_store::is_flush() const noexcept { return stage_ == stage::flush; } diff --git a/phlex/model/product_store.hpp b/phlex/model/product_store.hpp index 1aed24cc..d00c4724 100644 --- a/phlex/model/product_store.hpp +++ b/phlex/model/product_store.hpp @@ -25,18 +25,18 @@ namespace phlex::experimental { auto end() const noexcept { return products_.end(); } std::string const& level_name() const noexcept; - std::string_view source() const noexcept; // FIXME: Think carefully of using std::string_view + std::string const& source() const noexcept; product_store_const_ptr parent(std::string const& level_name) const noexcept; product_store_const_ptr parent() const noexcept; product_store_ptr make_flush() const; - product_store_ptr make_continuation(std::string_view source, products new_products = {}) const; + product_store_ptr make_continuation(std::string source, products new_products = {}) const; product_store_ptr make_child(std::size_t new_level_number, std::string const& new_level_name, - std::string_view source, + std::string source, products new_products); product_store_ptr make_child(std::size_t new_level_number, std::string const& new_level_name, - std::string_view source = {}, + std::string source = {}, stage st = stage::process); level_id_ptr const& id() const noexcept; bool is_flush() const noexcept; @@ -60,24 +60,24 @@ namespace phlex::experimental { private: explicit product_store(product_store_const_ptr parent = nullptr, level_id_ptr id = level_id::base_ptr(), - std::string_view source = {}, + std::string source = {}, stage processing_stage = stage::process, products new_products = {}); explicit product_store(product_store_const_ptr parent, std::size_t new_level_number, std::string const& new_level_name, - std::string_view source, + std::string source, products new_products); explicit product_store(product_store_const_ptr parent, std::size_t new_level_number, std::string const& new_level_name, - std::string_view source, + std::string source, stage processing_stage); product_store_const_ptr parent_{nullptr}; products products_{}; level_id_ptr id_; - std::string_view source_; + std::string source_; stage stage_; }; From 49cd48856e0bbb68eb85f56aaeba1944be914746 Mon Sep 17 00:00:00 2001 From: Chris Green Date: Tue, 18 Nov 2025 10:32:16 -0600 Subject: [PATCH 2/6] Optional name for base product store (defaults to "Source") --- phlex/model/product_store.cpp | 2 +- phlex/model/product_store.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phlex/model/product_store.cpp b/phlex/model/product_store.cpp index 03238bde..715d792f 100644 --- a/phlex/model/product_store.cpp +++ b/phlex/model/product_store.cpp @@ -46,7 +46,7 @@ namespace phlex::experimental { product_store::~product_store() = default; - product_store_ptr product_store::base() { return product_store_ptr{new product_store}; } + product_store_ptr product_store::base(std::string base_name) { return product_store_ptr{new product_store{nullptr, level_id::base_ptr(), std::move(base_name)}}; } product_store_const_ptr product_store::parent(std::string const& level_name) const noexcept { diff --git a/phlex/model/product_store.hpp b/phlex/model/product_store.hpp index d00c4724..5c215479 100644 --- a/phlex/model/product_store.hpp +++ b/phlex/model/product_store.hpp @@ -17,7 +17,7 @@ namespace phlex::experimental { class product_store : public std::enable_shared_from_this { public: ~product_store(); - static product_store_ptr base(); + static product_store_ptr base(std::string base_name="Source"); product_store_const_ptr store_for_product(std::string const& product_name) const; From 3048ee1d74601b7e2275108bd713af877b47436e Mon Sep 17 00:00:00 2001 From: Chris Green Date: Tue, 18 Nov 2025 10:32:47 -0600 Subject: [PATCH 3/6] Provide a source name for the product store --- test/hierarchical_nodes.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/hierarchical_nodes.cpp b/test/hierarchical_nodes.cpp index c72d81e1..588d618b 100644 --- a/test/hierarchical_nodes.cpp +++ b/test/hierarchical_nodes.cpp @@ -43,11 +43,11 @@ namespace { auto job_store = product_store::base(); driver.yield(job_store); for (unsigned i : std::views::iota(0u, index_limit)) { - auto run_store = job_store->make_child(i, "run"); + auto run_store = job_store->make_child(i, "run", "levels_to_process"); run_store->add_product("time", std::time(nullptr)); driver.yield(run_store); for (unsigned j : std::views::iota(0u, number_limit)) { - auto event_store = run_store->make_child(j, "event"); + auto event_store = run_store->make_child(j, "event", "levels_to_process"); event_store->add_product("number", i + j); driver.yield(event_store); } From 6b3257ea43619b50f8ef2f2409cfe38e990ef558 Mon Sep 17 00:00:00 2001 From: Chris Green Date: Wed, 19 Nov 2025 08:21:40 -0600 Subject: [PATCH 4/6] Add comment per @knoepfel See https://github.com/Framework-R-D/phlex/pull/121#discussion_r2539830139 Co-authored-by: Kyle Knoepfel Committing clang-format changes --- phlex/model/product_store.cpp | 17 +++++++++-------- phlex/model/product_store.hpp | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/phlex/model/product_store.cpp b/phlex/model/product_store.cpp index 715d792f..22823a49 100644 --- a/phlex/model/product_store.cpp +++ b/phlex/model/product_store.cpp @@ -46,7 +46,11 @@ namespace phlex::experimental { product_store::~product_store() = default; - product_store_ptr product_store::base(std::string base_name) { return product_store_ptr{new product_store{nullptr, level_id::base_ptr(), std::move(base_name)}}; } + product_store_ptr product_store::base(std::string base_name) + { + return product_store_ptr{ + new product_store{nullptr, level_id::base_ptr(), std::move(base_name)}}; + } product_store_const_ptr product_store::parent(std::string const& level_name) const noexcept { @@ -80,8 +84,8 @@ namespace phlex::experimental { product_store_ptr product_store::make_continuation(std::string source, products new_products) const { - return product_store_ptr{new product_store{ - parent_, id_, std::move(source), stage::process, std::move(new_products)}}; + return product_store_ptr{ + new product_store{parent_, id_, std::move(source), stage::process, std::move(new_products)}}; } product_store_ptr product_store::make_child(std::size_t new_level_number, @@ -101,11 +105,8 @@ namespace phlex::experimental { std::string source, stage processing_stage) { - return product_store_ptr{new product_store{shared_from_this(), - new_level_number, - new_level_name, - std::move(source), - processing_stage}}; + return product_store_ptr{new product_store{ + shared_from_this(), new_level_number, new_level_name, std::move(source), processing_stage}}; } std::string const& product_store::level_name() const noexcept { return id_->level_name(); } diff --git a/phlex/model/product_store.hpp b/phlex/model/product_store.hpp index 5c215479..3683c917 100644 --- a/phlex/model/product_store.hpp +++ b/phlex/model/product_store.hpp @@ -17,7 +17,7 @@ namespace phlex::experimental { class product_store : public std::enable_shared_from_this { public: ~product_store(); - static product_store_ptr base(std::string base_name="Source"); + static product_store_ptr base(std::string base_name = "Source"); product_store_const_ptr store_for_product(std::string const& product_name) const; @@ -77,7 +77,7 @@ namespace phlex::experimental { product_store_const_ptr parent_{nullptr}; products products_{}; level_id_ptr id_; - std::string source_; + std::string source_; // FIXME: Should not have to copy the string (the source should outlive the product store) stage stage_; }; From e4babca534053f12b51ec5e05f6a3dfa2cbe8a66 Mon Sep 17 00:00:00 2001 From: Chris Green Date: Wed, 19 Nov 2025 14:28:43 +0000 Subject: [PATCH 5/6] Remove unneeded default args per @knoepfel - See https://github.com/Framework-R-D/phlex/pull/121#discussion_r2539835220 --- phlex/model/product_store.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phlex/model/product_store.hpp b/phlex/model/product_store.hpp index 3683c917..2eced430 100644 --- a/phlex/model/product_store.hpp +++ b/phlex/model/product_store.hpp @@ -58,9 +58,9 @@ namespace phlex::experimental { void add_product(std::string const& key, std::unique_ptr>&& t); private: - explicit product_store(product_store_const_ptr parent = nullptr, - level_id_ptr id = level_id::base_ptr(), - std::string source = {}, + explicit product_store(product_store_const_ptr parent, + level_id_ptr id, + std::string source, stage processing_stage = stage::process, products new_products = {}); explicit product_store(product_store_const_ptr parent, From c30a3b99bdcb777c31258cbaa64932b12618646d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 19 Nov 2025 14:58:43 +0000 Subject: [PATCH 6/6] Committing clang-format changes --- phlex/model/product_store.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phlex/model/product_store.hpp b/phlex/model/product_store.hpp index 2eced430..c0060902 100644 --- a/phlex/model/product_store.hpp +++ b/phlex/model/product_store.hpp @@ -77,7 +77,8 @@ namespace phlex::experimental { product_store_const_ptr parent_{nullptr}; products products_{}; level_id_ptr id_; - std::string source_; // FIXME: Should not have to copy the string (the source should outlive the product store) + std::string + source_; // FIXME: Should not have to copy the string (the source should outlive the product store) stage stage_; };