Skip to content

Commit 62d5f40

Browse files
committed
move concepts out of AnalysisHelpers.h
1 parent 1223002 commit 62d5f40

2 files changed

Lines changed: 86 additions & 67 deletions

File tree

Framework/Core/include/Framework/AnalysisHelpers.h

Lines changed: 6 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -492,12 +492,6 @@ class TableConsumer;
492492
/// Helper class actually implementing the cursor which can write to
493493
/// a table. The provided template arguments are if type Column and
494494
/// therefore refer only to the persisted columns.
495-
template <typename T>
496-
concept is_producable = soa::has_metadata<aod::MetadataTrait<o2::aod::Hash<T::ref.desc_hash>>> || soa::has_metadata<aod::MetadataTrait<o2::aod::Hash<T::parent_t::ref.desc_hash>>>;
497-
498-
template <typename T>
499-
concept is_enumerated_iterator = requires(T t) { t.globalIndex(); };
500-
501495
template <is_producable T>
502496
struct WritingCursor {
503497
public:
@@ -579,13 +573,13 @@ struct WritingCursor {
579573
decltype(FFL(std::declval<cursor_t>())) cursor;
580574

581575
private:
582-
static decltype(auto) extract(is_enumerated_iterator auto const& arg)
576+
static decltype(auto) extract(soa::is_enumerated_iterator auto const& arg)
583577
{
584578
return arg.globalIndex();
585579
}
586580

587581
template <typename A>
588-
requires(!is_enumerated_iterator<A>)
582+
requires(!soa::is_enumerated_iterator<A>)
589583
static decltype(auto) extract(A&& arg)
590584
{
591585
return arg;
@@ -642,9 +636,6 @@ template <is_producable T>
642636
struct Produces : WritingCursor<T> {
643637
};
644638

645-
template <typename T>
646-
concept is_produces = requires(T t) { typename T::cursor_t; typename T::persistent_table_t; &T::cursor; };
647-
648639
/// Use this to group together produces. Useful to separate them logically
649640
/// or simply to stay within the 100 elements per Task limit.
650641
/// Use as:
@@ -654,11 +645,10 @@ concept is_produces = requires(T t) { typename T::cursor_t; typename T::persiste
654645
///
655646
/// Notice the label MySetOfProduces is just a mnemonic and can be omitted.
656647
struct ProducesGroup {
648+
static constexpr void isProducesGroup()
649+
{};
657650
};
658651

659-
template <typename T>
660-
concept is_produces_group = std::derived_from<T, ProducesGroup>;
661-
662652
/// Helper template for table transformations
663653
template <soa::is_metadata M, soa::TableRef Ref>
664654
struct TableTransform {
@@ -682,12 +672,6 @@ struct TableTransform {
682672

683673
/// This helper struct allows you to declare extended tables which should be
684674
/// created by the task (as opposed to those pre-defined by data model)
685-
template <typename T>
686-
concept is_spawnable = soa::has_metadata<aod::MetadataTrait<o2::aod::Hash<T::originals[T::originals.size() - 1].desc_hash>>> && soa::has_extension<typename aod::MetadataTrait<o2::aod::Hash<T::originals[T::originals.size() - 1].desc_hash>>::metadata>;
687-
688-
template <typename T>
689-
concept is_dynamically_spawnable = soa::has_metadata<aod::MetadataTrait<o2::aod::Hash<T::originals[T::originals.size() - 1].desc_hash>>> && soa::has_configurable_extension<typename aod::MetadataTrait<o2::aod::Hash<T::originals[T::originals.size() - 1].desc_hash>>::metadata>;
690-
691675
template <is_spawnable T>
692676
consteval auto transformBase()
693677
{
@@ -736,13 +720,6 @@ struct Spawns : decltype(transformBase<T>()) {
736720
}();
737721
};
738722

739-
template <typename T>
740-
concept is_spawns = requires(T t) {
741-
typename T::metadata;
742-
typename T::expression_pack_t;
743-
requires std::same_as<decltype(t.projector), std::shared_ptr<gandiva::Projector>>;
744-
};
745-
746723
/// This helper struct allows you to declare extended tables with dynamically-supplied
747724
/// expressions to be created by the task
748725
/// The actual expressions have to be set in init() for the configurable expression
@@ -792,15 +769,6 @@ struct Defines : decltype(transformBase<T>()) {
792769
template <is_dynamically_spawnable T>
793770
using DefinesDelayed = Defines<T, true>;
794771

795-
template <typename T>
796-
concept is_defines = requires(T t) {
797-
typename T::metadata;
798-
typename T::placeholders_pack_t;
799-
requires std::same_as<decltype(t.projector), std::shared_ptr<gandiva::Projector>>;
800-
requires std::same_as<decltype(t.needRecompilation), bool>;
801-
&T::recompile;
802-
};
803-
804772
/// Policy to control index building
805773
/// Exclusive index: each entry in a row has a valid index
806774
/// Sparse index: values in a row can be (-1), index table is isomorphic (joinable) to T1
@@ -859,13 +827,6 @@ struct Builds : decltype(transformBase<T>()) {
859827
}
860828
};
861829

862-
template <typename T>
863-
concept is_builds = requires(T t) {
864-
typename T::metadata;
865-
typename T::Key;
866-
requires std::same_as<decltype(t.map), std::vector<soa::IndexRecord>>;
867-
};
868-
869830
/// a task with rewritten origin, if running together with a task with the default, will
870831
/// have a different name and thus its output would be routed separately
871832

@@ -877,6 +838,7 @@ concept is_builds = requires(T t) {
877838
/// to determine the target file, e.g. analysis result, QA or control histogram,
878839
/// etc.
879840
template <typename T>
841+
requires(std::derived_from<T, TNamed>)
880842
struct OutputObj {
881843
using obj_t = T;
882844

@@ -964,15 +926,6 @@ struct OutputObj {
964926
uint32_t mTaskHash;
965927
};
966928

967-
template <typename T>
968-
concept is_outputobj = requires(T t) {
969-
&T::setHash;
970-
&T::spec;
971-
&T::ref;
972-
requires std::same_as<decltype(t.operator->()), typename T::obj_t*>;
973-
requires std::same_as<decltype(t.object), std::shared_ptr<typename T::obj_t>>;
974-
};
975-
976929
/// This helper allows you to fetch a Sevice from the context or
977930
/// by using some singleton. This hopefully will hide the Singleton and
978931
/// We will be able to retrieve it in a more thread safe manner later on.
@@ -991,12 +944,6 @@ struct Service {
991944
}
992945
};
993946

994-
template <typename T>
995-
concept is_service = requires(T t) {
996-
requires std::same_as<decltype(t.service), typename T::service_t*>;
997-
&T::operator->;
998-
};
999-
1000947
auto getTableFromFilter(soa::is_filtered_table auto const& table, soa::SelectionVector&& selection)
1001948
{
1002949
return std::make_unique<o2::soa::Filtered<std::decay_t<decltype(table)>>>(std::vector{table}, std::forward<soa::SelectionVector>(selection));
@@ -1016,7 +963,7 @@ void initializePartitionCaches(std::set<uint32_t> const& hashes, std::shared_ptr
1016963
/// the real reason is to provide grouped parts for the process functions that request it
1017964
/// better solution would be to "slice" the selection, as is already done in GroupSlicer
1018965
/// for the same purpose, instead of reapplying the filtering
1019-
template <typename T>
966+
template <soa::is_table T>
1020967
struct Partition {
1021968
using content_t = T;
1022969
Partition(expressions::Node&& filter_) : filter{std::forward<expressions::Node>(filter_)}
@@ -1128,13 +1075,6 @@ struct Partition {
11281075
return mFiltered->size();
11291076
}
11301077
};
1131-
1132-
template <typename T>
1133-
concept is_partition = requires(T t) {
1134-
&T::updatePlaceholders;
1135-
requires std::same_as<decltype(t.filter), expressions::Filter>;
1136-
requires std::same_as<decltype(t.mFiltered), std::unique_ptr<o2::soa::Filtered<typename T::content_t>>>;
1137-
};
11381078
} // namespace o2::framework
11391079

11401080
namespace o2::soa

Framework/Core/include/Framework/Concepts.h

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ concept is_not_filtered_table = is_table<T> && !is_filtered_table<T>;
164164
template <typename T>
165165
concept is_join = requires(T t) { t.isJoin(); };
166166

167+
/// 17. require an enumerated iterator
168+
template <typename T>
169+
concept is_enumerated_iterator = requires(T t) { t.globalIndex(); };
170+
167171
/// misc
168172
/// 1. require a type with originals container
169173
template <typename T>
@@ -227,9 +231,84 @@ concept is_preslice_policy = requires(T t) { t.isPreslicePolicy(); };
227231
template <typename T>
228232
concept is_preslice = requires(T t) { t.isPresliceContainer(); };
229233

230-
/// 3. reqiures a preslice group
234+
/// 3. reqiure a preslice group
231235
template <typename T>
232236
concept is_preslice_group = requires(T t) { t.isPresliceGroup(); };
237+
238+
/// 4. require a producable entity
239+
template <typename T>
240+
concept is_producable = soa::has_metadata<aod::MetadataTrait<o2::aod::Hash<T::ref.desc_hash>>> || soa::has_metadata<aod::MetadataTrait<o2::aod::Hash<T::parent_t::ref.desc_hash>>>;
241+
242+
/// 5. require produces declaration
243+
template <typename T>
244+
concept is_produces = requires(T t) { typename T::cursor_t; typename T::persistent_table_t; &T::cursor; };
245+
246+
/// 6. require produces group
247+
template <typename T>
248+
concept is_produces_group = requires(T t) { t.isProducesGroup(); };
249+
250+
/// 7. require spawnable entity
251+
template <typename T>
252+
concept is_spawnable = soa::has_metadata<aod::MetadataTrait<o2::aod::Hash<T::originals[T::originals.size() - 1].desc_hash>>> && soa::has_extension<typename aod::MetadataTrait<o2::aod::Hash<T::originals[T::originals.size() - 1].desc_hash>>::metadata>;
253+
254+
/// 8. require dynamically spawnable entity
255+
template <typename T>
256+
concept is_dynamically_spawnable = soa::has_metadata<aod::MetadataTrait<o2::aod::Hash<T::originals[T::originals.size() - 1].desc_hash>>> && soa::has_configurable_extension<typename aod::MetadataTrait<o2::aod::Hash<T::originals[T::originals.size() - 1].desc_hash>>::metadata>;
257+
258+
/// 9. require spawns declaration
259+
template <typename T>
260+
concept is_spawns = requires(T t) {
261+
typename T::metadata;
262+
typename T::expression_pack_t;
263+
t.projector.get();
264+
};
265+
266+
/// 10. require defines declaration
267+
template <typename T>
268+
concept is_defines = requires(T t) {
269+
typename T::metadata;
270+
typename T::placeholders_pack_t;
271+
t.projector.get();
272+
requires std::same_as<decltype(t.needRecompilation), bool>;
273+
t.recompile();
274+
};
275+
276+
/// 11. require builds declaration
277+
template <typename T>
278+
concept is_builds = requires(T t) {
279+
typename T::metadata;
280+
typename T::Key;
281+
t.map.size();
282+
};
283+
284+
/// 12. require outputobj declaration
285+
template <typename T>
286+
concept is_outputobj = requires(T t) {
287+
&T::setHash;
288+
&T::spec;
289+
&T::ref;
290+
requires std::same_as<decltype(t.operator->()), typename T::obj_t*>;
291+
requires std::same_as<decltype(t.object.get()), typename T::obj_t*>;
292+
};
293+
294+
/// 13. require service declaration
295+
template <typename T>
296+
concept is_service = requires(T t) {
297+
requires std::same_as<decltype(t.service), typename T::service_t*>;
298+
&T::operator->;
299+
};
300+
301+
/// 14. require partition declaration
302+
template <typename T>
303+
concept is_partition = requires(T t) {
304+
&T::updatePlaceholders;
305+
t.mFiltered.get();
306+
&T::operator->;
307+
requires std::same_as<decltype(t.dataframeChanged), bool>;
308+
t.begin();
309+
t.end();
310+
t.size();
311+
};
233312
} // namespace o2::framework
234313

235314
#endif // O2_FRAMEWORK_CONCEPTS_H

0 commit comments

Comments
 (0)