diff --git a/Framework/Core/CMakeLists.txt b/Framework/Core/CMakeLists.txt index 103b559f642e2..1711a3772a92f 100644 --- a/Framework/Core/CMakeLists.txt +++ b/Framework/Core/CMakeLists.txt @@ -199,6 +199,7 @@ add_executable(o2-test-framework-core test/test_CompletionPolicy.cxx test/test_ComputingResourceHelpers.cxx test/test_ComputingQuotaEvaluator.cxx + test/test_Concepts.cxx test/test_ControlServiceHelpers.cxx test/test_ConfigParamStore.cxx test/test_ConfigParamRegistry.cxx diff --git a/Framework/Core/include/Framework/ASoA.h b/Framework/Core/include/Framework/ASoA.h index cb2ff11a8e901..f21decd0d5c45 100644 --- a/Framework/Core/include/Framework/ASoA.h +++ b/Framework/Core/include/Framework/ASoA.h @@ -175,6 +175,8 @@ consteval auto intersectOriginals() namespace o2::soa { +struct Binding; + template concept not_void = requires { !std::same_as; }; @@ -192,7 +194,10 @@ template concept is_self_index_column = not_void && std::same_as; template -concept is_index_column = !is_self_index_column && (requires { &C::getId; } || requires { &C::getIds; }); +concept is_index_column = !is_self_index_column && requires(C c, o2::soa::Binding b) { + { c.setCurrentRaw(b) } -> std::same_as; + requires std::same_as; +}; template using is_external_index_t = typename std::conditional_t, std::true_type, std::false_type>; diff --git a/Framework/Core/test/test_Concepts.cxx b/Framework/Core/test/test_Concepts.cxx new file mode 100644 index 0000000000000..00ad931828b44 --- /dev/null +++ b/Framework/Core/test/test_Concepts.cxx @@ -0,0 +1,164 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +#include +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/Expressions.h" +#include "Framework/AnalysisHelpers.h" +#include "Framework/AnalysisTask.h" +#include "Framework/Condition.h" +#include "SimulationDataFormat/O2DatabasePDG.h" + +#include + +using namespace o2::framework; +using namespace o2::soa; +using namespace o2; + +struct P { + void process1(aod::Collisions const&) + { + } + + PROCESS_SWITCH(P, process1, "", true); +}; + +TEST_CASE("IdentificationConcepts") +{ + // ASoA + int i; + REQUIRE(not_void); + + REQUIRE(is_persistent_column); + + REQUIRE(is_self_index_column); + + REQUIRE(!is_index_column); + REQUIRE(is_index_column); + REQUIRE(is_index_column); + + REQUIRE(o2::aod::is_aod_hash>); + REQUIRE(o2::aod::is_origin_hash>); + + REQUIRE(has_parent_t); + + REQUIRE(is_metadata); + + REQUIRE(is_metadata_trait>>); + + REQUIRE(has_metadata>>); + + REQUIRE(has_extension>::metadata>); + + REQUIRE(is_spawnable_column); + + REQUIRE(is_indexing_column>); + + REQUIRE(is_dynamic_column>); + + REQUIRE(is_marker_column>); + + REQUIRE(is_column); + REQUIRE(is_column>); + REQUIRE(is_column>); + REQUIRE(is_column>); + + REQUIRE(is_table); + + REQUIRE(is_iterator); + + REQUIRE(with_originals); + + REQUIRE(with_sources>::metadata>); + + REQUIRE(with_base_table); + + REQUIRE(is_index_table); + + Preslice ps = o2::aod::track::collisionId; + REQUIRE(is_preslice); + + REQUIRE(has_filtered_policy::iterator>); + + REQUIRE(is_filtered_iterator::iterator>); + + REQUIRE(is_filtered_table>); + + REQUIRE(is_filtered::iterator>); + REQUIRE(is_filtered>); + + REQUIRE(is_not_filtered_table); + + REQUIRE(is_join); + + auto tl = []() -> SmallGroups { return {std::vector>{}, SelectionVector{}, 0}; }; + REQUIRE(is_smallgroups); + + // AnalysisHelpers + REQUIRE(is_producable); + + Produces prod; + REQUIRE(is_produces); + + struct : ProducesGroup { + Produces p; + } prodg; + REQUIRE(is_produces_group); + + REQUIRE(is_spawnable); + + Spawns spw; + REQUIRE(is_spawns); + + Builds bld; + REQUIRE(is_builds); + + OutputObj oo{"test"}; + REQUIRE(is_outputobj); + + Service srv; + REQUIRE(is_service); + + Partition part = o2::aod::track::collisionId >= 0; + REQUIRE(is_partition); + + // AnalysisTask + Enumeration<0, 1> en; + REQUIRE(is_enumeration); + + // Condition + Condition c{""}; + REQUIRE(is_condition); + + struct : ConditionGroup { + Condition c{""}; + } cg; + REQUIRE(is_condition_group); + + // Configurable + Configurable cc{"", 1, ""}; + REQUIRE(is_configurable); + + ConfigurableAxis ca{"", {0, 1, 2, 3}, ""}; + REQUIRE(is_configurable_axis); + + REQUIRE(is_process_configurable); + + struct : ConfigurableGroup { + Configurable c{"", 1, ""}; + } ccg; + REQUIRE(is_configurable_group); + + // Expressions + expressions::Filter f = o2::aod::track::pt > 1.0f; + REQUIRE(expressions::is_filter); +}