1313
1414#include " Framework/DataRef.h"
1515#include < functional>
16+ #include < fairmq/FwdDecls.h>
1617
1718extern template class std ::function<o2::framework::DataRef(size_t , o2::framework::DataRefIndices)>;
1819extern template class std ::function<o2::framework::DataRefIndices(size_t , o2::framework::DataRefIndices)>;
20+ extern template class std ::function<fair::mq::Message*(size_t , o2::framework::DataRefIndices)>;
1921
2022namespace o2 ::framework
2123{
@@ -38,6 +40,7 @@ class InputSpan
3840 std::function<int (size_t )> refCountGetter,
3941 std::function<DataRef(size_t , DataRefIndices)> indicesGetter,
4042 std::function<DataRefIndices(size_t , DataRefIndices)> nextIndicesGetter,
43+ std::function<fair::mq::Message*(size_t , DataRefIndices)> payloadGetter,
4144 size_t size);
4245
4346 // / @a i-th element of the InputSpan (O(partidx) sequential scan via indices protocol)
@@ -56,6 +59,12 @@ class InputSpan
5659 return mIndicesGetter (slotIdx, indices);
5760 }
5861
62+ // / Return the payload as fair::mq::Message* for the part described by @a indices in slot @a slotIdx
63+ [[nodiscard]] fair::mq::Message* getPayloadAtIndices (size_t slotIdx, DataRefIndices indices) const
64+ {
65+ return mPayloadGetter (slotIdx, indices);
66+ }
67+
5968 // / Advance from @a current to the indices of the next part in slot @a slotIdx in O(1).
6069 [[nodiscard]] DataRefIndices nextIndices (size_t slotIdx, DataRefIndices current) const
6170 {
@@ -179,6 +188,12 @@ class InputSpan
179188 return mCurrentIndices .headerIdx ;
180189 }
181190
191+ // return current indices
192+ [[nodiscard]] DataRefIndices indices () const
193+ {
194+ return mCurrentIndices ;
195+ }
196+
182197 // return an iterable range over all parts in the current slot
183198 // only available for slot-level iterators whose parent has parts(size_t)
184199 [[nodiscard]] auto parts () const
@@ -201,6 +216,7 @@ class InputSpan
201216 [[nodiscard]] DataRefIndices initialIndices () const { return {0 , 1 }; }
202217 [[nodiscard]] DataRefIndices endIndices () const { return {size_t (-1 ), size_t (-1 )}; }
203218 [[nodiscard]] DataRef getAtIndices (DataRefIndices idx) const { return span->getAtIndices (slot, idx); }
219+ [[nodiscard]] fair::mq::Message* getPayloadAtIndices (DataRefIndices idx) const { return span->getPayloadAtIndices (slot, idx); }
204220 [[nodiscard]] DataRefIndices nextIndices (DataRefIndices idx) const { return span->nextIndices (slot, idx); }
205221 [[nodiscard]] size_t size () const { return span->getNofParts (slot); }
206222
@@ -230,6 +246,7 @@ class InputSpan
230246 std::function<int (size_t )> mRefCountGetter ;
231247 std::function<DataRef(size_t , DataRefIndices)> mIndicesGetter ;
232248 std::function<DataRefIndices(size_t , DataRefIndices)> mNextIndicesGetter ;
249+ std::function<fair::mq::Message*(size_t , DataRefIndices)> mPayloadGetter ;
233250 size_t mSize ;
234251};
235252
0 commit comments