Skip to content

Commit cc6abbe

Browse files
committed
DPL: extend DataRefUtils::match to support multiple headers
1 parent 24c97f2 commit cc6abbe

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

Framework/Core/include/Framework/DataRefUtils.h

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#ifndef O2_FRAMEWORK_DATAREFUTILS_H_
1212
#define O2_FRAMEWORK_DATAREFUTILS_H_
1313

14+
#include "Framework/DataDescriptorMatcher.h"
1415
#include "Framework/DataRef.h"
1516
#include "Framework/RootSerializationSupport.h"
1617
#include "Framework/SerializationMethods.h"
@@ -33,6 +34,9 @@ class ConfigurableParam;
3334
namespace o2::framework
3435
{
3536

37+
template <typename H>
38+
concept DataHeaderLike = requires(H& dh) {dh.dataOrigin; dh.dataDescription; dh.subSpecification; };
39+
3640
// FIXME: Should enforce the fact that DataRefs are read only...
3741
struct DataRefUtils {
3842

@@ -220,17 +224,24 @@ struct DataRefUtils {
220224
return ref.spec != nullptr && ref.spec->binding == binding;
221225
}
222226

223-
/// check if the O2 message referred by DataRef matches a particular
224-
/// input spec. The DataHeader is retrieved from the header message and matched
225-
/// against @ref spec parameter.
226-
static bool match(DataRef const& ref, InputSpec const& spec)
227+
template <DataHeaderLike H>
228+
static bool matchHeader(DataRef const& ref, InputSpec const& spec)
227229
{
228-
auto dh = DataRefUtils::getHeader<o2::header::DataHeader*>(ref);
230+
auto const* dh = o2::header::get<H*>(ref.header);
229231
if (dh == nullptr) {
230232
return false;
231233
}
232234
return DataSpecUtils::match(spec, dh->dataOrigin, dh->dataDescription, dh->subSpecification);
233235
}
236+
237+
/// check if the O2 message referred by DataRef matches a particular
238+
/// input spec. The DataHeader is retrieved from the header message and matched
239+
/// against @ref spec parameter.
240+
template <DataHeaderLike... H>
241+
static bool match(DataRef const& ref, InputSpec const& spec)
242+
{
243+
return (DataRefUtils::matchHeader<H>(ref, spec) || ... || matchHeader<o2::header::DataHeader>(ref, spec));
244+
}
234245
};
235246

236247
} // namespace o2::framework

0 commit comments

Comments
 (0)