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;
3334namespace 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...
3741struct DataRefUtils {
3842
@@ -52,7 +56,7 @@ struct DataRefUtils {
5256 if ((payloadSize % sizeof (T)) != 0 ) {
5357 throw runtime_error (" Cannot extract POD from message as size do not match" );
5458 }
55- // FIXME: provide a const collection
59+ // FIXME: provide a const collection
5660 return gsl::span<T>(reinterpret_cast <T*>(const_cast <char *>(ref.payload )), payloadSize / sizeof (T));
5761 } else if constexpr (has_root_dictionary<T>::value == true &&
5862 is_messageable<T>::value == false ) {
@@ -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