diff --git a/phlex/core/CMakeLists.txt b/phlex/core/CMakeLists.txt index f72c5767b..080fc6f53 100644 --- a/phlex/core/CMakeLists.txt +++ b/phlex/core/CMakeLists.txt @@ -41,8 +41,7 @@ cet_make_library( spdlog::spdlog ) install( - FILES cached_product_stores.hpp - concepts.hpp + FILES concepts.hpp consumer.hpp declared_fold.hpp declared_observer.hpp diff --git a/phlex/core/cached_product_stores.hpp b/phlex/core/cached_product_stores.hpp deleted file mode 100644 index 706279e69..000000000 --- a/phlex/core/cached_product_stores.hpp +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef PHLEX_CORE_CACHED_PRODUCT_STORES_HPP -#define PHLEX_CORE_CACHED_PRODUCT_STORES_HPP - -// FIXME: only intended to be used in a single-threaded context as std::map is not -// thread-safe. - -#include "phlex/model/data_cell_index.hpp" -#include "phlex/model/fwd.hpp" -#include "phlex/model/product_store.hpp" - -namespace phlex::experimental { - - class cached_product_stores { - public: - product_store_ptr get_store(data_cell_index_ptr id = data_cell_index::base_ptr()) - { - auto it = product_stores_.find(id->hash()); - if (it != cend(product_stores_)) { - return it->second; - } - if (id == data_cell_index::base_ptr()) { - return new_store(product_store::base()); - } - return new_store( - get_store(id->parent()) - ->make_child(id->number(), id->layer_name(), source_name_, stage::process)); - } - - private: - product_store_ptr new_store(product_store_ptr const& store) - { - return product_stores_.try_emplace(store->id()->hash(), store).first->second; - } - - std::string const source_name_{"Source"}; - std::map product_stores_{}; - }; - -} - -#endif // PHLEX_CORE_CACHED_PRODUCT_STORES_HPP diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 028fb8c07..83533721f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -42,9 +42,6 @@ cet_test( phlex::core Boost::json ) -cet_test(cached_product_stores USE_CATCH2_MAIN SOURCE cached_product_stores.cpp - LIBRARIES phlex::core - ) cet_test( class_registration USE_CATCH2_MAIN diff --git a/test/cached_product_stores.cpp b/test/cached_product_stores.cpp deleted file mode 100644 index 0ba7710b3..000000000 --- a/test/cached_product_stores.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include "phlex/core/cached_product_stores.hpp" -#include "phlex/model/data_cell_index.hpp" -#include "phlex/model/product_store.hpp" - -#include "catch2/catch_test_macros.hpp" - -using namespace phlex::experimental; - -TEST_CASE("Cached product stores", "[data model]") -{ - cached_product_stores stores{}; - SECTION("Root store") - { - auto store = stores.get_store(); - REQUIRE(store); - CHECK(store->id() == data_cell_index::base_ptr()); - } - SECTION("One layer down") - { - auto store = stores.get_store("1"_id); - REQUIRE(store); - CHECK(*store->id() == *"1"_id); - REQUIRE(store->parent()); - CHECK(store->parent()->id() == data_cell_index::base_ptr()); - } - SECTION("One layer down, multiple instances") - { - auto store1 = stores.get_store("1"_id); - auto store2 = stores.get_store("2"_id); - REQUIRE(store1); - REQUIRE(store2); - CHECK(*store1->id() == *"1"_id); - CHECK(*store2->id() == *"2"_id); - // Make sure both stores have the same parent - CHECK(store1->parent() == store2->parent()); - } - SECTION("Multiple layers") - { - auto store1 = stores.get_store("1"_id); - auto store2345 = stores.get_store("2:3:4:5"_id); - REQUIRE(store1); - REQUIRE(store2345); - - CHECK(*store1->id() == *"1"_id); - auto store234 = store2345->parent(); - CHECK(*store234->id() == *"2:3:4"_id); - auto store23 = store234->parent(); - CHECK(*store23->id() == *"2:3"_id); - auto store2 = store23->parent(); - CHECK(*store2->id() == *"2"_id); - - // Make sure both stores have the same parent - CHECK(store2->parent() == store1->parent()); - } -}